From 5cc7cbc3704ec255eb5d0ac53b2cc0fcb1221d63 Mon Sep 17 00:00:00 2001 From: Dominick Allen Date: Wed, 23 Oct 2024 13:21:10 -0500 Subject: String conversion and parsing format spec. --- test/test_utf8.cpp | 219 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 124 insertions(+), 95 deletions(-) (limited to 'test/test_utf8.cpp') diff --git a/test/test_utf8.cpp b/test/test_utf8.cpp index d1737f7..4b57b64 100644 --- a/test/test_utf8.cpp +++ b/test/test_utf8.cpp @@ -30,6 +30,35 @@ namespace fud { +using classify::CharPredicate; +using classify::FudUtf8Predicate; +using classify::isAscii; +using classify::isAscii; +using classify:: isAlphanumeric; +using classify:: isAlphanumeric; +using classify:: isAlpha; +using classify:: isAlpha; +using classify:: isLowercase; +using classify:: isLowercase; +using classify:: isUppercase; +using classify:: isUppercase; +using classify:: isDigit; +using classify:: isDigit; +using classify:: isHexDigit; +using classify:: isHexDigit; +using classify:: isControl; +using classify:: isControl; +using classify:: isGraphical; +using classify:: isGraphical; +using classify:: isSpace; +using classify:: isSpace; +using classify:: isBlank; +using classify:: isBlank; +using classify:: isPrintable; +using classify:: isPrintable; +using classify:: isPunctuation; +using classify:: isPunctuation; + constexpr size_t validAsciiSize = INT8_MAX + 1; constexpr size_t invalidAsciiSize = UINT8_MAX + 1 - validAsciiSize; @@ -194,24 +223,24 @@ TEST(Utf8Test, Utf8MultiByte) TEST(Utf8Test, Utf8IsAscii) { - ASSERT_FALSE(charIsAscii(invalidAscii)); + ASSERT_FALSE(isAscii(invalidAscii)); Iota charIota{0, 1, validAsciiSize}; - ASSERT_TRUE(allOf([&]() -> Option { return charIota().map(toLetter); }, charIsAscii)); + ASSERT_TRUE(allOf([&]() -> Option { return charIota().map(toLetter); }, static_cast(isAscii))); Iota invalidCharIota{validAsciiSize, 1, invalidAsciiSize}; - ASSERT_FALSE(anyOf([&]() -> Option { return invalidCharIota().map(toLetter); }, charIsAscii)); + ASSERT_FALSE(anyOf([&]() -> Option { return invalidCharIota().map(toLetter); }, static_cast(isAscii))); FudUtf8 unicode{FudUtf8::invalidAscii()}; - ASSERT_FALSE(utf8IsAscii(unicode)); + ASSERT_FALSE(isAscii(unicode)); charIota.set(0); - ASSERT_TRUE(allOf([&]() -> Option { return charIota().map(toUtf8); }, utf8IsAscii)); + ASSERT_TRUE(allOf([&]() -> Option { return charIota().map(toUtf8); }, static_cast(isAscii))); invalidCharIota.set(invalidAsciiSize); - ASSERT_FALSE(anyOf([&]() -> Option { return invalidCharIota().map(toUtf8); }, utf8IsAscii)); + ASSERT_FALSE(anyOf([&]() -> Option { return invalidCharIota().map(toUtf8); }, static_cast(isAscii))); } template @@ -241,22 +270,22 @@ TEST(Utf8Test, Utf8IsAlphanumeric) Array alphanumericChars{}; copyMem(alphanumericChars, alphanumericCharLiteral); - ASSERT_TRUE(allOf(alphanumericChars.span(), charIsAlphanumeric)); + ASSERT_TRUE(allOf(alphanumericChars.span(), static_cast(isAlphanumeric))); constexpr size_t numNonAlphanumericChars = validAsciiSize - numAlphanumericChars; Vector nonAlphanumericChars{}; for (char idx = 0; idx < INT8_MAX; ++idx) { - if (!charIsAlphanumeric(idx)) { + if (!isAlphanumeric(idx)) { ASSERT_EQ(nonAlphanumericChars.pushBack(idx), FudStatus::Success); } } auto nonAlphanumericSpan{nonAlphanumericChars.span().takeOkay()}; - ASSERT_FALSE(anyOf(nonAlphanumericSpan, charIsAlphanumeric)); + ASSERT_FALSE(anyOf(nonAlphanumericSpan, static_cast(isAlphanumeric))); auto invalidAsciiChars = invalidAsciiGenerator(); - ASSERT_FALSE(anyOf(invalidAsciiChars, charIsAlphanumeric)); + ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast(isAlphanumeric))); - ASSERT_FALSE(utf8IsAlphanumeric(FudUtf8{Ascii{invalidAscii}})); + ASSERT_FALSE(isAlphanumeric(FudUtf8{Ascii{invalidAscii}})); auto iotaGenerator = invalidAsciiGenerator(); auto generator = generate( @@ -265,11 +294,11 @@ TEST(Utf8Test, Utf8IsAlphanumeric) SpanGenerator alphanumericGenerator{alphanumericChars.span()}; auto utf8AlphanumericGenerator = [&]() { return alphanumericGenerator().map(toUtf8); }; - ASSERT_TRUE(allOf(utf8AlphanumericGenerator, utf8IsAlphanumeric)); + ASSERT_TRUE(allOf(utf8AlphanumericGenerator, static_cast(isAlphanumeric))); SpanGenerator nonAlphanumericGenerator{nonAlphanumericChars.span().takeOkay()}; auto utf8NonAlphanumericGenerator = [&]() { return nonAlphanumericGenerator().map(toUtf8); }; - ASSERT_FALSE(anyOf(utf8NonAlphanumericGenerator, utf8IsAlphanumeric)); + ASSERT_FALSE(anyOf(utf8NonAlphanumericGenerator, static_cast(isAlphanumeric))); } TEST(Utf8Test, Utf8IsAlpha) @@ -279,29 +308,29 @@ TEST(Utf8Test, Utf8IsAlpha) Array alphaChars{}; copyMem(alphaChars, alphaCharLiteral); - ASSERT_TRUE(allOf(alphaChars.span(), charIsAlpha)); + ASSERT_TRUE(allOf(alphaChars.span(), static_cast(isAlpha))); constexpr size_t numNonAlphanumericChars = validAsciiSize - numAlphaChars; Vector nonAlphaChars{}; for (char idx = 0; idx < INT8_MAX; ++idx) { - if (!charIsAlphanumeric(idx)) { + if (!isAlphanumeric(idx)) { ASSERT_EQ(nonAlphaChars.pushBack(idx), FudStatus::Success); } } - ASSERT_FALSE(anyOf(nonAlphaChars.span().takeOkay(), charIsAlpha)); + ASSERT_FALSE(anyOf(nonAlphaChars.span().takeOkay(), static_cast(isAlpha))); auto invalidAsciiChars = invalidAsciiGenerator(); - ASSERT_FALSE(anyOf(invalidAsciiChars, charIsAlpha)); + ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast(isAlpha))); - ASSERT_FALSE(utf8IsAlpha(FudUtf8{Ascii{invalidAscii}})); + ASSERT_FALSE(isAlpha(FudUtf8{Ascii{invalidAscii}})); SpanGenerator alphaGenerator{alphaChars.span()}; auto utf8AlphaGenerator = [&]() { return alphaGenerator().map(toUtf8); }; - ASSERT_TRUE(allOf(utf8AlphaGenerator, utf8IsAlpha)); + ASSERT_TRUE(allOf(utf8AlphaGenerator, static_cast(isAlpha))); SpanGenerator nonAlphaGenerator{nonAlphaChars.span().takeOkay()}; auto utf8NonAlphaGenerator = [&]() { return nonAlphaGenerator().map(toUtf8); }; - ASSERT_FALSE(anyOf(utf8NonAlphaGenerator, utf8IsAlpha)); + ASSERT_FALSE(anyOf(utf8NonAlphaGenerator, static_cast(isAlpha))); } TEST(Utf8Test, Utf8IsLower) @@ -311,29 +340,29 @@ TEST(Utf8Test, Utf8IsLower) Array lowerChars{}; copyMem(lowerChars, lowerCharLiteral); - ASSERT_TRUE(allOf(lowerChars.span(), charIsLowercase)); + ASSERT_TRUE(allOf(lowerChars.span(), static_cast(isLowercase))); constexpr size_t numNonLowerChars = validAsciiSize - numLowerChars; Vector nonLowerChars{}; for (char idx = 0; idx < INT8_MAX; ++idx) { - if (!charIsLowercase(idx)) { + if (!isLowercase(idx)) { ASSERT_EQ(nonLowerChars.pushBack(idx), FudStatus::Success); } } - ASSERT_FALSE(anyOf(nonLowerChars.span().takeOkay(), charIsLowercase)); + ASSERT_FALSE(anyOf(nonLowerChars.span().takeOkay(), static_cast(isLowercase))); auto invalidAsciiChars = invalidAsciiGenerator(); - ASSERT_FALSE(anyOf(invalidAsciiChars, charIsLowercase)); + ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast(isLowercase))); - ASSERT_FALSE(utf8IsLowercase(FudUtf8{Ascii{invalidAscii}})); + ASSERT_FALSE(isLowercase(FudUtf8{Ascii{invalidAscii}})); SpanGenerator lowerGenerator{lowerChars.span()}; auto utf8LowerGenerator = [&]() { return lowerGenerator().map(toUtf8); }; - ASSERT_TRUE(allOf(utf8LowerGenerator, utf8IsLowercase)); + ASSERT_TRUE(allOf(utf8LowerGenerator, static_cast(isLowercase))); SpanGenerator nonLowerGenerator{nonLowerChars.span().takeOkay()}; auto utf8NonLowerGenerator = [&]() { return nonLowerGenerator().map(toUtf8); }; - ASSERT_FALSE(anyOf(utf8NonLowerGenerator, utf8IsLowercase)); + ASSERT_FALSE(anyOf(utf8NonLowerGenerator, static_cast(isLowercase))); } TEST(Utf8Test, Utf8IsUpper) @@ -343,29 +372,29 @@ TEST(Utf8Test, Utf8IsUpper) Array upperChars{}; copyMem(upperChars, upperCharLiteral); - ASSERT_TRUE(allOf(upperChars.span(), charIsUppercase)); + ASSERT_TRUE(allOf(upperChars.span(), static_cast(isUppercase))); constexpr size_t numNonUpperChars = validAsciiSize - numUpperChars; Vector nonUpperChars{}; for (char idx = 0; idx < INT8_MAX; ++idx) { - if (!charIsUppercase(idx)) { + if (!isUppercase(idx)) { ASSERT_EQ(nonUpperChars.pushBack(idx), FudStatus::Success); } } - ASSERT_FALSE(anyOf(nonUpperChars.span().takeOkay(), charIsUppercase)); + ASSERT_FALSE(anyOf(nonUpperChars.span().takeOkay(), static_cast(isUppercase))); auto invalidAsciiChars = invalidAsciiGenerator(); - ASSERT_FALSE(anyOf(invalidAsciiChars, charIsUppercase)); + ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast(isUppercase))); - ASSERT_FALSE(utf8IsUppercase(FudUtf8{Ascii{invalidAscii}})); + ASSERT_FALSE(isUppercase(FudUtf8{Ascii{invalidAscii}})); SpanGenerator upperGenerator{upperChars.span()}; auto utf8UpperGenerator = [&]() { return upperGenerator().map(toUtf8); }; - ASSERT_TRUE(allOf(utf8UpperGenerator, utf8IsUppercase)); + ASSERT_TRUE(allOf(utf8UpperGenerator, static_cast(isUppercase))); SpanGenerator nonUpperGenerator{nonUpperChars.span().takeOkay()}; auto utf8NonUpperGenerator = [&]() { return nonUpperGenerator().map(toUtf8); }; - ASSERT_FALSE(anyOf(utf8NonUpperGenerator, utf8IsUppercase)); + ASSERT_FALSE(anyOf(utf8NonUpperGenerator, static_cast(isUppercase))); } TEST(Utf8Test, Utf8IsDigit) @@ -375,29 +404,29 @@ TEST(Utf8Test, Utf8IsDigit) Array digitChars{}; copyMem(digitChars, digitCharLiteral); - ASSERT_TRUE(allOf(digitChars.span(), charIsDigit)); + ASSERT_TRUE(allOf(digitChars.span(), static_cast(isDigit))); constexpr size_t numNonDigitChars = validAsciiSize - numDigitChars; Vector nonDigitChars{}; for (char idx = 0; idx < INT8_MAX; ++idx) { - if (!charIsDigit(idx)) { + if (!isDigit(idx)) { ASSERT_EQ(nonDigitChars.pushBack(idx), FudStatus::Success); } } - ASSERT_FALSE(anyOf(nonDigitChars.span().takeOkay(), charIsDigit)); + ASSERT_FALSE(anyOf(nonDigitChars.span().takeOkay(), static_cast(isDigit))); auto invalidAsciiChars = invalidAsciiGenerator(); - ASSERT_FALSE(anyOf(invalidAsciiChars, charIsDigit)); + ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast(isDigit))); - ASSERT_FALSE(utf8IsDigit(FudUtf8{Ascii{invalidAscii}})); + ASSERT_FALSE(isDigit(FudUtf8{Ascii{invalidAscii}})); SpanGenerator digitGenerator{digitChars.span()}; auto utf8DigitGenerator = [&]() { return digitGenerator().map(toUtf8); }; - ASSERT_TRUE(allOf(utf8DigitGenerator, utf8IsDigit)); + ASSERT_TRUE(allOf(utf8DigitGenerator, static_cast(isDigit))); SpanGenerator nonDigitGenerator{nonDigitChars.span().takeOkay()}; auto utf8NonDigitGenerator = [&]() { return nonDigitGenerator().map(toUtf8); }; - ASSERT_FALSE(anyOf(utf8NonDigitGenerator, utf8IsDigit)); + ASSERT_FALSE(anyOf(utf8NonDigitGenerator, static_cast(isDigit))); } TEST(Utf8Test, Utf8IsHexDigit) @@ -407,29 +436,29 @@ TEST(Utf8Test, Utf8IsHexDigit) Array hexDigitChars{}; copyMem(hexDigitChars, hexDigitCharLiteral); - ASSERT_TRUE(allOf(hexDigitChars.span(), charIsHexDigit)); + ASSERT_TRUE(allOf(hexDigitChars.span(), static_cast(isHexDigit))); constexpr size_t numNonHexDigitChars = validAsciiSize - numHexDigitChars; Vector nonHexDigitChars{}; for (char idx = 0; idx < INT8_MAX; ++idx) { - if (!charIsHexDigit(idx)) { + if (!isHexDigit(idx)) { ASSERT_EQ(nonHexDigitChars.pushBack(idx), FudStatus::Success); } } - ASSERT_FALSE(anyOf(nonHexDigitChars.span().takeOkay(), charIsHexDigit)); + ASSERT_FALSE(anyOf(nonHexDigitChars.span().takeOkay(), static_cast(isHexDigit))); auto invalidAsciiChars = invalidAsciiGenerator(); - ASSERT_FALSE(anyOf(invalidAsciiChars, charIsHexDigit)); + ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast(isHexDigit))); - ASSERT_FALSE(utf8IsHexDigit(FudUtf8{Ascii{invalidAscii}})); + ASSERT_FALSE(isHexDigit(FudUtf8{Ascii{invalidAscii}})); SpanGenerator hexDigitGenerator{hexDigitChars.span()}; auto utf8HexDigitGenerator = [&]() { return hexDigitGenerator().map(toUtf8); }; - ASSERT_TRUE(allOf(utf8HexDigitGenerator, utf8IsHexDigit)); + ASSERT_TRUE(allOf(utf8HexDigitGenerator, static_cast(isHexDigit))); SpanGenerator nonHexDigitGenerator{nonHexDigitChars.span().takeOkay()}; auto utf8NonHexDigitGenerator = [&]() { return nonHexDigitGenerator().map(toUtf8); }; - ASSERT_FALSE(anyOf(utf8NonHexDigitGenerator, utf8IsHexDigit)); + ASSERT_FALSE(anyOf(utf8NonHexDigitGenerator, static_cast(isHexDigit))); } TEST(Utf8Test, Utf8IsControl) @@ -439,7 +468,7 @@ TEST(Utf8Test, Utf8IsControl) constexpr const char deleteChar = 0x7F; controlChars.back() = deleteChar; - ASSERT_TRUE(allOf(controlChars.span(), charIsControl)); + ASSERT_TRUE(allOf(controlChars.span(), static_cast(isControl))); constexpr size_t numNonControlChars = INT8_MAX + 1 - numControlChars; Vector nonControlChars{}; @@ -447,21 +476,21 @@ TEST(Utf8Test, Utf8IsControl) for (auto idx = numControlChars - 1; idx < deleteChar; ++idx) { ASSERT_EQ(nonControlChars.pushBack(idx), FudStatus::Success); } - ASSERT_FALSE(anyOf(nonControlChars.span().takeOkay(), charIsControl)); - ASSERT_TRUE(allOf(nonControlChars.span().takeOkay(), charIsAscii)); + ASSERT_FALSE(anyOf(nonControlChars.span().takeOkay(), static_cast(isControl))); + ASSERT_TRUE(allOf(nonControlChars.span().takeOkay(), static_cast(isAscii))); auto invalidAsciiChars = invalidAsciiGenerator(); - ASSERT_FALSE(anyOf(invalidAsciiChars, charIsControl)); + ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast(isControl))); - ASSERT_FALSE(utf8IsControl(FudUtf8{Ascii{invalidAscii}})); + ASSERT_FALSE(isControl(FudUtf8{Ascii{invalidAscii}})); SpanGenerator controlGenerator{controlChars.span()}; auto utf8ControlGenerator = [&]() { return controlGenerator().map(toUtf8); }; - ASSERT_TRUE(allOf(utf8ControlGenerator, utf8IsControl)); + ASSERT_TRUE(allOf(utf8ControlGenerator, static_cast(isControl))); SpanGenerator nonControlGenerator{nonControlChars.span().takeOkay()}; auto utf8NonControlGenerator = [&]() { return nonControlGenerator().map(toUtf8); }; - ASSERT_FALSE(anyOf(utf8NonControlGenerator, utf8IsControl)); + ASSERT_FALSE(anyOf(utf8NonControlGenerator, static_cast(isControl))); } TEST(Utf8Test, Utf8IsGraphical) @@ -471,32 +500,32 @@ TEST(Utf8Test, Utf8IsGraphical) Array graphicalChars{}; copyMem(graphicalChars, graphicalCharLiteral); - ASSERT_TRUE(allOf(graphicalChars.span(), charIsGraphical)); + ASSERT_TRUE(allOf(graphicalChars.span(), static_cast(isGraphical))); constexpr size_t numNonGraphicalChars = validAsciiSize - numGraphicalChars; Vector nonGraphicalChars{}; ASSERT_EQ(nonGraphicalChars.reserve(numNonGraphicalChars), FudStatus::Success); for (uint8_t idx = 0; idx < INT8_MAX + 1; ++idx) { - if (!charIsGraphical(static_cast(idx))) { + if (!isGraphical(static_cast(idx))) { ASSERT_EQ(nonGraphicalChars.pushBack(static_cast(idx)), FudStatus::Success); } } - ASSERT_FALSE(anyOf(nonGraphicalChars.span().takeOkay(), charIsGraphical)); - ASSERT_TRUE(allOf(nonGraphicalChars.span().takeOkay(), charIsAscii)); + ASSERT_FALSE(anyOf(nonGraphicalChars.span().takeOkay(), static_cast(isGraphical))); + ASSERT_TRUE(allOf(nonGraphicalChars.span().takeOkay(), static_cast(isAscii))); ASSERT_EQ(nonGraphicalChars.size() + graphicalChars.size(), INT8_MAX + 1); auto invalidAsciiChars = invalidAsciiGenerator(); - ASSERT_FALSE(anyOf(invalidAsciiChars, charIsGraphical)); + ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast(isGraphical))); - ASSERT_FALSE(utf8IsGraphical(FudUtf8{Ascii{invalidAscii}})); + ASSERT_FALSE(isGraphical(FudUtf8{Ascii{invalidAscii}})); SpanGenerator graphicalGenerator{graphicalChars.span()}; auto utf8GraphicalGenerator = [&]() { return graphicalGenerator().map(toUtf8); }; - ASSERT_TRUE(allOf(utf8GraphicalGenerator, utf8IsGraphical)); + ASSERT_TRUE(allOf(utf8GraphicalGenerator, static_cast(isGraphical))); SpanGenerator nonGraphicalGenerator{nonGraphicalChars.span().takeOkay()}; auto utf8NonGraphicalGenerator = [&]() { return nonGraphicalGenerator().map(toUtf8); }; - ASSERT_FALSE(anyOf(utf8NonGraphicalGenerator, utf8IsGraphical)); + ASSERT_FALSE(anyOf(utf8NonGraphicalGenerator, static_cast(isGraphical))); } TEST(Utf8Test, Utf8IsSpace) @@ -506,32 +535,32 @@ TEST(Utf8Test, Utf8IsSpace) Array spaceChars{}; copyMem(spaceChars, spaceCharLiteral); - ASSERT_TRUE(allOf(spaceChars.span(), charIsSpace)); + ASSERT_TRUE(allOf(spaceChars.span(), static_cast(isSpace))); constexpr size_t numNonSpaceChars = validAsciiSize - numSpaceChars; Vector nonSpaceChars{}; ASSERT_EQ(nonSpaceChars.reserve(numNonSpaceChars), FudStatus::Success); for (uint8_t idx = 0; idx < INT8_MAX + 1; ++idx) { - if (!charIsSpace(static_cast(idx))) { + if (!isSpace(static_cast(idx))) { ASSERT_EQ(nonSpaceChars.pushBack(static_cast(idx)), FudStatus::Success); } } - ASSERT_FALSE(anyOf(nonSpaceChars.span().takeOkay(), charIsSpace)); - ASSERT_TRUE(allOf(nonSpaceChars.span().takeOkay(), charIsAscii)); + ASSERT_FALSE(anyOf(nonSpaceChars.span().takeOkay(), static_cast(isSpace))); + ASSERT_TRUE(allOf(nonSpaceChars.span().takeOkay(), static_cast(isAscii))); ASSERT_EQ(nonSpaceChars.size() + spaceChars.size(), INT8_MAX + 1); auto invalidAsciiChars = invalidAsciiGenerator(); - ASSERT_FALSE(anyOf(invalidAsciiChars, charIsSpace)); + ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast(isSpace))); - ASSERT_FALSE(utf8IsSpace(FudUtf8{Ascii{invalidAscii}})); + ASSERT_FALSE(isSpace(FudUtf8{Ascii{invalidAscii}})); SpanGenerator spaceGenerator{spaceChars.span()}; auto utf8SpaceGenerator = [&]() { return spaceGenerator().map(toUtf8); }; - ASSERT_TRUE(allOf(utf8SpaceGenerator, utf8IsSpace)); + ASSERT_TRUE(allOf(utf8SpaceGenerator, static_cast(isSpace))); SpanGenerator nonSpaceGenerator{nonSpaceChars.span().takeOkay()}; auto utf8NonSpaceGenerator = [&]() { return nonSpaceGenerator().map(toUtf8); }; - ASSERT_FALSE(anyOf(utf8NonSpaceGenerator, utf8IsSpace)); + ASSERT_FALSE(anyOf(utf8NonSpaceGenerator, static_cast(isSpace))); } TEST(Utf8Test, Utf8IsBlank) @@ -541,32 +570,32 @@ TEST(Utf8Test, Utf8IsBlank) Array blankChars{}; copyMem(blankChars, blankCharLiteral); - ASSERT_TRUE(allOf(blankChars.span(), charIsBlank)); + ASSERT_TRUE(allOf(blankChars.span(), static_cast(isBlank))); constexpr size_t numNonBlankChars = validAsciiSize - numBlankChars; Vector nonBlankChars{}; ASSERT_EQ(nonBlankChars.reserve(numNonBlankChars), FudStatus::Success); for (uint8_t idx = 0; idx < INT8_MAX + 1; ++idx) { - if (!charIsBlank(static_cast(idx))) { + if (!isBlank(static_cast(idx))) { ASSERT_EQ(nonBlankChars.pushBack(static_cast(idx)), FudStatus::Success); } } - ASSERT_FALSE(anyOf(nonBlankChars.span().takeOkay(), charIsBlank)); - ASSERT_TRUE(allOf(nonBlankChars.span().takeOkay(), charIsAscii)); + ASSERT_FALSE(anyOf(nonBlankChars.span().takeOkay(), static_cast(isBlank))); + ASSERT_TRUE(allOf(nonBlankChars.span().takeOkay(), static_cast(isAscii))); ASSERT_EQ(nonBlankChars.size() + blankChars.size(), INT8_MAX + 1); auto invalidAsciiChars = invalidAsciiGenerator(); - ASSERT_FALSE(anyOf(invalidAsciiChars, charIsBlank)); + ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast(isBlank))); - ASSERT_FALSE(utf8IsBlank(FudUtf8{Ascii{invalidAscii}})); + ASSERT_FALSE(isBlank(FudUtf8{Ascii{invalidAscii}})); SpanGenerator blankGenerator{blankChars.span()}; auto utf8BlankGenerator = [&]() { return blankGenerator().map(toUtf8); }; - ASSERT_TRUE(allOf(utf8BlankGenerator, utf8IsBlank)); + ASSERT_TRUE(allOf(utf8BlankGenerator, static_cast(isBlank))); SpanGenerator nonBlankGenerator{nonBlankChars.span().takeOkay()}; auto utf8NonBlankGenerator = [&]() { return nonBlankGenerator().map(toUtf8); }; - ASSERT_FALSE(anyOf(utf8NonBlankGenerator, utf8IsBlank)); + ASSERT_FALSE(anyOf(utf8NonBlankGenerator, static_cast(isBlank))); } TEST(Utf8Test, Utf8IsPrintable) @@ -576,32 +605,32 @@ TEST(Utf8Test, Utf8IsPrintable) Array printableChars{}; copyMem(printableChars, printableCharLiteral); - ASSERT_TRUE(allOf(printableChars.span(), charIsPrintable)); + ASSERT_TRUE(allOf(printableChars.span(), static_cast(isPrintable))); constexpr size_t numNonPrintableChars = validAsciiSize - numPrintableChars; Vector nonPrintableChars{}; ASSERT_EQ(nonPrintableChars.reserve(numNonPrintableChars), FudStatus::Success); for (uint8_t idx = 0; idx < INT8_MAX + 1; ++idx) { - if (!charIsPrintable(static_cast(idx))) { + if (!isPrintable(static_cast(idx))) { ASSERT_EQ(nonPrintableChars.pushBack(static_cast(idx)), FudStatus::Success); } } - ASSERT_FALSE(anyOf(nonPrintableChars.span().takeOkay(), charIsPrintable)); - ASSERT_TRUE(allOf(nonPrintableChars.span().takeOkay(), charIsAscii)); + ASSERT_FALSE(anyOf(nonPrintableChars.span().takeOkay(), static_cast(isPrintable))); + ASSERT_TRUE(allOf(nonPrintableChars.span().takeOkay(), static_cast(isAscii))); ASSERT_EQ(nonPrintableChars.size() + printableChars.size(), INT8_MAX + 1); auto invalidAsciiChars = invalidAsciiGenerator(); - ASSERT_FALSE(anyOf(invalidAsciiChars, charIsPrintable)); + ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast(isPrintable))); - ASSERT_FALSE(utf8IsPrintable(FudUtf8{Ascii{invalidAscii}})); + ASSERT_FALSE(isPrintable(FudUtf8{Ascii{invalidAscii}})); SpanGenerator printableGenerator{printableChars.span()}; auto utf8PrintableGenerator = [&]() { return printableGenerator().map(toUtf8); }; - ASSERT_TRUE(allOf(utf8PrintableGenerator, utf8IsPrintable)); + ASSERT_TRUE(allOf(utf8PrintableGenerator, static_cast(isPrintable))); SpanGenerator nonPrintableGenerator{nonPrintableChars.span().takeOkay()}; auto utf8NonPrintableGenerator = [&]() { return nonPrintableGenerator().map(toUtf8); }; - ASSERT_FALSE(anyOf(utf8NonPrintableGenerator, utf8IsPrintable)); + ASSERT_FALSE(anyOf(utf8NonPrintableGenerator, static_cast(isPrintable))); } TEST(Utf8Test, Utf8IsPunctuation) @@ -611,32 +640,32 @@ TEST(Utf8Test, Utf8IsPunctuation) Array punctuationChars{}; copyMem(punctuationChars, punctuationCharLiteral); - ASSERT_TRUE(allOf(punctuationChars.span(), charIsPunctuation)); + ASSERT_TRUE(allOf(punctuationChars.span(), static_cast(isPunctuation))); constexpr size_t numNonPunctuationChars = validAsciiSize - numPunctuationChars; Vector nonPunctuationChars{}; ASSERT_EQ(nonPunctuationChars.reserve(numNonPunctuationChars), FudStatus::Success); for (uint8_t idx = 0; idx < INT8_MAX + 1; ++idx) { - if (!charIsPunctuation(static_cast(idx))) { + if (!isPunctuation(static_cast(idx))) { ASSERT_EQ(nonPunctuationChars.pushBack(static_cast(idx)), FudStatus::Success); } } - ASSERT_FALSE(anyOf(nonPunctuationChars.span().takeOkay(), charIsPunctuation)); - ASSERT_TRUE(allOf(nonPunctuationChars.span().takeOkay(), charIsAscii)); + ASSERT_FALSE(anyOf(nonPunctuationChars.span().takeOkay(), static_cast(isPunctuation))); + ASSERT_TRUE(allOf(nonPunctuationChars.span().takeOkay(), static_cast(isAscii))); ASSERT_EQ(nonPunctuationChars.size() + punctuationChars.size(), INT8_MAX + 1); auto invalidAsciiChars = invalidAsciiGenerator(); - ASSERT_FALSE(anyOf(invalidAsciiChars, charIsPunctuation)); + ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast(isPunctuation))); - ASSERT_FALSE(utf8IsPunctuation(FudUtf8{Ascii{invalidAscii}})); + ASSERT_FALSE(isPunctuation(FudUtf8{Ascii{invalidAscii}})); SpanGenerator punctuationGenerator{punctuationChars.span()}; auto utf8PunctuationGenerator = [&]() { return punctuationGenerator().map(toUtf8); }; - ASSERT_TRUE(allOf(utf8PunctuationGenerator, utf8IsPunctuation)); + ASSERT_TRUE(allOf(utf8PunctuationGenerator, static_cast(isPunctuation))); SpanGenerator nonPunctuationGenerator{nonPunctuationChars.span().takeOkay()}; auto utf8NonPunctuationGenerator = [&]() { return nonPunctuationGenerator().map(toUtf8); }; - ASSERT_FALSE(anyOf(utf8NonPunctuationGenerator, utf8IsPunctuation)); + ASSERT_FALSE(anyOf(utf8NonPunctuationGenerator, static_cast(isPunctuation))); } } // namespace fud -- cgit v1.2.3