diff options
Diffstat (limited to 'test/test_utf8.cpp')
-rw-r--r-- | test/test_utf8.cpp | 123 |
1 files changed, 60 insertions, 63 deletions
diff --git a/test/test_utf8.cpp b/test/test_utf8.cpp index 8c3cad2..591d1a3 100644 --- a/test/test_utf8.cpp +++ b/test/test_utf8.cpp @@ -203,9 +203,6 @@ TEST(Utf8Test, Utf8MultiByte) EXPECT_EQ(character.size(), multiByteCharacters[idx].size()); EXPECT_EQ(character, multiByteCharacters[idx]); EXPECT_TRUE(multiByteCharacters[idx].valid()); - if (character != multiByteCharacters[idx]) { - printf("idx = %zu, %.*s\n", idx, static_cast<int>(character.size()), character.data()); - } idx++; } characterOpt = utf8Iter.next(); @@ -265,14 +262,14 @@ struct SpanGenerator { TEST(Utf8Test, Utf8IsAlphanumeric) { constexpr size_t numAlphanumericChars = 26 * 2 + 10; - Array<char, numAlphanumericChars + 1> alphanumericCharLiteral{ALPHA_NUMERIC_CHARS}; - Array<char, numAlphanumericChars> alphanumericChars{}; + Array<utf8, numAlphanumericChars + 1> alphanumericCharLiteral{ALPHA_NUMERIC_CHARS}; + Array<utf8, numAlphanumericChars> alphanumericChars{}; copyMem<numAlphanumericChars>(alphanumericChars, alphanumericCharLiteral); ASSERT_TRUE(allOf(alphanumericChars.span(), static_cast<CharPredicate>(isAlphanumeric))); constexpr size_t numNonAlphanumericChars = validAsciiSize - numAlphanumericChars; - Vector<char> nonAlphanumericChars{}; + Vector<utf8> nonAlphanumericChars{}; for (char idx = 0; idx < INT8_MAX; ++idx) { if (!isAlphanumeric(idx)) { ASSERT_EQ(nonAlphanumericChars.pushBack(idx), FudStatus::Success); @@ -291,11 +288,11 @@ TEST(Utf8Test, Utf8IsAlphanumeric) []() { return Array<utf8, invalidAsciiSize>{}; }, [&]() { return iotaGenerator().map([](auto val) { return static_cast<utf8>(val); }); }); - SpanGenerator<char, alphanumericChars.size()> alphanumericGenerator{alphanumericChars.span()}; + SpanGenerator<utf8, alphanumericChars.size()> alphanumericGenerator{alphanumericChars.span()}; auto utf8AlphanumericGenerator = [&]() { return alphanumericGenerator().map(toUtf8<uint16_t>); }; ASSERT_TRUE(allOf(utf8AlphanumericGenerator, static_cast<FudUtf8Predicate>(isAlphanumeric))); - SpanGenerator<char> nonAlphanumericGenerator{nonAlphanumericChars.span().takeOkay()}; + SpanGenerator<utf8> nonAlphanumericGenerator{nonAlphanumericChars.span().takeOkay()}; auto utf8NonAlphanumericGenerator = [&]() { return nonAlphanumericGenerator().map(toUtf8<uint16_t>); }; ASSERT_FALSE(anyOf(utf8NonAlphanumericGenerator, static_cast<FudUtf8Predicate>(isAlphanumeric))); } @@ -303,14 +300,14 @@ TEST(Utf8Test, Utf8IsAlphanumeric) TEST(Utf8Test, Utf8IsAlpha) { constexpr size_t numAlphaChars = sizeof(ALPHA_CHARS) - 1; - Array<char, numAlphaChars + 1> alphaCharLiteral{ALPHA_CHARS}; - Array<char, numAlphaChars> alphaChars{}; + Array<utf8, numAlphaChars + 1> alphaCharLiteral{ALPHA_CHARS}; + Array<utf8, numAlphaChars> alphaChars{}; copyMem<numAlphaChars>(alphaChars, alphaCharLiteral); ASSERT_TRUE(allOf(alphaChars.span(), static_cast<CharPredicate>(isAlpha))); constexpr size_t numNonAlphanumericChars = validAsciiSize - numAlphaChars; - Vector<char> nonAlphaChars{}; + Vector<utf8> nonAlphaChars{}; for (char idx = 0; idx < INT8_MAX; ++idx) { if (!isAlphanumeric(idx)) { ASSERT_EQ(nonAlphaChars.pushBack(idx), FudStatus::Success); @@ -323,11 +320,11 @@ TEST(Utf8Test, Utf8IsAlpha) ASSERT_FALSE(isAlpha(FudUtf8{Ascii{invalidAscii}})); - SpanGenerator<char, alphaChars.size()> alphaGenerator{alphaChars.span()}; + SpanGenerator<utf8, alphaChars.size()> alphaGenerator{alphaChars.span()}; auto utf8AlphaGenerator = [&]() { return alphaGenerator().map(toUtf8<uint16_t>); }; ASSERT_TRUE(allOf(utf8AlphaGenerator, static_cast<FudUtf8Predicate>(isAlpha))); - SpanGenerator<char> nonAlphaGenerator{nonAlphaChars.span().takeOkay()}; + SpanGenerator<utf8> nonAlphaGenerator{nonAlphaChars.span().takeOkay()}; auto utf8NonAlphaGenerator = [&]() { return nonAlphaGenerator().map(toUtf8<uint16_t>); }; ASSERT_FALSE(anyOf(utf8NonAlphaGenerator, static_cast<FudUtf8Predicate>(isAlpha))); } @@ -335,14 +332,14 @@ TEST(Utf8Test, Utf8IsAlpha) TEST(Utf8Test, Utf8IsLower) { constexpr size_t numLowerChars = 26; - Array<char, numLowerChars + 1> lowerCharLiteral{LOWERCASE_CHARS}; - Array<char, numLowerChars> lowerChars{}; + Array<utf8, numLowerChars + 1> lowerCharLiteral{LOWERCASE_CHARS}; + Array<utf8, numLowerChars> lowerChars{}; copyMem<numLowerChars>(lowerChars, lowerCharLiteral); ASSERT_TRUE(allOf(lowerChars.span(), static_cast<CharPredicate>(isLowercase))); constexpr size_t numNonLowerChars = validAsciiSize - numLowerChars; - Vector<char> nonLowerChars{}; + Vector<utf8> nonLowerChars{}; for (char idx = 0; idx < INT8_MAX; ++idx) { if (!isLowercase(idx)) { ASSERT_EQ(nonLowerChars.pushBack(idx), FudStatus::Success); @@ -355,11 +352,11 @@ TEST(Utf8Test, Utf8IsLower) ASSERT_FALSE(isLowercase(FudUtf8{Ascii{invalidAscii}})); - SpanGenerator<char, lowerChars.size()> lowerGenerator{lowerChars.span()}; + SpanGenerator<utf8, lowerChars.size()> lowerGenerator{lowerChars.span()}; auto utf8LowerGenerator = [&]() { return lowerGenerator().map(toUtf8<uint16_t>); }; ASSERT_TRUE(allOf(utf8LowerGenerator, static_cast<FudUtf8Predicate>(isLowercase))); - SpanGenerator<char> nonLowerGenerator{nonLowerChars.span().takeOkay()}; + SpanGenerator<utf8> nonLowerGenerator{nonLowerChars.span().takeOkay()}; auto utf8NonLowerGenerator = [&]() { return nonLowerGenerator().map(toUtf8<uint16_t>); }; ASSERT_FALSE(anyOf(utf8NonLowerGenerator, static_cast<FudUtf8Predicate>(isLowercase))); } @@ -367,15 +364,15 @@ TEST(Utf8Test, Utf8IsLower) TEST(Utf8Test, Utf8IsUpper) { constexpr size_t numUpperChars = 26; - Array<char, numUpperChars + 1> upperCharLiteral{UPPERCASE_CHARS}; - Array<char, numUpperChars> upperChars{}; + Array<utf8, numUpperChars + 1> upperCharLiteral{UPPERCASE_CHARS}; + Array<utf8, numUpperChars> upperChars{}; copyMem<numUpperChars>(upperChars, upperCharLiteral); ASSERT_TRUE(allOf(upperChars.span(), static_cast<CharPredicate>(isUppercase))); constexpr size_t numNonUpperChars = validAsciiSize - numUpperChars; - Vector<char> nonUpperChars{}; - for (char idx = 0; idx < INT8_MAX; ++idx) { + Vector<utf8> nonUpperChars{}; + for (utf8 idx = 0; idx < INT8_MAX; ++idx) { if (!isUppercase(idx)) { ASSERT_EQ(nonUpperChars.pushBack(idx), FudStatus::Success); } @@ -387,11 +384,11 @@ TEST(Utf8Test, Utf8IsUpper) ASSERT_FALSE(isUppercase(FudUtf8{Ascii{invalidAscii}})); - SpanGenerator<char, upperChars.size()> upperGenerator{upperChars.span()}; + SpanGenerator<utf8, upperChars.size()> upperGenerator{upperChars.span()}; auto utf8UpperGenerator = [&]() { return upperGenerator().map(toUtf8<uint16_t>); }; ASSERT_TRUE(allOf(utf8UpperGenerator, static_cast<FudUtf8Predicate>(isUppercase))); - SpanGenerator<char> nonUpperGenerator{nonUpperChars.span().takeOkay()}; + SpanGenerator<utf8> nonUpperGenerator{nonUpperChars.span().takeOkay()}; auto utf8NonUpperGenerator = [&]() { return nonUpperGenerator().map(toUtf8<uint16_t>); }; ASSERT_FALSE(anyOf(utf8NonUpperGenerator, static_cast<FudUtf8Predicate>(isUppercase))); } @@ -399,14 +396,14 @@ TEST(Utf8Test, Utf8IsUpper) TEST(Utf8Test, Utf8IsDigit) { constexpr size_t numDigitChars = 10; - Array<char, numDigitChars + 1> digitCharLiteral{DECIMAL_CHARS}; - Array<char, numDigitChars> digitChars{}; + Array<utf8, numDigitChars + 1> digitCharLiteral{DECIMAL_CHARS}; + Array<utf8, numDigitChars> digitChars{}; copyMem<numDigitChars>(digitChars, digitCharLiteral); ASSERT_TRUE(allOf(digitChars.span(), static_cast<CharPredicate>(isDigit))); constexpr size_t numNonDigitChars = validAsciiSize - numDigitChars; - Vector<char> nonDigitChars{}; + Vector<utf8> nonDigitChars{}; for (char idx = 0; idx < INT8_MAX; ++idx) { if (!isDigit(idx)) { ASSERT_EQ(nonDigitChars.pushBack(idx), FudStatus::Success); @@ -419,11 +416,11 @@ TEST(Utf8Test, Utf8IsDigit) ASSERT_FALSE(isDigit(FudUtf8{Ascii{invalidAscii}})); - SpanGenerator<char, digitChars.size()> digitGenerator{digitChars.span()}; + SpanGenerator<utf8, digitChars.size()> digitGenerator{digitChars.span()}; auto utf8DigitGenerator = [&]() { return digitGenerator().map(toUtf8<uint16_t>); }; ASSERT_TRUE(allOf(utf8DigitGenerator, static_cast<FudUtf8Predicate>(isDigit))); - SpanGenerator<char> nonDigitGenerator{nonDigitChars.span().takeOkay()}; + SpanGenerator<utf8> nonDigitGenerator{nonDigitChars.span().takeOkay()}; auto utf8NonDigitGenerator = [&]() { return nonDigitGenerator().map(toUtf8<uint16_t>); }; ASSERT_FALSE(anyOf(utf8NonDigitGenerator, static_cast<FudUtf8Predicate>(isDigit))); } @@ -431,14 +428,14 @@ TEST(Utf8Test, Utf8IsDigit) TEST(Utf8Test, Utf8IsHexDigit) { constexpr size_t numHexDigitChars = 6 * 2 + 10; - Array<char, numHexDigitChars + 1> hexDigitCharLiteral{"abcdefABCDEF0123456789"}; - Array<char, numHexDigitChars> hexDigitChars{}; + Array<utf8, numHexDigitChars + 1> hexDigitCharLiteral{u8"abcdefABCDEF0123456789"}; + Array<utf8, numHexDigitChars> hexDigitChars{}; copyMem<numHexDigitChars>(hexDigitChars, hexDigitCharLiteral); ASSERT_TRUE(allOf(hexDigitChars.span(), static_cast<CharPredicate>(isHexDigit))); constexpr size_t numNonHexDigitChars = validAsciiSize - numHexDigitChars; - Vector<char> nonHexDigitChars{}; + Vector<utf8> nonHexDigitChars{}; for (char idx = 0; idx < INT8_MAX; ++idx) { if (!isHexDigit(idx)) { ASSERT_EQ(nonHexDigitChars.pushBack(idx), FudStatus::Success); @@ -451,11 +448,11 @@ TEST(Utf8Test, Utf8IsHexDigit) ASSERT_FALSE(isHexDigit(FudUtf8{Ascii{invalidAscii}})); - SpanGenerator<char, hexDigitChars.size()> hexDigitGenerator{hexDigitChars.span()}; + SpanGenerator<utf8, hexDigitChars.size()> hexDigitGenerator{hexDigitChars.span()}; auto utf8HexDigitGenerator = [&]() { return hexDigitGenerator().map(toUtf8<uint16_t>); }; ASSERT_TRUE(allOf(utf8HexDigitGenerator, static_cast<FudUtf8Predicate>(isHexDigit))); - SpanGenerator<char> nonHexDigitGenerator{nonHexDigitChars.span().takeOkay()}; + SpanGenerator<utf8> nonHexDigitGenerator{nonHexDigitChars.span().takeOkay()}; auto utf8NonHexDigitGenerator = [&]() { return nonHexDigitGenerator().map(toUtf8<uint16_t>); }; ASSERT_FALSE(anyOf(utf8NonHexDigitGenerator, static_cast<FudUtf8Predicate>(isHexDigit))); } @@ -463,14 +460,14 @@ TEST(Utf8Test, Utf8IsHexDigit) TEST(Utf8Test, Utf8IsControl) { Iota<char> controlArrayGenerator{0, 1, numControlChars}; - auto controlChars = generate([]() { return Array<char, numControlChars>{}; }, controlArrayGenerator); + auto controlChars = generate([]() { return Array<utf8, numControlChars>{}; }, controlArrayGenerator); constexpr const char deleteChar = 0x7F; controlChars.back() = deleteChar; ASSERT_TRUE(allOf(controlChars.span(), static_cast<CharPredicate>(isControl))); constexpr size_t numNonControlChars = INT8_MAX + 1 - numControlChars; - Vector<char> nonControlChars{}; + Vector<utf8> nonControlChars{}; ASSERT_EQ(nonControlChars.reserve(numNonControlChars), FudStatus::Success); for (auto idx = numControlChars - 1; idx < deleteChar; ++idx) { ASSERT_EQ(nonControlChars.pushBack(idx), FudStatus::Success); @@ -483,11 +480,11 @@ TEST(Utf8Test, Utf8IsControl) ASSERT_FALSE(isControl(FudUtf8{Ascii{invalidAscii}})); - SpanGenerator<char, controlChars.size()> controlGenerator{controlChars.span()}; + SpanGenerator<utf8, controlChars.size()> controlGenerator{controlChars.span()}; auto utf8ControlGenerator = [&]() { return controlGenerator().map(toUtf8<uint16_t>); }; ASSERT_TRUE(allOf(utf8ControlGenerator, static_cast<FudUtf8Predicate>(isControl))); - SpanGenerator<char> nonControlGenerator{nonControlChars.span().takeOkay()}; + SpanGenerator<utf8> nonControlGenerator{nonControlChars.span().takeOkay()}; auto utf8NonControlGenerator = [&]() { return nonControlGenerator().map(toUtf8<uint16_t>); }; ASSERT_FALSE(anyOf(utf8NonControlGenerator, static_cast<FudUtf8Predicate>(isControl))); } @@ -495,14 +492,14 @@ TEST(Utf8Test, Utf8IsControl) TEST(Utf8Test, Utf8IsGraphical) { constexpr size_t numGraphicalChars = sizeof(GRAPHICAL_CHARS) - 1; - Array<char, numGraphicalChars + 1> graphicalCharLiteral{GRAPHICAL_CHARS}; - Array<char, numGraphicalChars> graphicalChars{}; + Array<utf8, numGraphicalChars + 1> graphicalCharLiteral{GRAPHICAL_CHARS}; + Array<utf8, numGraphicalChars> graphicalChars{}; copyMem<numGraphicalChars>(graphicalChars, graphicalCharLiteral); ASSERT_TRUE(allOf(graphicalChars.span(), static_cast<CharPredicate>(isGraphical))); constexpr size_t numNonGraphicalChars = validAsciiSize - numGraphicalChars; - Vector<char> nonGraphicalChars{}; + Vector<utf8> nonGraphicalChars{}; ASSERT_EQ(nonGraphicalChars.reserve(numNonGraphicalChars), FudStatus::Success); for (uint8_t idx = 0; idx < INT8_MAX + 1; ++idx) { if (!isGraphical(static_cast<char>(idx))) { @@ -518,11 +515,11 @@ TEST(Utf8Test, Utf8IsGraphical) ASSERT_FALSE(isGraphical(FudUtf8{Ascii{invalidAscii}})); - SpanGenerator<char, graphicalChars.size()> graphicalGenerator{graphicalChars.span()}; + SpanGenerator<utf8, graphicalChars.size()> graphicalGenerator{graphicalChars.span()}; auto utf8GraphicalGenerator = [&]() { return graphicalGenerator().map(toUtf8<uint16_t>); }; ASSERT_TRUE(allOf(utf8GraphicalGenerator, static_cast<FudUtf8Predicate>(isGraphical))); - SpanGenerator<char> nonGraphicalGenerator{nonGraphicalChars.span().takeOkay()}; + SpanGenerator<utf8> nonGraphicalGenerator{nonGraphicalChars.span().takeOkay()}; auto utf8NonGraphicalGenerator = [&]() { return nonGraphicalGenerator().map(toUtf8<uint16_t>); }; ASSERT_FALSE(anyOf(utf8NonGraphicalGenerator, static_cast<FudUtf8Predicate>(isGraphical))); } @@ -530,14 +527,14 @@ TEST(Utf8Test, Utf8IsGraphical) TEST(Utf8Test, Utf8IsSpace) { constexpr size_t numSpaceChars = sizeof(SPACE_CHARS) - 1; - Array<char, numSpaceChars + 1> spaceCharLiteral{SPACE_CHARS}; - Array<char, numSpaceChars> spaceChars{}; + Array<utf8, numSpaceChars + 1> spaceCharLiteral{SPACE_CHARS}; + Array<utf8, numSpaceChars> spaceChars{}; copyMem<numSpaceChars>(spaceChars, spaceCharLiteral); ASSERT_TRUE(allOf(spaceChars.span(), static_cast<CharPredicate>(isSpace))); constexpr size_t numNonSpaceChars = validAsciiSize - numSpaceChars; - Vector<char> nonSpaceChars{}; + Vector<utf8> nonSpaceChars{}; ASSERT_EQ(nonSpaceChars.reserve(numNonSpaceChars), FudStatus::Success); for (uint8_t idx = 0; idx < INT8_MAX + 1; ++idx) { if (!isSpace(static_cast<char>(idx))) { @@ -553,11 +550,11 @@ TEST(Utf8Test, Utf8IsSpace) ASSERT_FALSE(isSpace(FudUtf8{Ascii{invalidAscii}})); - SpanGenerator<char, spaceChars.size()> spaceGenerator{spaceChars.span()}; + SpanGenerator<utf8, spaceChars.size()> spaceGenerator{spaceChars.span()}; auto utf8SpaceGenerator = [&]() { return spaceGenerator().map(toUtf8<uint16_t>); }; ASSERT_TRUE(allOf(utf8SpaceGenerator, static_cast<FudUtf8Predicate>(isSpace))); - SpanGenerator<char> nonSpaceGenerator{nonSpaceChars.span().takeOkay()}; + SpanGenerator<utf8> nonSpaceGenerator{nonSpaceChars.span().takeOkay()}; auto utf8NonSpaceGenerator = [&]() { return nonSpaceGenerator().map(toUtf8<uint16_t>); }; ASSERT_FALSE(anyOf(utf8NonSpaceGenerator, static_cast<FudUtf8Predicate>(isSpace))); } @@ -565,14 +562,14 @@ TEST(Utf8Test, Utf8IsSpace) TEST(Utf8Test, Utf8IsBlank) { constexpr size_t numBlankChars = sizeof(BLANK_CHARS) - 1; - Array<char, numBlankChars + 1> blankCharLiteral{BLANK_CHARS}; - Array<char, numBlankChars> blankChars{}; + Array<utf8, numBlankChars + 1> blankCharLiteral{BLANK_CHARS}; + Array<utf8, numBlankChars> blankChars{}; copyMem<numBlankChars>(blankChars, blankCharLiteral); ASSERT_TRUE(allOf(blankChars.span(), static_cast<CharPredicate>(isBlank))); constexpr size_t numNonBlankChars = validAsciiSize - numBlankChars; - Vector<char> nonBlankChars{}; + Vector<utf8> nonBlankChars{}; ASSERT_EQ(nonBlankChars.reserve(numNonBlankChars), FudStatus::Success); for (uint8_t idx = 0; idx < INT8_MAX + 1; ++idx) { if (!isBlank(static_cast<char>(idx))) { @@ -588,11 +585,11 @@ TEST(Utf8Test, Utf8IsBlank) ASSERT_FALSE(isBlank(FudUtf8{Ascii{invalidAscii}})); - SpanGenerator<char, blankChars.size()> blankGenerator{blankChars.span()}; + SpanGenerator<utf8, blankChars.size()> blankGenerator{blankChars.span()}; auto utf8BlankGenerator = [&]() { return blankGenerator().map(toUtf8<uint16_t>); }; ASSERT_TRUE(allOf(utf8BlankGenerator, static_cast<FudUtf8Predicate>(isBlank))); - SpanGenerator<char> nonBlankGenerator{nonBlankChars.span().takeOkay()}; + SpanGenerator<utf8> nonBlankGenerator{nonBlankChars.span().takeOkay()}; auto utf8NonBlankGenerator = [&]() { return nonBlankGenerator().map(toUtf8<uint16_t>); }; ASSERT_FALSE(anyOf(utf8NonBlankGenerator, static_cast<FudUtf8Predicate>(isBlank))); } @@ -600,14 +597,14 @@ TEST(Utf8Test, Utf8IsBlank) TEST(Utf8Test, Utf8IsPrintable) { constexpr size_t numPrintableChars = sizeof(PRINTABLE_CHARS) - 1; - Array<char, numPrintableChars + 1> printableCharLiteral{PRINTABLE_CHARS}; - Array<char, numPrintableChars> printableChars{}; + Array<utf8, numPrintableChars + 1> printableCharLiteral{PRINTABLE_CHARS}; + Array<utf8, numPrintableChars> printableChars{}; copyMem<numPrintableChars>(printableChars, printableCharLiteral); ASSERT_TRUE(allOf(printableChars.span(), static_cast<CharPredicate>(isPrintable))); constexpr size_t numNonPrintableChars = validAsciiSize - numPrintableChars; - Vector<char> nonPrintableChars{}; + Vector<utf8> nonPrintableChars{}; ASSERT_EQ(nonPrintableChars.reserve(numNonPrintableChars), FudStatus::Success); for (uint8_t idx = 0; idx < INT8_MAX + 1; ++idx) { if (!isPrintable(static_cast<char>(idx))) { @@ -623,11 +620,11 @@ TEST(Utf8Test, Utf8IsPrintable) ASSERT_FALSE(isPrintable(FudUtf8{Ascii{invalidAscii}})); - SpanGenerator<char, printableChars.size()> printableGenerator{printableChars.span()}; + SpanGenerator<utf8, printableChars.size()> printableGenerator{printableChars.span()}; auto utf8PrintableGenerator = [&]() { return printableGenerator().map(toUtf8<uint16_t>); }; ASSERT_TRUE(allOf(utf8PrintableGenerator, static_cast<FudUtf8Predicate>(isPrintable))); - SpanGenerator<char> nonPrintableGenerator{nonPrintableChars.span().takeOkay()}; + SpanGenerator<utf8> nonPrintableGenerator{nonPrintableChars.span().takeOkay()}; auto utf8NonPrintableGenerator = [&]() { return nonPrintableGenerator().map(toUtf8<uint16_t>); }; ASSERT_FALSE(anyOf(utf8NonPrintableGenerator, static_cast<FudUtf8Predicate>(isPrintable))); } @@ -635,14 +632,14 @@ TEST(Utf8Test, Utf8IsPrintable) TEST(Utf8Test, Utf8IsPunctuation) { constexpr size_t numPunctuationChars = sizeof(PUNCTUATION_CHARS) - 1; - Array<char, numPunctuationChars + 1> punctuationCharLiteral{PUNCTUATION_CHARS}; - Array<char, numPunctuationChars> punctuationChars{}; + Array<utf8, numPunctuationChars + 1> punctuationCharLiteral{PUNCTUATION_CHARS}; + Array<utf8, numPunctuationChars> punctuationChars{}; copyMem<numPunctuationChars>(punctuationChars, punctuationCharLiteral); ASSERT_TRUE(allOf(punctuationChars.span(), static_cast<CharPredicate>(isPunctuation))); constexpr size_t numNonPunctuationChars = validAsciiSize - numPunctuationChars; - Vector<char> nonPunctuationChars{}; + Vector<utf8> nonPunctuationChars{}; ASSERT_EQ(nonPunctuationChars.reserve(numNonPunctuationChars), FudStatus::Success); for (uint8_t idx = 0; idx < INT8_MAX + 1; ++idx) { if (!isPunctuation(static_cast<char>(idx))) { @@ -658,11 +655,11 @@ TEST(Utf8Test, Utf8IsPunctuation) ASSERT_FALSE(isPunctuation(FudUtf8{Ascii{invalidAscii}})); - SpanGenerator<char, punctuationChars.size()> punctuationGenerator{punctuationChars.span()}; + SpanGenerator<utf8, punctuationChars.size()> punctuationGenerator{punctuationChars.span()}; auto utf8PunctuationGenerator = [&]() { return punctuationGenerator().map(toUtf8<uint16_t>); }; ASSERT_TRUE(allOf(utf8PunctuationGenerator, static_cast<FudUtf8Predicate>(isPunctuation))); - SpanGenerator<char> nonPunctuationGenerator{nonPunctuationChars.span().takeOkay()}; + SpanGenerator<utf8> nonPunctuationGenerator{nonPunctuationChars.span().takeOkay()}; auto utf8NonPunctuationGenerator = [&]() { return nonPunctuationGenerator().map(toUtf8<uint16_t>); }; ASSERT_FALSE(anyOf(utf8NonPunctuationGenerator, static_cast<FudUtf8Predicate>(isPunctuation))); } |