summaryrefslogtreecommitdiff
path: root/test/test_utf8.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_utf8.cpp')
-rw-r--r--test/test_utf8.cpp219
1 files changed, 124 insertions, 95 deletions
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<int16_t> charIota{0, 1, validAsciiSize};
- ASSERT_TRUE(allOf([&]() -> Option<char> { return charIota().map(toLetter<int16_t>); }, charIsAscii));
+ ASSERT_TRUE(allOf([&]() -> Option<char> { return charIota().map(toLetter<int16_t>); }, static_cast<CharPredicate>(isAscii)));
Iota<int16_t> invalidCharIota{validAsciiSize, 1, invalidAsciiSize};
- ASSERT_FALSE(anyOf([&]() -> Option<char> { return invalidCharIota().map(toLetter<int16_t>); }, charIsAscii));
+ ASSERT_FALSE(anyOf([&]() -> Option<char> { return invalidCharIota().map(toLetter<int16_t>); }, static_cast<CharPredicate>(isAscii)));
FudUtf8 unicode{FudUtf8::invalidAscii()};
- ASSERT_FALSE(utf8IsAscii(unicode));
+ ASSERT_FALSE(isAscii(unicode));
charIota.set(0);
- ASSERT_TRUE(allOf([&]() -> Option<FudUtf8> { return charIota().map(toUtf8<int16_t>); }, utf8IsAscii));
+ ASSERT_TRUE(allOf([&]() -> Option<FudUtf8> { return charIota().map(toUtf8<int16_t>); }, static_cast<FudUtf8Predicate>(isAscii)));
invalidCharIota.set(invalidAsciiSize);
- ASSERT_FALSE(anyOf([&]() -> Option<FudUtf8> { return invalidCharIota().map(toUtf8<int16_t>); }, utf8IsAscii));
+ ASSERT_FALSE(anyOf([&]() -> Option<FudUtf8> { return invalidCharIota().map(toUtf8<int16_t>); }, static_cast<FudUtf8Predicate>(isAscii)));
}
template <typename T, size_t Size = SIZE_MAX>
@@ -241,22 +270,22 @@ TEST(Utf8Test, Utf8IsAlphanumeric)
Array<char, numAlphanumericChars> alphanumericChars{};
copyMem<numAlphanumericChars>(alphanumericChars, alphanumericCharLiteral);
- ASSERT_TRUE(allOf(alphanumericChars.span(), charIsAlphanumeric));
+ ASSERT_TRUE(allOf(alphanumericChars.span(), static_cast<CharPredicate>(isAlphanumeric)));
constexpr size_t numNonAlphanumericChars = validAsciiSize - numAlphanumericChars;
Vector<char> 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<CharPredicate>(isAlphanumeric)));
auto invalidAsciiChars = invalidAsciiGenerator();
- ASSERT_FALSE(anyOf(invalidAsciiChars, charIsAlphanumeric));
+ ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast<CharPredicate>(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<char, alphanumericChars.size()> alphanumericGenerator{alphanumericChars.span()};
auto utf8AlphanumericGenerator = [&]() { return alphanumericGenerator().map(toUtf8<uint16_t>); };
- ASSERT_TRUE(allOf(utf8AlphanumericGenerator, utf8IsAlphanumeric));
+ ASSERT_TRUE(allOf(utf8AlphanumericGenerator, static_cast<FudUtf8Predicate>(isAlphanumeric)));
SpanGenerator<char> nonAlphanumericGenerator{nonAlphanumericChars.span().takeOkay()};
auto utf8NonAlphanumericGenerator = [&]() { return nonAlphanumericGenerator().map(toUtf8<uint16_t>); };
- ASSERT_FALSE(anyOf(utf8NonAlphanumericGenerator, utf8IsAlphanumeric));
+ ASSERT_FALSE(anyOf(utf8NonAlphanumericGenerator, static_cast<FudUtf8Predicate>(isAlphanumeric)));
}
TEST(Utf8Test, Utf8IsAlpha)
@@ -279,29 +308,29 @@ TEST(Utf8Test, Utf8IsAlpha)
Array<char, numAlphaChars> alphaChars{};
copyMem<numAlphaChars>(alphaChars, alphaCharLiteral);
- ASSERT_TRUE(allOf(alphaChars.span(), charIsAlpha));
+ ASSERT_TRUE(allOf(alphaChars.span(), static_cast<CharPredicate>(isAlpha)));
constexpr size_t numNonAlphanumericChars = validAsciiSize - numAlphaChars;
Vector<char> 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<CharPredicate>(isAlpha)));
auto invalidAsciiChars = invalidAsciiGenerator();
- ASSERT_FALSE(anyOf(invalidAsciiChars, charIsAlpha));
+ ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast<CharPredicate>(isAlpha)));
- ASSERT_FALSE(utf8IsAlpha(FudUtf8{Ascii{invalidAscii}}));
+ ASSERT_FALSE(isAlpha(FudUtf8{Ascii{invalidAscii}}));
SpanGenerator<char, alphaChars.size()> alphaGenerator{alphaChars.span()};
auto utf8AlphaGenerator = [&]() { return alphaGenerator().map(toUtf8<uint16_t>); };
- ASSERT_TRUE(allOf(utf8AlphaGenerator, utf8IsAlpha));
+ ASSERT_TRUE(allOf(utf8AlphaGenerator, static_cast<FudUtf8Predicate>(isAlpha)));
SpanGenerator<char> nonAlphaGenerator{nonAlphaChars.span().takeOkay()};
auto utf8NonAlphaGenerator = [&]() { return nonAlphaGenerator().map(toUtf8<uint16_t>); };
- ASSERT_FALSE(anyOf(utf8NonAlphaGenerator, utf8IsAlpha));
+ ASSERT_FALSE(anyOf(utf8NonAlphaGenerator, static_cast<FudUtf8Predicate>(isAlpha)));
}
TEST(Utf8Test, Utf8IsLower)
@@ -311,29 +340,29 @@ TEST(Utf8Test, Utf8IsLower)
Array<char, numLowerChars> lowerChars{};
copyMem<numLowerChars>(lowerChars, lowerCharLiteral);
- ASSERT_TRUE(allOf(lowerChars.span(), charIsLowercase));
+ ASSERT_TRUE(allOf(lowerChars.span(), static_cast<CharPredicate>(isLowercase)));
constexpr size_t numNonLowerChars = validAsciiSize - numLowerChars;
Vector<char> 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<CharPredicate>(isLowercase)));
auto invalidAsciiChars = invalidAsciiGenerator();
- ASSERT_FALSE(anyOf(invalidAsciiChars, charIsLowercase));
+ ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast<CharPredicate>(isLowercase)));
- ASSERT_FALSE(utf8IsLowercase(FudUtf8{Ascii{invalidAscii}}));
+ ASSERT_FALSE(isLowercase(FudUtf8{Ascii{invalidAscii}}));
SpanGenerator<char, lowerChars.size()> lowerGenerator{lowerChars.span()};
auto utf8LowerGenerator = [&]() { return lowerGenerator().map(toUtf8<uint16_t>); };
- ASSERT_TRUE(allOf(utf8LowerGenerator, utf8IsLowercase));
+ ASSERT_TRUE(allOf(utf8LowerGenerator, static_cast<FudUtf8Predicate>(isLowercase)));
SpanGenerator<char> nonLowerGenerator{nonLowerChars.span().takeOkay()};
auto utf8NonLowerGenerator = [&]() { return nonLowerGenerator().map(toUtf8<uint16_t>); };
- ASSERT_FALSE(anyOf(utf8NonLowerGenerator, utf8IsLowercase));
+ ASSERT_FALSE(anyOf(utf8NonLowerGenerator, static_cast<FudUtf8Predicate>(isLowercase)));
}
TEST(Utf8Test, Utf8IsUpper)
@@ -343,29 +372,29 @@ TEST(Utf8Test, Utf8IsUpper)
Array<char, numUpperChars> upperChars{};
copyMem<numUpperChars>(upperChars, upperCharLiteral);
- ASSERT_TRUE(allOf(upperChars.span(), charIsUppercase));
+ 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) {
- 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<CharPredicate>(isUppercase)));
auto invalidAsciiChars = invalidAsciiGenerator();
- ASSERT_FALSE(anyOf(invalidAsciiChars, charIsUppercase));
+ ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast<CharPredicate>(isUppercase)));
- ASSERT_FALSE(utf8IsUppercase(FudUtf8{Ascii{invalidAscii}}));
+ ASSERT_FALSE(isUppercase(FudUtf8{Ascii{invalidAscii}}));
SpanGenerator<char, upperChars.size()> upperGenerator{upperChars.span()};
auto utf8UpperGenerator = [&]() { return upperGenerator().map(toUtf8<uint16_t>); };
- ASSERT_TRUE(allOf(utf8UpperGenerator, utf8IsUppercase));
+ ASSERT_TRUE(allOf(utf8UpperGenerator, static_cast<FudUtf8Predicate>(isUppercase)));
SpanGenerator<char> nonUpperGenerator{nonUpperChars.span().takeOkay()};
auto utf8NonUpperGenerator = [&]() { return nonUpperGenerator().map(toUtf8<uint16_t>); };
- ASSERT_FALSE(anyOf(utf8NonUpperGenerator, utf8IsUppercase));
+ ASSERT_FALSE(anyOf(utf8NonUpperGenerator, static_cast<FudUtf8Predicate>(isUppercase)));
}
TEST(Utf8Test, Utf8IsDigit)
@@ -375,29 +404,29 @@ TEST(Utf8Test, Utf8IsDigit)
Array<char, numDigitChars> digitChars{};
copyMem<numDigitChars>(digitChars, digitCharLiteral);
- ASSERT_TRUE(allOf(digitChars.span(), charIsDigit));
+ ASSERT_TRUE(allOf(digitChars.span(), static_cast<CharPredicate>(isDigit)));
constexpr size_t numNonDigitChars = validAsciiSize - numDigitChars;
Vector<char> 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<CharPredicate>(isDigit)));
auto invalidAsciiChars = invalidAsciiGenerator();
- ASSERT_FALSE(anyOf(invalidAsciiChars, charIsDigit));
+ ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast<CharPredicate>(isDigit)));
- ASSERT_FALSE(utf8IsDigit(FudUtf8{Ascii{invalidAscii}}));
+ ASSERT_FALSE(isDigit(FudUtf8{Ascii{invalidAscii}}));
SpanGenerator<char, digitChars.size()> digitGenerator{digitChars.span()};
auto utf8DigitGenerator = [&]() { return digitGenerator().map(toUtf8<uint16_t>); };
- ASSERT_TRUE(allOf(utf8DigitGenerator, utf8IsDigit));
+ ASSERT_TRUE(allOf(utf8DigitGenerator, static_cast<FudUtf8Predicate>(isDigit)));
SpanGenerator<char> nonDigitGenerator{nonDigitChars.span().takeOkay()};
auto utf8NonDigitGenerator = [&]() { return nonDigitGenerator().map(toUtf8<uint16_t>); };
- ASSERT_FALSE(anyOf(utf8NonDigitGenerator, utf8IsDigit));
+ ASSERT_FALSE(anyOf(utf8NonDigitGenerator, static_cast<FudUtf8Predicate>(isDigit)));
}
TEST(Utf8Test, Utf8IsHexDigit)
@@ -407,29 +436,29 @@ TEST(Utf8Test, Utf8IsHexDigit)
Array<char, numHexDigitChars> hexDigitChars{};
copyMem<numHexDigitChars>(hexDigitChars, hexDigitCharLiteral);
- ASSERT_TRUE(allOf(hexDigitChars.span(), charIsHexDigit));
+ ASSERT_TRUE(allOf(hexDigitChars.span(), static_cast<CharPredicate>(isHexDigit)));
constexpr size_t numNonHexDigitChars = validAsciiSize - numHexDigitChars;
Vector<char> 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<CharPredicate>(isHexDigit)));
auto invalidAsciiChars = invalidAsciiGenerator();
- ASSERT_FALSE(anyOf(invalidAsciiChars, charIsHexDigit));
+ ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast<CharPredicate>(isHexDigit)));
- ASSERT_FALSE(utf8IsHexDigit(FudUtf8{Ascii{invalidAscii}}));
+ ASSERT_FALSE(isHexDigit(FudUtf8{Ascii{invalidAscii}}));
SpanGenerator<char, hexDigitChars.size()> hexDigitGenerator{hexDigitChars.span()};
auto utf8HexDigitGenerator = [&]() { return hexDigitGenerator().map(toUtf8<uint16_t>); };
- ASSERT_TRUE(allOf(utf8HexDigitGenerator, utf8IsHexDigit));
+ ASSERT_TRUE(allOf(utf8HexDigitGenerator, static_cast<FudUtf8Predicate>(isHexDigit)));
SpanGenerator<char> nonHexDigitGenerator{nonHexDigitChars.span().takeOkay()};
auto utf8NonHexDigitGenerator = [&]() { return nonHexDigitGenerator().map(toUtf8<uint16_t>); };
- ASSERT_FALSE(anyOf(utf8NonHexDigitGenerator, utf8IsHexDigit));
+ ASSERT_FALSE(anyOf(utf8NonHexDigitGenerator, static_cast<FudUtf8Predicate>(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<CharPredicate>(isControl)));
constexpr size_t numNonControlChars = INT8_MAX + 1 - numControlChars;
Vector<char> 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<CharPredicate>(isControl)));
+ ASSERT_TRUE(allOf(nonControlChars.span().takeOkay(), static_cast<CharPredicate>(isAscii)));
auto invalidAsciiChars = invalidAsciiGenerator();
- ASSERT_FALSE(anyOf(invalidAsciiChars, charIsControl));
+ ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast<CharPredicate>(isControl)));
- ASSERT_FALSE(utf8IsControl(FudUtf8{Ascii{invalidAscii}}));
+ ASSERT_FALSE(isControl(FudUtf8{Ascii{invalidAscii}}));
SpanGenerator<char, controlChars.size()> controlGenerator{controlChars.span()};
auto utf8ControlGenerator = [&]() { return controlGenerator().map(toUtf8<uint16_t>); };
- ASSERT_TRUE(allOf(utf8ControlGenerator, utf8IsControl));
+ ASSERT_TRUE(allOf(utf8ControlGenerator, static_cast<FudUtf8Predicate>(isControl)));
SpanGenerator<char> nonControlGenerator{nonControlChars.span().takeOkay()};
auto utf8NonControlGenerator = [&]() { return nonControlGenerator().map(toUtf8<uint16_t>); };
- ASSERT_FALSE(anyOf(utf8NonControlGenerator, utf8IsControl));
+ ASSERT_FALSE(anyOf(utf8NonControlGenerator, static_cast<FudUtf8Predicate>(isControl)));
}
TEST(Utf8Test, Utf8IsGraphical)
@@ -471,32 +500,32 @@ TEST(Utf8Test, Utf8IsGraphical)
Array<char, numGraphicalChars> graphicalChars{};
copyMem<numGraphicalChars>(graphicalChars, graphicalCharLiteral);
- ASSERT_TRUE(allOf(graphicalChars.span(), charIsGraphical));
+ ASSERT_TRUE(allOf(graphicalChars.span(), static_cast<CharPredicate>(isGraphical)));
constexpr size_t numNonGraphicalChars = validAsciiSize - numGraphicalChars;
Vector<char> nonGraphicalChars{};
ASSERT_EQ(nonGraphicalChars.reserve(numNonGraphicalChars), FudStatus::Success);
for (uint8_t idx = 0; idx < INT8_MAX + 1; ++idx) {
- if (!charIsGraphical(static_cast<char>(idx))) {
+ if (!isGraphical(static_cast<char>(idx))) {
ASSERT_EQ(nonGraphicalChars.pushBack(static_cast<char>(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<CharPredicate>(isGraphical)));
+ ASSERT_TRUE(allOf(nonGraphicalChars.span().takeOkay(), static_cast<CharPredicate>(isAscii)));
ASSERT_EQ(nonGraphicalChars.size() + graphicalChars.size(), INT8_MAX + 1);
auto invalidAsciiChars = invalidAsciiGenerator();
- ASSERT_FALSE(anyOf(invalidAsciiChars, charIsGraphical));
+ ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast<CharPredicate>(isGraphical)));
- ASSERT_FALSE(utf8IsGraphical(FudUtf8{Ascii{invalidAscii}}));
+ ASSERT_FALSE(isGraphical(FudUtf8{Ascii{invalidAscii}}));
SpanGenerator<char, graphicalChars.size()> graphicalGenerator{graphicalChars.span()};
auto utf8GraphicalGenerator = [&]() { return graphicalGenerator().map(toUtf8<uint16_t>); };
- ASSERT_TRUE(allOf(utf8GraphicalGenerator, utf8IsGraphical));
+ ASSERT_TRUE(allOf(utf8GraphicalGenerator, static_cast<FudUtf8Predicate>(isGraphical)));
SpanGenerator<char> nonGraphicalGenerator{nonGraphicalChars.span().takeOkay()};
auto utf8NonGraphicalGenerator = [&]() { return nonGraphicalGenerator().map(toUtf8<uint16_t>); };
- ASSERT_FALSE(anyOf(utf8NonGraphicalGenerator, utf8IsGraphical));
+ ASSERT_FALSE(anyOf(utf8NonGraphicalGenerator, static_cast<FudUtf8Predicate>(isGraphical)));
}
TEST(Utf8Test, Utf8IsSpace)
@@ -506,32 +535,32 @@ TEST(Utf8Test, Utf8IsSpace)
Array<char, numSpaceChars> spaceChars{};
copyMem<numSpaceChars>(spaceChars, spaceCharLiteral);
- ASSERT_TRUE(allOf(spaceChars.span(), charIsSpace));
+ ASSERT_TRUE(allOf(spaceChars.span(), static_cast<CharPredicate>(isSpace)));
constexpr size_t numNonSpaceChars = validAsciiSize - numSpaceChars;
Vector<char> nonSpaceChars{};
ASSERT_EQ(nonSpaceChars.reserve(numNonSpaceChars), FudStatus::Success);
for (uint8_t idx = 0; idx < INT8_MAX + 1; ++idx) {
- if (!charIsSpace(static_cast<char>(idx))) {
+ if (!isSpace(static_cast<char>(idx))) {
ASSERT_EQ(nonSpaceChars.pushBack(static_cast<char>(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<CharPredicate>(isSpace)));
+ ASSERT_TRUE(allOf(nonSpaceChars.span().takeOkay(), static_cast<CharPredicate>(isAscii)));
ASSERT_EQ(nonSpaceChars.size() + spaceChars.size(), INT8_MAX + 1);
auto invalidAsciiChars = invalidAsciiGenerator();
- ASSERT_FALSE(anyOf(invalidAsciiChars, charIsSpace));
+ ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast<CharPredicate>(isSpace)));
- ASSERT_FALSE(utf8IsSpace(FudUtf8{Ascii{invalidAscii}}));
+ ASSERT_FALSE(isSpace(FudUtf8{Ascii{invalidAscii}}));
SpanGenerator<char, spaceChars.size()> spaceGenerator{spaceChars.span()};
auto utf8SpaceGenerator = [&]() { return spaceGenerator().map(toUtf8<uint16_t>); };
- ASSERT_TRUE(allOf(utf8SpaceGenerator, utf8IsSpace));
+ ASSERT_TRUE(allOf(utf8SpaceGenerator, static_cast<FudUtf8Predicate>(isSpace)));
SpanGenerator<char> nonSpaceGenerator{nonSpaceChars.span().takeOkay()};
auto utf8NonSpaceGenerator = [&]() { return nonSpaceGenerator().map(toUtf8<uint16_t>); };
- ASSERT_FALSE(anyOf(utf8NonSpaceGenerator, utf8IsSpace));
+ ASSERT_FALSE(anyOf(utf8NonSpaceGenerator, static_cast<FudUtf8Predicate>(isSpace)));
}
TEST(Utf8Test, Utf8IsBlank)
@@ -541,32 +570,32 @@ TEST(Utf8Test, Utf8IsBlank)
Array<char, numBlankChars> blankChars{};
copyMem<numBlankChars>(blankChars, blankCharLiteral);
- ASSERT_TRUE(allOf(blankChars.span(), charIsBlank));
+ ASSERT_TRUE(allOf(blankChars.span(), static_cast<CharPredicate>(isBlank)));
constexpr size_t numNonBlankChars = validAsciiSize - numBlankChars;
Vector<char> nonBlankChars{};
ASSERT_EQ(nonBlankChars.reserve(numNonBlankChars), FudStatus::Success);
for (uint8_t idx = 0; idx < INT8_MAX + 1; ++idx) {
- if (!charIsBlank(static_cast<char>(idx))) {
+ if (!isBlank(static_cast<char>(idx))) {
ASSERT_EQ(nonBlankChars.pushBack(static_cast<char>(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<CharPredicate>(isBlank)));
+ ASSERT_TRUE(allOf(nonBlankChars.span().takeOkay(), static_cast<CharPredicate>(isAscii)));
ASSERT_EQ(nonBlankChars.size() + blankChars.size(), INT8_MAX + 1);
auto invalidAsciiChars = invalidAsciiGenerator();
- ASSERT_FALSE(anyOf(invalidAsciiChars, charIsBlank));
+ ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast<CharPredicate>(isBlank)));
- ASSERT_FALSE(utf8IsBlank(FudUtf8{Ascii{invalidAscii}}));
+ ASSERT_FALSE(isBlank(FudUtf8{Ascii{invalidAscii}}));
SpanGenerator<char, blankChars.size()> blankGenerator{blankChars.span()};
auto utf8BlankGenerator = [&]() { return blankGenerator().map(toUtf8<uint16_t>); };
- ASSERT_TRUE(allOf(utf8BlankGenerator, utf8IsBlank));
+ ASSERT_TRUE(allOf(utf8BlankGenerator, static_cast<FudUtf8Predicate>(isBlank)));
SpanGenerator<char> nonBlankGenerator{nonBlankChars.span().takeOkay()};
auto utf8NonBlankGenerator = [&]() { return nonBlankGenerator().map(toUtf8<uint16_t>); };
- ASSERT_FALSE(anyOf(utf8NonBlankGenerator, utf8IsBlank));
+ ASSERT_FALSE(anyOf(utf8NonBlankGenerator, static_cast<FudUtf8Predicate>(isBlank)));
}
TEST(Utf8Test, Utf8IsPrintable)
@@ -576,32 +605,32 @@ TEST(Utf8Test, Utf8IsPrintable)
Array<char, numPrintableChars> printableChars{};
copyMem<numPrintableChars>(printableChars, printableCharLiteral);
- ASSERT_TRUE(allOf(printableChars.span(), charIsPrintable));
+ ASSERT_TRUE(allOf(printableChars.span(), static_cast<CharPredicate>(isPrintable)));
constexpr size_t numNonPrintableChars = validAsciiSize - numPrintableChars;
Vector<char> nonPrintableChars{};
ASSERT_EQ(nonPrintableChars.reserve(numNonPrintableChars), FudStatus::Success);
for (uint8_t idx = 0; idx < INT8_MAX + 1; ++idx) {
- if (!charIsPrintable(static_cast<char>(idx))) {
+ if (!isPrintable(static_cast<char>(idx))) {
ASSERT_EQ(nonPrintableChars.pushBack(static_cast<char>(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<CharPredicate>(isPrintable)));
+ ASSERT_TRUE(allOf(nonPrintableChars.span().takeOkay(), static_cast<CharPredicate>(isAscii)));
ASSERT_EQ(nonPrintableChars.size() + printableChars.size(), INT8_MAX + 1);
auto invalidAsciiChars = invalidAsciiGenerator();
- ASSERT_FALSE(anyOf(invalidAsciiChars, charIsPrintable));
+ ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast<CharPredicate>(isPrintable)));
- ASSERT_FALSE(utf8IsPrintable(FudUtf8{Ascii{invalidAscii}}));
+ ASSERT_FALSE(isPrintable(FudUtf8{Ascii{invalidAscii}}));
SpanGenerator<char, printableChars.size()> printableGenerator{printableChars.span()};
auto utf8PrintableGenerator = [&]() { return printableGenerator().map(toUtf8<uint16_t>); };
- ASSERT_TRUE(allOf(utf8PrintableGenerator, utf8IsPrintable));
+ ASSERT_TRUE(allOf(utf8PrintableGenerator, static_cast<FudUtf8Predicate>(isPrintable)));
SpanGenerator<char> nonPrintableGenerator{nonPrintableChars.span().takeOkay()};
auto utf8NonPrintableGenerator = [&]() { return nonPrintableGenerator().map(toUtf8<uint16_t>); };
- ASSERT_FALSE(anyOf(utf8NonPrintableGenerator, utf8IsPrintable));
+ ASSERT_FALSE(anyOf(utf8NonPrintableGenerator, static_cast<FudUtf8Predicate>(isPrintable)));
}
TEST(Utf8Test, Utf8IsPunctuation)
@@ -611,32 +640,32 @@ TEST(Utf8Test, Utf8IsPunctuation)
Array<char, numPunctuationChars> punctuationChars{};
copyMem<numPunctuationChars>(punctuationChars, punctuationCharLiteral);
- ASSERT_TRUE(allOf(punctuationChars.span(), charIsPunctuation));
+ ASSERT_TRUE(allOf(punctuationChars.span(), static_cast<CharPredicate>(isPunctuation)));
constexpr size_t numNonPunctuationChars = validAsciiSize - numPunctuationChars;
Vector<char> nonPunctuationChars{};
ASSERT_EQ(nonPunctuationChars.reserve(numNonPunctuationChars), FudStatus::Success);
for (uint8_t idx = 0; idx < INT8_MAX + 1; ++idx) {
- if (!charIsPunctuation(static_cast<char>(idx))) {
+ if (!isPunctuation(static_cast<char>(idx))) {
ASSERT_EQ(nonPunctuationChars.pushBack(static_cast<char>(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<CharPredicate>(isPunctuation)));
+ ASSERT_TRUE(allOf(nonPunctuationChars.span().takeOkay(), static_cast<CharPredicate>(isAscii)));
ASSERT_EQ(nonPunctuationChars.size() + punctuationChars.size(), INT8_MAX + 1);
auto invalidAsciiChars = invalidAsciiGenerator();
- ASSERT_FALSE(anyOf(invalidAsciiChars, charIsPunctuation));
+ ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast<CharPredicate>(isPunctuation)));
- ASSERT_FALSE(utf8IsPunctuation(FudUtf8{Ascii{invalidAscii}}));
+ ASSERT_FALSE(isPunctuation(FudUtf8{Ascii{invalidAscii}}));
SpanGenerator<char, punctuationChars.size()> punctuationGenerator{punctuationChars.span()};
auto utf8PunctuationGenerator = [&]() { return punctuationGenerator().map(toUtf8<uint16_t>); };
- ASSERT_TRUE(allOf(utf8PunctuationGenerator, utf8IsPunctuation));
+ ASSERT_TRUE(allOf(utf8PunctuationGenerator, static_cast<FudUtf8Predicate>(isPunctuation)));
SpanGenerator<char> nonPunctuationGenerator{nonPunctuationChars.span().takeOkay()};
auto utf8NonPunctuationGenerator = [&]() { return nonPunctuationGenerator().map(toUtf8<uint16_t>); };
- ASSERT_FALSE(anyOf(utf8NonPunctuationGenerator, utf8IsPunctuation));
+ ASSERT_FALSE(anyOf(utf8NonPunctuationGenerator, static_cast<FudUtf8Predicate>(isPunctuation)));
}
} // namespace fud