FOSSology  4.7.1
Open Source License Compliance by Open Source Software
ReplaceUnicodeControlCharsTest Class Reference
Inheritance diagram for ReplaceUnicodeControlCharsTest:
Inheritance graph
Collaboration diagram for ReplaceUnicodeControlCharsTest:
Collaboration graph

Protected Member Functions

void testPlainAsciiIsUnchanged ()
 Plain ASCII text passes through unchanged.
 
void testTabAndNewlineAreKept ()
 Horizontal tab (U+0009) and line feed (U+000A) are kept. More...
 
void testCarriageReturnIsKept ()
 Carriage return (U+000D) is kept.
 
void testNullByteIsStripped ()
 Null byte (U+0000) is stripped.
 
void testC0ControlCharsAreStripped ()
 C0 control characters U+0001-U+0008 are stripped. More...
 
void testC1ControlCharsAreStripped ()
 C1 control characters U+0080-U+009F are stripped. More...
 
void testDeleteCharIsStripped ()
 DEL character (U+007F) is stripped.
 
void testUtf8MultiBytePrintableIsKept ()
 A printable multi-byte UTF-8 character (e.g. U+00A9 ©) is kept.
 
void testSurrogatePairCodepointIsKept ()
 A codepoint above U+FFFF (surrogate-pair range in UTF-16) is kept. More...
 
void testMixedControlAndPrintableFiltered ()
 A string mixing control characters and printable text is filtered correctly. More...
 
void testEmptyStringIsUnchanged ()
 An empty input string returns an empty string.
 

Private Member Functions

 CPPUNIT_TEST_SUITE (ReplaceUnicodeControlCharsTest)
 
 CPPUNIT_TEST (testPlainAsciiIsUnchanged)
 
 CPPUNIT_TEST (testTabAndNewlineAreKept)
 
 CPPUNIT_TEST (testCarriageReturnIsKept)
 
 CPPUNIT_TEST (testNullByteIsStripped)
 
 CPPUNIT_TEST (testC0ControlCharsAreStripped)
 
 CPPUNIT_TEST (testC1ControlCharsAreStripped)
 
 CPPUNIT_TEST (testDeleteCharIsStripped)
 
 CPPUNIT_TEST (testUtf8MultiBytePrintableIsKept)
 
 CPPUNIT_TEST (testSurrogatePairCodepointIsKept)
 
 CPPUNIT_TEST (testMixedControlAndPrintableFiltered)
 
 CPPUNIT_TEST (testEmptyStringIsUnchanged)
 
 CPPUNIT_TEST_SUITE_END ()
 
std::string call (const std::string &s)
 

Private Attributes

ReuserHelpersAccessor acc
 

Detailed Description

Definition at line 213 of file test_helpers.cc.

Member Function Documentation

◆ testC0ControlCharsAreStripped()

void ReplaceUnicodeControlCharsTest::testC0ControlCharsAreStripped ( )
inlineprotected

C0 control characters U+0001-U+0008 are stripped.

Characters in the range 0x01-0x08 are non-printable controls that can corrupt database content or confuse downstream parsers.

Definition at line 279 of file test_helpers.cc.

◆ testC1ControlCharsAreStripped()

void ReplaceUnicodeControlCharsTest::testC1ControlCharsAreStripped ( )
inlineprotected

C1 control characters U+0080-U+009F are stripped.

These are legacy 8-bit control codes that appear in some legacy copyright strings; they must not pass through to the database.

Definition at line 308 of file test_helpers.cc.

◆ testMixedControlAndPrintableFiltered()

void ReplaceUnicodeControlCharsTest::testMixedControlAndPrintableFiltered ( )
inlineprotected

A string mixing control characters and printable text is filtered correctly.

Only the printable parts survive; embedded controls are removed without corrupting adjacent characters.

Definition at line 358 of file test_helpers.cc.

◆ testSurrogatePairCodepointIsKept()

void ReplaceUnicodeControlCharsTest::testSurrogatePairCodepointIsKept ( )
inlineprotected

A codepoint above U+FFFF (surrogate-pair range in UTF-16) is kept.

ICU's char32At() returns the full codepoint for supplementary characters and advances the index by 2 UTF-16 code units. The implementation skips the second unit via ++i to avoid processing half a surrogate pair as a separate character. This test verifies that such a codepoint (U+1F600 😀) survives the filter intact and the iterator does not go out of bounds.

Definition at line 345 of file test_helpers.cc.

◆ testTabAndNewlineAreKept()

void ReplaceUnicodeControlCharsTest::testTabAndNewlineAreKept ( )
inlineprotected

Horizontal tab (U+0009) and line feed (U+000A) are kept.

These are standard whitespace characters not classified as controls by the filter (only U+0000-U+0008 are stripped in the C0 range).

Definition at line 251 of file test_helpers.cc.


The documentation for this class was generated from the following file: