summaryrefslogtreecommitdiff
path: root/test/test_utf8.cpp
diff options
context:
space:
mode:
authorDominick Allen <djallen@librehumanitas.org>2024-10-21 12:49:43 -0500
committerDominick Allen <djallen@librehumanitas.org>2024-10-21 12:49:43 -0500
commitb2dbcb55e2832c373fecb4033a3ed77e5dbc77aa (patch)
tree1f294fcf1d85a02db86de3eea2b03393fd89ca5a /test/test_utf8.cpp
parent6a27a2a4032e88fa9154ef0f0741edc584f7a701 (diff)
Add vector and option.
Diffstat (limited to 'test/test_utf8.cpp')
-rw-r--r--test/test_utf8.cpp1125
1 files changed, 302 insertions, 823 deletions
diff --git a/test/test_utf8.cpp b/test/test_utf8.cpp
index 8f1d655..d1737f7 100644
--- a/test/test_utf8.cpp
+++ b/test/test_utf8.cpp
@@ -38,10 +38,21 @@ constexpr char printableCharOffset = 0x20;
constexpr auto invalidAscii = FudUtf8::invalidAsciiCode.character();
-auto generateInvalidAsciiChars()
+auto invalidAsciiGenerator()
{
- Iota<utf8> iota{};
- return generate([]() { return Array<utf8, invalidAsciiSize>{}; }, [&]() { return iota().value(); });
+ return Iota<uint16_t>{validAsciiSize, 1, invalidAsciiSize};
+}
+
+template <typename T>
+auto toUtf8(T letter)
+{
+ return FudUtf8::make(static_cast<utf8>(letter));
+}
+
+template <typename T>
+auto toLetter(T letter)
+{
+ return static_cast<char>(letter);
}
TEST(Utf8Test, Utf8Creation)
@@ -187,123 +198,80 @@ TEST(Utf8Test, Utf8IsAscii)
Iota<int16_t> charIota{0, 1, validAsciiSize};
- ASSERT_TRUE(allOf(
- [&]() -> std::optional<char> {
- auto value = charIota();
- return value ? std::optional<char>(static_cast<char>(*value)) : std::nullopt;
- },
- charIsAscii));
+ ASSERT_TRUE(allOf([&]() -> Option<char> { return charIota().map(toLetter<int16_t>); }, charIsAscii));
Iota<int16_t> invalidCharIota{validAsciiSize, 1, invalidAsciiSize};
- ASSERT_FALSE(anyOf(
- [&]() -> std::optional<char> {
- auto value = invalidCharIota();
- return value ? std::optional<char>(static_cast<char>(*value)) : std::nullopt;
- },
- charIsAscii));
+ ASSERT_FALSE(anyOf([&]() -> Option<char> { return invalidCharIota().map(toLetter<int16_t>); }, charIsAscii));
FudUtf8 unicode{FudUtf8::invalidAscii()};
ASSERT_FALSE(utf8IsAscii(unicode));
charIota.set(0);
- ASSERT_TRUE(allOf(
- [&]() -> std::optional<FudUtf8> {
- auto value = charIota();
- return value ? std::optional<FudUtf8>(FudUtf8::make(static_cast<utf8>(*value))) : std::nullopt;
- },
- utf8IsAscii));
+ ASSERT_TRUE(allOf([&]() -> Option<FudUtf8> { return charIota().map(toUtf8<int16_t>); }, utf8IsAscii));
invalidCharIota.set(invalidAsciiSize);
- ASSERT_FALSE(anyOf(
- [&]() -> std::optional<FudUtf8> {
- auto value = invalidCharIota();
- return value ? std::optional<FudUtf8>(FudUtf8::make(static_cast<utf8>(*value))) : std::nullopt;
- },
- utf8IsAscii));
+ ASSERT_FALSE(anyOf([&]() -> Option<FudUtf8> { return invalidCharIota().map(toUtf8<int16_t>); }, utf8IsAscii));
}
-TEST(Utf8Test, Utf8IsAlphaNumeric)
+template <typename T, size_t Size = SIZE_MAX>
+struct SpanGenerator {
+ Span<T, Size> span;
+ size_t index{0};
+
+ void reset()
+ {
+ index = 0;
+ }
+
+ Option<T> operator()()
+ {
+ if (index < span.size()) {
+ index++;
+ return span[index - 1];
+ }
+ return NullOpt;
+ }
+};
+
+TEST(Utf8Test, Utf8IsAlphanumeric)
{
- constexpr size_t numAlphaNumericChars = 26 * 2 + 10;
- Array<char, numAlphaNumericChars + 1> alphaNumericCharLiteral{ALPHA_NUMERIC_CHARS};
- Array<char, numAlphaNumericChars> alphaNumericChars{};
- copyMem<numAlphaNumericChars>(alphaNumericChars, alphaNumericCharLiteral);
-#if 0
- ASSERT_TRUE(allOf(alphaNumericChars, charIsAlphanumeric));
-
- auto alphaNumericSetResult{StaticSet<char, numAlphaNumericChars>::makeFromArray(alphaNumericChars)};
- ASSERT_TRUE(alphaNumericSetResult.isOkay());
- auto alphaNumericSet{std::move(alphaNumericSetResult.getOkay())};
-
- constexpr size_t numNonAlphaNumericChars = validAsciiSize - numAlphaNumericChars;
- FixedVector<char, numNonAlphaNumericChars> nonAlphaNumericChars{};
+ constexpr size_t numAlphanumericChars = 26 * 2 + 10;
+ Array<char, numAlphanumericChars + 1> alphanumericCharLiteral{ALPHA_NUMERIC_CHARS};
+ Array<char, numAlphanumericChars> alphanumericChars{};
+ copyMem<numAlphanumericChars>(alphanumericChars, alphanumericCharLiteral);
+
+ ASSERT_TRUE(allOf(alphanumericChars.span(), charIsAlphanumeric));
+
+ constexpr size_t numNonAlphanumericChars = validAsciiSize - numAlphanumericChars;
+ Vector<char> nonAlphanumericChars{};
for (char idx = 0; idx < INT8_MAX; ++idx) {
- if (!alphaNumericSet.isKey(idx)) {
- ASSERT_TRUE(nonAlphaNumericChars.pushBack(idx));
+ if (!charIsAlphanumeric(idx)) {
+ ASSERT_EQ(nonAlphanumericChars.pushBack(idx), FudStatus::Success);
}
}
- ASSERT_FALSE(anyOf(nonAlphaNumericChars, charIsAlphanumeric));
+ auto nonAlphanumericSpan{nonAlphanumericChars.span().takeOkay()};
+ ASSERT_FALSE(anyOf(nonAlphanumericSpan, charIsAlphanumeric));
- auto invalidAsciiChars = generateInvalidAsciiChars();
+ auto invalidAsciiChars = invalidAsciiGenerator();
ASSERT_FALSE(anyOf(invalidAsciiChars, charIsAlphanumeric));
- ASSERT_TRUE(allOf(
- map(alphaNumericChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_alphanumeric));
- ASSERT_FALSE(anyOf(
- map(nonAlphaNumericChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_alphanumeric));
- ASSERT_FALSE(anyOf(
- map(invalidAsciiChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_alphanumeric));
-
- ASSERT_TRUE(allOf(
- map(alphaNumericChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_alphanumeric));
- ASSERT_FALSE(anyOf(
- map(nonAlphaNumericChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_alphanumeric));
- ASSERT_FALSE(anyOf(
- map(invalidAsciiChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_alphanumeric));
-
- Utf8 utf8{invalidAscii};
- bool isAscii = false;
- ASSERT_EQ(ext_lib_utf8_is_alphanumeric(nullptr, nullptr), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_alphanumeric(&utf8, nullptr), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_alphanumeric(nullptr, &isAscii), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_alphanumeric(&utf8, &isAscii), ExtInvalidInput);
- ASSERT_FALSE(isAscii);
-
- ASSERT_TRUE(allOf(
- map(alphaNumericChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_alphanumeric(&utf8Letter, &predicate);
- return isPredicateStatus == ExtSuccess && predicate;
- }));
- ASSERT_FALSE(anyOf(
- map(nonAlphaNumericChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_alphanumeric(&utf8Letter, &predicate);
- return isPredicateStatus != ExtSuccess || predicate;
- }));
- ASSERT_FALSE(allOf(
- map(nonAlphaNumericChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_alphanumeric(&utf8Letter, &predicate);
- return isPredicateStatus == ExtInvalidInput && !predicate;
- }));
-#endif
+ ASSERT_FALSE(utf8IsAlphanumeric(FudUtf8{Ascii{invalidAscii}}));
+
+ auto iotaGenerator = invalidAsciiGenerator();
+ auto generator = generate(
+ []() { return Array<utf8, invalidAsciiSize>{}; },
+ [&]() { return iotaGenerator().map([](auto val) { return static_cast<utf8>(val); }); });
+
+ SpanGenerator<char, alphanumericChars.size()> alphanumericGenerator{alphanumericChars.span()};
+ auto utf8AlphanumericGenerator = [&]() { return alphanumericGenerator().map(toUtf8<uint16_t>); };
+ ASSERT_TRUE(allOf(utf8AlphanumericGenerator, utf8IsAlphanumeric));
+
+ SpanGenerator<char> nonAlphanumericGenerator{nonAlphanumericChars.span().takeOkay()};
+ auto utf8NonAlphanumericGenerator = [&]() { return nonAlphanumericGenerator().map(toUtf8<uint16_t>); };
+ ASSERT_FALSE(anyOf(utf8NonAlphanumericGenerator, utf8IsAlphanumeric));
}
-#if 0
TEST(Utf8Test, Utf8IsAlpha)
{
constexpr size_t numAlphaChars = sizeof(ALPHA_CHARS) - 1;
@@ -311,75 +279,29 @@ TEST(Utf8Test, Utf8IsAlpha)
Array<char, numAlphaChars> alphaChars{};
copyMem<numAlphaChars>(alphaChars, alphaCharLiteral);
- ASSERT_TRUE(allOf(alphaChars, ext_lib_char_is_alpha));
-
- auto alphaSetResult{StaticSet<char, numAlphaChars>::makeFromArray(alphaChars)};
- ASSERT_TRUE(alphaSetResult.isOkay());
- auto alphaSet{std::move(alphaSetResult.getOkay())};
+ ASSERT_TRUE(allOf(alphaChars.span(), charIsAlpha));
- constexpr size_t numNonAlphaChars = validAsciiSize - numAlphaChars;
- FixedVector<char, numNonAlphaChars> nonAlphaChars{};
+ constexpr size_t numNonAlphanumericChars = validAsciiSize - numAlphaChars;
+ Vector<char> nonAlphaChars{};
for (char idx = 0; idx < INT8_MAX; ++idx) {
- if (!alphaSet.isKey(idx)) {
- ASSERT_TRUE(nonAlphaChars.pushBack(idx));
+ if (!charIsAlphanumeric(idx)) {
+ ASSERT_EQ(nonAlphaChars.pushBack(idx), FudStatus::Success);
}
}
- ASSERT_FALSE(anyOf(nonAlphaChars, ext_lib_char_is_alpha));
-
- auto invalidAsciiChars = generateInvalidAsciiChars();
- ASSERT_FALSE(anyOf(invalidAsciiChars, ext_lib_char_is_alpha));
-
- ASSERT_TRUE(allOf(
- map(alphaChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_alpha));
- ASSERT_FALSE(anyOf(
- map(nonAlphaChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_alpha));
- ASSERT_FALSE(anyOf(
- map(invalidAsciiChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_alpha));
-
- ASSERT_TRUE(allOf(
- map(alphaChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_alpha));
- ASSERT_FALSE(anyOf(
- map(nonAlphaChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_alpha));
- ASSERT_FALSE(anyOf(
- map(invalidAsciiChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_alpha));
-
- Utf8 utf8{invalidAscii};
- bool isAscii = false;
- ASSERT_EQ(ext_lib_utf8_is_alpha(nullptr, nullptr), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_alpha(&utf8, nullptr), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_alpha(nullptr, &isAscii), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_alpha(&utf8, &isAscii), ExtInvalidInput);
- ASSERT_FALSE(isAscii);
-
- ASSERT_TRUE(allOf(
- map(alphaChars, [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_alpha(&utf8Letter, &predicate);
- return isPredicateStatus == ExtSuccess && predicate;
- }));
- ASSERT_FALSE(anyOf(
- map(nonAlphaChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_alpha(&utf8Letter, &predicate);
- return isPredicateStatus != ExtSuccess || predicate;
- }));
- ASSERT_FALSE(allOf(
- map(nonAlphaChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_alpha(&utf8Letter, &predicate);
- return isPredicateStatus == ExtInvalidInput && !predicate;
- }));
+ ASSERT_FALSE(anyOf(nonAlphaChars.span().takeOkay(), charIsAlpha));
+
+ auto invalidAsciiChars = invalidAsciiGenerator();
+ ASSERT_FALSE(anyOf(invalidAsciiChars, charIsAlpha));
+
+ ASSERT_FALSE(utf8IsAlpha(FudUtf8{Ascii{invalidAscii}}));
+
+ SpanGenerator<char, alphaChars.size()> alphaGenerator{alphaChars.span()};
+ auto utf8AlphaGenerator = [&]() { return alphaGenerator().map(toUtf8<uint16_t>); };
+ ASSERT_TRUE(allOf(utf8AlphaGenerator, utf8IsAlpha));
+
+ SpanGenerator<char> nonAlphaGenerator{nonAlphaChars.span().takeOkay()};
+ auto utf8NonAlphaGenerator = [&]() { return nonAlphaGenerator().map(toUtf8<uint16_t>); };
+ ASSERT_FALSE(anyOf(utf8NonAlphaGenerator, utf8IsAlpha));
}
TEST(Utf8Test, Utf8IsLower)
@@ -389,75 +311,29 @@ TEST(Utf8Test, Utf8IsLower)
Array<char, numLowerChars> lowerChars{};
copyMem<numLowerChars>(lowerChars, lowerCharLiteral);
- ASSERT_TRUE(allOf(lowerChars, ext_lib_char_is_lowercase));
-
- auto lowerSetResult{StaticSet<char, numLowerChars>::makeFromArray(lowerChars)};
- ASSERT_TRUE(lowerSetResult.isOkay());
- auto lowerSet{std::move(lowerSetResult.getOkay())};
+ ASSERT_TRUE(allOf(lowerChars.span(), charIsLowercase));
constexpr size_t numNonLowerChars = validAsciiSize - numLowerChars;
- FixedVector<char, numNonLowerChars> nonLowerChars{};
+ Vector<char> nonLowerChars{};
for (char idx = 0; idx < INT8_MAX; ++idx) {
- if (!lowerSet.isKey(idx)) {
- ASSERT_TRUE(nonLowerChars.pushBack(idx));
+ if (!charIsLowercase(idx)) {
+ ASSERT_EQ(nonLowerChars.pushBack(idx), FudStatus::Success);
}
}
- ASSERT_FALSE(anyOf(nonLowerChars, ext_lib_char_is_lowercase));
-
- auto invalidAsciiChars = generateInvalidAsciiChars();
- ASSERT_FALSE(anyOf(invalidAsciiChars, ext_lib_char_is_lowercase));
-
- ASSERT_TRUE(allOf(
- map(lowerChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_lowercase));
- ASSERT_FALSE(anyOf(
- map(nonLowerChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_lowercase));
- ASSERT_FALSE(anyOf(
- map(invalidAsciiChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_lowercase));
-
- ASSERT_TRUE(allOf(
- map(lowerChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_lowercase));
- ASSERT_FALSE(anyOf(
- map(nonLowerChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_lowercase));
- ASSERT_FALSE(anyOf(
- map(invalidAsciiChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_lowercase));
-
- Utf8 utf8{invalidAscii};
- bool isAscii = false;
- ASSERT_EQ(ext_lib_utf8_is_lowercase(nullptr, nullptr), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_lowercase(&utf8, nullptr), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_lowercase(nullptr, &isAscii), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_lowercase(&utf8, &isAscii), ExtInvalidInput);
- ASSERT_FALSE(isAscii);
-
- ASSERT_TRUE(allOf(
- map(lowerChars, [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_lowercase(&utf8Letter, &predicate);
- return isPredicateStatus == ExtSuccess && predicate;
- }));
- ASSERT_FALSE(anyOf(
- map(nonLowerChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_lowercase(&utf8Letter, &predicate);
- return isPredicateStatus != ExtSuccess || predicate;
- }));
- ASSERT_FALSE(allOf(
- map(nonLowerChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_lowercase(&utf8Letter, &predicate);
- return isPredicateStatus == ExtInvalidInput && !predicate;
- }));
+ ASSERT_FALSE(anyOf(nonLowerChars.span().takeOkay(), charIsLowercase));
+
+ auto invalidAsciiChars = invalidAsciiGenerator();
+ ASSERT_FALSE(anyOf(invalidAsciiChars, charIsLowercase));
+
+ ASSERT_FALSE(utf8IsLowercase(FudUtf8{Ascii{invalidAscii}}));
+
+ SpanGenerator<char, lowerChars.size()> lowerGenerator{lowerChars.span()};
+ auto utf8LowerGenerator = [&]() { return lowerGenerator().map(toUtf8<uint16_t>); };
+ ASSERT_TRUE(allOf(utf8LowerGenerator, utf8IsLowercase));
+
+ SpanGenerator<char> nonLowerGenerator{nonLowerChars.span().takeOkay()};
+ auto utf8NonLowerGenerator = [&]() { return nonLowerGenerator().map(toUtf8<uint16_t>); };
+ ASSERT_FALSE(anyOf(utf8NonLowerGenerator, utf8IsLowercase));
}
TEST(Utf8Test, Utf8IsUpper)
@@ -467,153 +343,61 @@ TEST(Utf8Test, Utf8IsUpper)
Array<char, numUpperChars> upperChars{};
copyMem<numUpperChars>(upperChars, upperCharLiteral);
- ASSERT_TRUE(allOf(upperChars, ext_lib_char_is_uppercase));
-
- auto upperSetResult{StaticSet<char, numUpperChars>::makeFromArray(upperChars)};
- ASSERT_TRUE(upperSetResult.isOkay());
- auto upperSet{std::move(upperSetResult.getOkay())};
+ ASSERT_TRUE(allOf(upperChars.span(), charIsUppercase));
constexpr size_t numNonUpperChars = validAsciiSize - numUpperChars;
- FixedVector<char, numNonUpperChars> nonUpperChars{};
+ Vector<char> nonUpperChars{};
for (char idx = 0; idx < INT8_MAX; ++idx) {
- if (!upperSet.isKey(idx)) {
- ASSERT_TRUE(nonUpperChars.pushBack(idx));
+ if (!charIsUppercase(idx)) {
+ ASSERT_EQ(nonUpperChars.pushBack(idx), FudStatus::Success);
}
}
- ASSERT_FALSE(anyOf(nonUpperChars, ext_lib_char_is_uppercase));
-
- auto invalidAsciiChars = generateInvalidAsciiChars();
- ASSERT_FALSE(anyOf(invalidAsciiChars, ext_lib_char_is_uppercase));
-
- ASSERT_TRUE(allOf(
- map(upperChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_uppercase));
- ASSERT_FALSE(anyOf(
- map(nonUpperChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_uppercase));
- ASSERT_FALSE(anyOf(
- map(invalidAsciiChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_uppercase));
-
- ASSERT_TRUE(allOf(
- map(upperChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_uppercase));
- ASSERT_FALSE(anyOf(
- map(nonUpperChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_uppercase));
- ASSERT_FALSE(anyOf(
- map(invalidAsciiChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_uppercase));
-
- Utf8 utf8{invalidAscii};
- bool isAscii = false;
- ASSERT_EQ(ext_lib_utf8_is_uppercase(nullptr, nullptr), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_uppercase(&utf8, nullptr), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_uppercase(nullptr, &isAscii), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_uppercase(&utf8, &isAscii), ExtInvalidInput);
- ASSERT_FALSE(isAscii);
-
- ASSERT_TRUE(allOf(
- map(upperChars, [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_uppercase(&utf8Letter, &predicate);
- return isPredicateStatus == ExtSuccess && predicate;
- }));
- ASSERT_FALSE(anyOf(
- map(nonUpperChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_uppercase(&utf8Letter, &predicate);
- return isPredicateStatus != ExtSuccess || predicate;
- }));
- ASSERT_FALSE(allOf(
- map(nonUpperChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_uppercase(&utf8Letter, &predicate);
- return isPredicateStatus == ExtInvalidInput && !predicate;
- }));
+ ASSERT_FALSE(anyOf(nonUpperChars.span().takeOkay(), charIsUppercase));
+
+ auto invalidAsciiChars = invalidAsciiGenerator();
+ ASSERT_FALSE(anyOf(invalidAsciiChars, charIsUppercase));
+
+ ASSERT_FALSE(utf8IsUppercase(FudUtf8{Ascii{invalidAscii}}));
+
+ SpanGenerator<char, upperChars.size()> upperGenerator{upperChars.span()};
+ auto utf8UpperGenerator = [&]() { return upperGenerator().map(toUtf8<uint16_t>); };
+ ASSERT_TRUE(allOf(utf8UpperGenerator, utf8IsUppercase));
+
+ SpanGenerator<char> nonUpperGenerator{nonUpperChars.span().takeOkay()};
+ auto utf8NonUpperGenerator = [&]() { return nonUpperGenerator().map(toUtf8<uint16_t>); };
+ ASSERT_FALSE(anyOf(utf8NonUpperGenerator, utf8IsUppercase));
}
TEST(Utf8Test, Utf8IsDigit)
{
constexpr size_t numDigitChars = 10;
- Array<char, numDigitChars + 1> digitCharLiteral{"0123456789"};
+ Array<char, numDigitChars + 1> digitCharLiteral{DECIMAL_CHARS};
Array<char, numDigitChars> digitChars{};
copyMem<numDigitChars>(digitChars, digitCharLiteral);
- ASSERT_TRUE(allOf(digitChars, ext_lib_char_is_digit));
-
- auto digitSetResult{StaticSet<char, numDigitChars>::makeFromArray(digitChars)};
- ASSERT_TRUE(digitSetResult.isOkay());
- auto digitSet{std::move(digitSetResult.getOkay())};
+ ASSERT_TRUE(allOf(digitChars.span(), charIsDigit));
constexpr size_t numNonDigitChars = validAsciiSize - numDigitChars;
- FixedVector<char, numNonDigitChars> nonDigitChars{};
+ Vector<char> nonDigitChars{};
for (char idx = 0; idx < INT8_MAX; ++idx) {
- if (!digitSet.isKey(idx)) {
- ASSERT_TRUE(nonDigitChars.pushBack(idx));
+ if (!charIsDigit(idx)) {
+ ASSERT_EQ(nonDigitChars.pushBack(idx), FudStatus::Success);
}
}
- ASSERT_FALSE(anyOf(nonDigitChars, ext_lib_char_is_digit));
-
- auto invalidAsciiChars = generateInvalidAsciiChars();
- ASSERT_FALSE(anyOf(invalidAsciiChars, ext_lib_char_is_digit));
-
- ASSERT_TRUE(allOf(
- map(digitChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_digit));
- ASSERT_FALSE(anyOf(
- map(nonDigitChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_digit));
- ASSERT_FALSE(anyOf(
- map(invalidAsciiChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_digit));
-
- ASSERT_TRUE(allOf(
- map(digitChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_digit));
- ASSERT_FALSE(anyOf(
- map(nonDigitChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_digit));
- ASSERT_FALSE(anyOf(
- map(invalidAsciiChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_digit));
-
- Utf8 utf8{invalidAscii};
- bool isAscii = false;
- ASSERT_EQ(ext_lib_utf8_is_digit(nullptr, nullptr), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_digit(&utf8, nullptr), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_digit(nullptr, &isAscii), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_digit(&utf8, &isAscii), ExtInvalidInput);
- ASSERT_FALSE(isAscii);
-
- ASSERT_TRUE(allOf(
- map(digitChars, [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_digit(&utf8Letter, &predicate);
- return isPredicateStatus == ExtSuccess && predicate;
- }));
- ASSERT_FALSE(anyOf(
- map(nonDigitChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_digit(&utf8Letter, &predicate);
- return isPredicateStatus != ExtSuccess || predicate;
- }));
- ASSERT_FALSE(allOf(
- map(nonDigitChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_digit(&utf8Letter, &predicate);
- return isPredicateStatus == ExtInvalidInput && !predicate;
- }));
+ ASSERT_FALSE(anyOf(nonDigitChars.span().takeOkay(), charIsDigit));
+
+ auto invalidAsciiChars = invalidAsciiGenerator();
+ ASSERT_FALSE(anyOf(invalidAsciiChars, charIsDigit));
+
+ ASSERT_FALSE(utf8IsDigit(FudUtf8{Ascii{invalidAscii}}));
+
+ SpanGenerator<char, digitChars.size()> digitGenerator{digitChars.span()};
+ auto utf8DigitGenerator = [&]() { return digitGenerator().map(toUtf8<uint16_t>); };
+ ASSERT_TRUE(allOf(utf8DigitGenerator, utf8IsDigit));
+
+ SpanGenerator<char> nonDigitGenerator{nonDigitChars.span().takeOkay()};
+ auto utf8NonDigitGenerator = [&]() { return nonDigitGenerator().map(toUtf8<uint16_t>); };
+ ASSERT_FALSE(anyOf(utf8NonDigitGenerator, utf8IsDigit));
}
TEST(Utf8Test, Utf8IsHexDigit)
@@ -623,147 +407,61 @@ TEST(Utf8Test, Utf8IsHexDigit)
Array<char, numHexDigitChars> hexDigitChars{};
copyMem<numHexDigitChars>(hexDigitChars, hexDigitCharLiteral);
- ASSERT_TRUE(allOf(hexDigitChars, ext_lib_char_is_hex_digit));
-
- auto hexDigitSetResult{StaticSet<char, numHexDigitChars>::makeFromArray(hexDigitChars)};
- ASSERT_TRUE(hexDigitSetResult.isOkay());
- auto hexDigitSet{std::move(hexDigitSetResult.getOkay())};
+ ASSERT_TRUE(allOf(hexDigitChars.span(), charIsHexDigit));
constexpr size_t numNonHexDigitChars = validAsciiSize - numHexDigitChars;
- FixedVector<char, numNonHexDigitChars> nonHexDigitChars{};
+ Vector<char> nonHexDigitChars{};
for (char idx = 0; idx < INT8_MAX; ++idx) {
- if (!hexDigitSet.isKey(idx)) {
- ASSERT_TRUE(nonHexDigitChars.pushBack(idx));
+ if (!charIsHexDigit(idx)) {
+ ASSERT_EQ(nonHexDigitChars.pushBack(idx), FudStatus::Success);
}
}
- ASSERT_FALSE(anyOf(nonHexDigitChars, ext_lib_char_is_hex_digit));
-
- auto invalidAsciiChars = generateInvalidAsciiChars();
- ASSERT_FALSE(anyOf(invalidAsciiChars, ext_lib_char_is_hex_digit));
-
- ASSERT_TRUE(allOf(
- map(hexDigitChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_hex_digit));
- ASSERT_FALSE(anyOf(
- map(nonHexDigitChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_hex_digit));
- ASSERT_FALSE(anyOf(
- map(invalidAsciiChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_hex_digit));
-
- ASSERT_TRUE(allOf(
- map(hexDigitChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_hex_digit));
- ASSERT_FALSE(anyOf(
- map(nonHexDigitChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_hex_digit));
- ASSERT_FALSE(anyOf(
- map(invalidAsciiChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_hex_digit));
-
- Utf8 utf8{invalidAscii};
- bool isAscii = false;
- ASSERT_EQ(ext_lib_utf8_is_hex_digit(nullptr, nullptr), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_hex_digit(&utf8, nullptr), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_hex_digit(nullptr, &isAscii), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_hex_digit(&utf8, &isAscii), ExtInvalidInput);
- ASSERT_FALSE(isAscii);
-
- ASSERT_TRUE(allOf(
- map(hexDigitChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_hex_digit(&utf8Letter, &predicate);
- return isPredicateStatus == ExtSuccess && predicate;
- }));
- ASSERT_FALSE(anyOf(
- map(nonHexDigitChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_hex_digit(&utf8Letter, &predicate);
- return isPredicateStatus != ExtSuccess || predicate;
- }));
- ASSERT_FALSE(allOf(
- map(nonHexDigitChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_hex_digit(&utf8Letter, &predicate);
- return isPredicateStatus == ExtInvalidInput && !predicate;
- }));
+ ASSERT_FALSE(anyOf(nonHexDigitChars.span().takeOkay(), charIsHexDigit));
+
+ auto invalidAsciiChars = invalidAsciiGenerator();
+ ASSERT_FALSE(anyOf(invalidAsciiChars, charIsHexDigit));
+
+ ASSERT_FALSE(utf8IsHexDigit(FudUtf8{Ascii{invalidAscii}}));
+
+ SpanGenerator<char, hexDigitChars.size()> hexDigitGenerator{hexDigitChars.span()};
+ auto utf8HexDigitGenerator = [&]() { return hexDigitGenerator().map(toUtf8<uint16_t>); };
+ ASSERT_TRUE(allOf(utf8HexDigitGenerator, utf8IsHexDigit));
+
+ SpanGenerator<char> nonHexDigitGenerator{nonHexDigitChars.span().takeOkay()};
+ auto utf8NonHexDigitGenerator = [&]() { return nonHexDigitGenerator().map(toUtf8<uint16_t>); };
+ ASSERT_FALSE(anyOf(utf8NonHexDigitGenerator, utf8IsHexDigit));
}
TEST(Utf8Test, Utf8IsControl)
{
- auto controlChars = generateIndexArray<Array, char, numControlChars>([](int idx) { return static_cast<char>(idx); });
+ Iota<char> controlArrayGenerator{0, 1, numControlChars};
+ auto controlChars = generate([]() { return Array<char, numControlChars>{}; }, controlArrayGenerator);
constexpr const char deleteChar = 0x7F;
controlChars.back() = deleteChar;
- ASSERT_TRUE(allOf(controlChars, ext_lib_char_is_control));
-
- constexpr size_t numNonControlChars = 256 - numControlChars;
- auto nonControlChars = generateIndexArray<Array, char, numControlChars>([](int idx) {
- return static_cast<char>(idx + printableCharOffset);
- });
- ASSERT_FALSE(anyOf(nonControlChars, ext_lib_char_is_control));
-
- auto invalidAsciiChars = generateInvalidAsciiChars();
- ASSERT_FALSE(anyOf(invalidAsciiChars, ext_lib_char_is_control));
-
- ASSERT_TRUE(allOf(
- map(controlChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_control));
- ASSERT_FALSE(anyOf(
- map(nonControlChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_control));
- ASSERT_FALSE(anyOf(
- map(invalidAsciiChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_control));
-
- ASSERT_TRUE(allOf(
- map(controlChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_control));
- ASSERT_FALSE(anyOf(
- map(nonControlChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_control));
- ASSERT_FALSE(anyOf(
- map(invalidAsciiChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_control));
-
- Utf8 utf8{invalidAscii};
- bool isAscii = false;
- ASSERT_EQ(ext_lib_utf8_is_control(nullptr, nullptr), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_control(&utf8, nullptr), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_control(nullptr, &isAscii), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_control(&utf8, &isAscii), ExtInvalidInput);
- ASSERT_FALSE(isAscii);
-
- ASSERT_TRUE(allOf(
- map(controlChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_control(&utf8Letter, &predicate);
- return isPredicateStatus == ExtSuccess && predicate;
- }));
- ASSERT_FALSE(anyOf(
- map(nonControlChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_control(&utf8Letter, &predicate);
- return isPredicateStatus != ExtSuccess || predicate;
- }));
- ASSERT_FALSE(allOf(
- map(nonControlChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_control(&utf8Letter, &predicate);
- return isPredicateStatus == ExtInvalidInput && !predicate;
- }));
+ ASSERT_TRUE(allOf(controlChars.span(), charIsControl));
+
+ constexpr size_t numNonControlChars = INT8_MAX + 1 - numControlChars;
+ Vector<char> nonControlChars{};
+ ASSERT_EQ(nonControlChars.reserve(numNonControlChars), FudStatus::Success);
+ 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));
+
+ auto invalidAsciiChars = invalidAsciiGenerator();
+ ASSERT_FALSE(anyOf(invalidAsciiChars, charIsControl));
+
+ ASSERT_FALSE(utf8IsControl(FudUtf8{Ascii{invalidAscii}}));
+
+ SpanGenerator<char, controlChars.size()> controlGenerator{controlChars.span()};
+ auto utf8ControlGenerator = [&]() { return controlGenerator().map(toUtf8<uint16_t>); };
+ ASSERT_TRUE(allOf(utf8ControlGenerator, utf8IsControl));
+
+ SpanGenerator<char> nonControlGenerator{nonControlChars.span().takeOkay()};
+ auto utf8NonControlGenerator = [&]() { return nonControlGenerator().map(toUtf8<uint16_t>); };
+ ASSERT_FALSE(anyOf(utf8NonControlGenerator, utf8IsControl));
}
TEST(Utf8Test, Utf8IsGraphical)
@@ -773,311 +471,137 @@ TEST(Utf8Test, Utf8IsGraphical)
Array<char, numGraphicalChars> graphicalChars{};
copyMem<numGraphicalChars>(graphicalChars, graphicalCharLiteral);
- ASSERT_TRUE(allOf(graphicalChars, ext_lib_char_is_graphical));
-
- auto graphicalSetResult{StaticSet<char, numGraphicalChars>::makeFromArray(graphicalChars)};
- ASSERT_TRUE(graphicalSetResult.isOkay());
- auto graphicalSet{std::move(graphicalSetResult.getOkay())};
+ ASSERT_TRUE(allOf(graphicalChars.span(), charIsGraphical));
constexpr size_t numNonGraphicalChars = validAsciiSize - numGraphicalChars;
- FixedVector<char, numNonGraphicalChars> nonGraphicalChars{};
- for (char idx = 0; idx < INT8_MAX; ++idx) {
- if (!graphicalSet.isKey(idx)) {
- ASSERT_TRUE(nonGraphicalChars.pushBack(idx));
+ 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))) {
+ ASSERT_EQ(nonGraphicalChars.pushBack(static_cast<char>(idx)), FudStatus::Success);
}
}
- ASSERT_FALSE(anyOf(nonGraphicalChars, ext_lib_char_is_graphical));
-
- auto invalidAsciiChars = generateInvalidAsciiChars();
- ASSERT_FALSE(anyOf(invalidAsciiChars, ext_lib_char_is_graphical));
-
- ASSERT_TRUE(allOf(
- map(graphicalChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_graphical));
- ASSERT_FALSE(anyOf(
- map(nonGraphicalChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_graphical));
- ASSERT_FALSE(anyOf(
- map(invalidAsciiChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_graphical));
-
- ASSERT_TRUE(allOf(
- map(graphicalChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_graphical));
- ASSERT_FALSE(anyOf(
- map(nonGraphicalChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_graphical));
- ASSERT_FALSE(anyOf(
- map(invalidAsciiChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_graphical));
-
- Utf8 utf8{invalidAscii};
- bool isAscii = false;
- ASSERT_EQ(ext_lib_utf8_is_graphical(nullptr, nullptr), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_graphical(&utf8, nullptr), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_graphical(nullptr, &isAscii), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_graphical(&utf8, &isAscii), ExtInvalidInput);
- ASSERT_FALSE(isAscii);
-
- ASSERT_TRUE(allOf(
- map(graphicalChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_graphical(&utf8Letter, &predicate);
- return isPredicateStatus == ExtSuccess && predicate;
- }));
- ASSERT_FALSE(anyOf(
- map(nonGraphicalChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_graphical(&utf8Letter, &predicate);
- return isPredicateStatus != ExtSuccess || predicate;
- }));
- ASSERT_FALSE(allOf(
- map(nonGraphicalChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_graphical(&utf8Letter, &predicate);
- return isPredicateStatus == ExtInvalidInput && !predicate;
- }));
+ ASSERT_FALSE(anyOf(nonGraphicalChars.span().takeOkay(), charIsGraphical));
+ ASSERT_TRUE(allOf(nonGraphicalChars.span().takeOkay(), charIsAscii));
+ ASSERT_EQ(nonGraphicalChars.size() + graphicalChars.size(), INT8_MAX + 1);
+
+ auto invalidAsciiChars = invalidAsciiGenerator();
+ ASSERT_FALSE(anyOf(invalidAsciiChars, charIsGraphical));
+
+ ASSERT_FALSE(utf8IsGraphical(FudUtf8{Ascii{invalidAscii}}));
+
+ SpanGenerator<char, graphicalChars.size()> graphicalGenerator{graphicalChars.span()};
+ auto utf8GraphicalGenerator = [&]() { return graphicalGenerator().map(toUtf8<uint16_t>); };
+ ASSERT_TRUE(allOf(utf8GraphicalGenerator, utf8IsGraphical));
+
+ SpanGenerator<char> nonGraphicalGenerator{nonGraphicalChars.span().takeOkay()};
+ auto utf8NonGraphicalGenerator = [&]() { return nonGraphicalGenerator().map(toUtf8<uint16_t>); };
+ ASSERT_FALSE(anyOf(utf8NonGraphicalGenerator, utf8IsGraphical));
}
TEST(Utf8Test, Utf8IsSpace)
{
- constexpr size_t numSpaceChars = sizeof(" \t\v\r\n") - 1;
- Array<char, numSpaceChars + 1> spaceCharLiteral{" \t\v\r\n"};
+ constexpr size_t numSpaceChars = sizeof(SPACE_CHARS) - 1;
+ Array<char, numSpaceChars + 1> spaceCharLiteral{SPACE_CHARS};
Array<char, numSpaceChars> spaceChars{};
copyMem<numSpaceChars>(spaceChars, spaceCharLiteral);
- ASSERT_TRUE(allOf(spaceChars, ext_lib_char_is_space));
-
- auto spaceSetResult{StaticSet<char, numSpaceChars>::makeFromArray(spaceChars)};
- ASSERT_TRUE(spaceSetResult.isOkay());
- auto spaceSet{std::move(spaceSetResult.getOkay())};
+ ASSERT_TRUE(allOf(spaceChars.span(), charIsSpace));
constexpr size_t numNonSpaceChars = validAsciiSize - numSpaceChars;
- FixedVector<char, numNonSpaceChars> nonSpaceChars{};
- for (char idx = 0; idx < INT8_MAX; ++idx) {
- if (!spaceSet.isKey(idx)) {
- ASSERT_TRUE(nonSpaceChars.pushBack(idx));
+ 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))) {
+ ASSERT_EQ(nonSpaceChars.pushBack(static_cast<char>(idx)), FudStatus::Success);
}
}
- ASSERT_FALSE(anyOf(nonSpaceChars, ext_lib_char_is_space));
-
- auto invalidAsciiChars = generateInvalidAsciiChars();
- ASSERT_FALSE(anyOf(invalidAsciiChars, ext_lib_char_is_space));
-
- ASSERT_TRUE(allOf(
- map(spaceChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_space));
- ASSERT_FALSE(anyOf(
- map(nonSpaceChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_space));
- ASSERT_FALSE(anyOf(
- map(invalidAsciiChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_space));
-
- ASSERT_TRUE(allOf(
- map(spaceChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_space));
- ASSERT_FALSE(anyOf(
- map(nonSpaceChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_space));
- ASSERT_FALSE(anyOf(
- map(invalidAsciiChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_space));
-
- Utf8 utf8{invalidAscii};
- bool isAscii = false;
- ASSERT_EQ(ext_lib_utf8_is_space(nullptr, nullptr), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_space(&utf8, nullptr), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_space(nullptr, &isAscii), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_space(&utf8, &isAscii), ExtInvalidInput);
- ASSERT_FALSE(isAscii);
-
- ASSERT_TRUE(allOf(
- map(spaceChars, [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_space(&utf8Letter, &predicate);
- return isPredicateStatus == ExtSuccess && predicate;
- }));
- ASSERT_FALSE(anyOf(
- map(nonSpaceChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_space(&utf8Letter, &predicate);
- return isPredicateStatus != ExtSuccess || predicate;
- }));
- ASSERT_FALSE(allOf(
- map(nonSpaceChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_space(&utf8Letter, &predicate);
- return isPredicateStatus == ExtInvalidInput && !predicate;
- }));
+ ASSERT_FALSE(anyOf(nonSpaceChars.span().takeOkay(), charIsSpace));
+ ASSERT_TRUE(allOf(nonSpaceChars.span().takeOkay(), charIsAscii));
+ ASSERT_EQ(nonSpaceChars.size() + spaceChars.size(), INT8_MAX + 1);
+
+ auto invalidAsciiChars = invalidAsciiGenerator();
+ ASSERT_FALSE(anyOf(invalidAsciiChars, charIsSpace));
+
+ ASSERT_FALSE(utf8IsSpace(FudUtf8{Ascii{invalidAscii}}));
+
+ SpanGenerator<char, spaceChars.size()> spaceGenerator{spaceChars.span()};
+ auto utf8SpaceGenerator = [&]() { return spaceGenerator().map(toUtf8<uint16_t>); };
+ ASSERT_TRUE(allOf(utf8SpaceGenerator, utf8IsSpace));
+
+ SpanGenerator<char> nonSpaceGenerator{nonSpaceChars.span().takeOkay()};
+ auto utf8NonSpaceGenerator = [&]() { return nonSpaceGenerator().map(toUtf8<uint16_t>); };
+ ASSERT_FALSE(anyOf(utf8NonSpaceGenerator, utf8IsSpace));
}
TEST(Utf8Test, Utf8IsBlank)
{
- constexpr size_t numBlankChars = sizeof(" \t") - 1;
- Array<char, numBlankChars + 1> blankCharLiteral{" \t"};
+ constexpr size_t numBlankChars = sizeof(BLANK_CHARS) - 1;
+ Array<char, numBlankChars + 1> blankCharLiteral{BLANK_CHARS};
Array<char, numBlankChars> blankChars{};
copyMem<numBlankChars>(blankChars, blankCharLiteral);
- ASSERT_TRUE(allOf(blankChars, ext_lib_char_is_blank));
-
- auto blankSetResult{StaticSet<char, numBlankChars>::makeFromArray(blankChars)};
- ASSERT_TRUE(blankSetResult.isOkay());
- auto blankSet{std::move(blankSetResult.getOkay())};
+ ASSERT_TRUE(allOf(blankChars.span(), charIsBlank));
constexpr size_t numNonBlankChars = validAsciiSize - numBlankChars;
- FixedVector<char, numNonBlankChars> nonBlankChars{};
- for (char idx = 0; idx < INT8_MAX; ++idx) {
- if (!blankSet.isKey(idx)) {
- ASSERT_TRUE(nonBlankChars.pushBack(idx));
+ 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))) {
+ ASSERT_EQ(nonBlankChars.pushBack(static_cast<char>(idx)), FudStatus::Success);
}
}
- ASSERT_FALSE(anyOf(nonBlankChars, ext_lib_char_is_blank));
-
- auto invalidAsciiChars = generateInvalidAsciiChars();
- ASSERT_FALSE(anyOf(invalidAsciiChars, ext_lib_char_is_blank));
-
- ASSERT_TRUE(allOf(
- map(blankChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_blank));
- ASSERT_FALSE(anyOf(
- map(nonBlankChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_blank));
- ASSERT_FALSE(anyOf(
- map(invalidAsciiChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_blank));
-
- ASSERT_TRUE(allOf(
- map(blankChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_blank));
- ASSERT_FALSE(anyOf(
- map(nonBlankChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_blank));
- ASSERT_FALSE(anyOf(
- map(invalidAsciiChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_blank));
-
- Utf8 utf8{invalidAscii};
- bool isAscii = false;
- ASSERT_EQ(ext_lib_utf8_is_blank(nullptr, nullptr), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_blank(&utf8, nullptr), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_blank(nullptr, &isAscii), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_blank(&utf8, &isAscii), ExtInvalidInput);
- ASSERT_FALSE(isAscii);
-
- ASSERT_TRUE(allOf(
- map(blankChars, [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_blank(&utf8Letter, &predicate);
- return isPredicateStatus == ExtSuccess && predicate;
- }));
- ASSERT_FALSE(anyOf(
- map(nonBlankChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_blank(&utf8Letter, &predicate);
- return isPredicateStatus != ExtSuccess || predicate;
- }));
- ASSERT_FALSE(allOf(
- map(nonBlankChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_blank(&utf8Letter, &predicate);
- return isPredicateStatus == ExtInvalidInput && !predicate;
- }));
+ ASSERT_FALSE(anyOf(nonBlankChars.span().takeOkay(), charIsBlank));
+ ASSERT_TRUE(allOf(nonBlankChars.span().takeOkay(), charIsAscii));
+ ASSERT_EQ(nonBlankChars.size() + blankChars.size(), INT8_MAX + 1);
+
+ auto invalidAsciiChars = invalidAsciiGenerator();
+ ASSERT_FALSE(anyOf(invalidAsciiChars, charIsBlank));
+
+ ASSERT_FALSE(utf8IsBlank(FudUtf8{Ascii{invalidAscii}}));
+
+ SpanGenerator<char, blankChars.size()> blankGenerator{blankChars.span()};
+ auto utf8BlankGenerator = [&]() { return blankGenerator().map(toUtf8<uint16_t>); };
+ ASSERT_TRUE(allOf(utf8BlankGenerator, utf8IsBlank));
+
+ SpanGenerator<char> nonBlankGenerator{nonBlankChars.span().takeOkay()};
+ auto utf8NonBlankGenerator = [&]() { return nonBlankGenerator().map(toUtf8<uint16_t>); };
+ ASSERT_FALSE(anyOf(utf8NonBlankGenerator, utf8IsBlank));
}
TEST(Utf8Test, Utf8IsPrintable)
{
- constexpr size_t numPrintableChars = validAsciiSize - numControlChars;
- auto printableChars = generateIndexArray<Array, char, numPrintableChars>([](int idx) {
- return static_cast<char>(idx + printableCharOffset);
- });
-
- ASSERT_TRUE(allOf(printableChars, ext_lib_char_is_printable));
+ constexpr size_t numPrintableChars = sizeof(PRINTABLE_CHARS) - 1;
+ Array<char, numPrintableChars + 1> printableCharLiteral{PRINTABLE_CHARS};
+ Array<char, numPrintableChars> printableChars{};
+ copyMem<numPrintableChars>(printableChars, printableCharLiteral);
- auto printableSetResult{StaticSet<char, numPrintableChars>::makeFromArray(printableChars)};
- ASSERT_TRUE(printableSetResult.isOkay());
- auto printableSet{std::move(printableSetResult.getOkay())};
+ ASSERT_TRUE(allOf(printableChars.span(), charIsPrintable));
constexpr size_t numNonPrintableChars = validAsciiSize - numPrintableChars;
- FixedVector<char, numNonPrintableChars> nonPrintableChars{};
- for (char idx = 0; idx < INT8_MAX; ++idx) {
- if (!printableSet.isKey(idx)) {
- ASSERT_TRUE(nonPrintableChars.pushBack(idx));
+ 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))) {
+ ASSERT_EQ(nonPrintableChars.pushBack(static_cast<char>(idx)), FudStatus::Success);
}
}
- ASSERT_FALSE(anyOf(nonPrintableChars, ext_lib_char_is_printable));
-
- auto invalidAsciiChars = generateInvalidAsciiChars();
- ASSERT_FALSE(anyOf(invalidAsciiChars, ext_lib_char_is_printable));
-
- ASSERT_TRUE(allOf(
- map(printableChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_printable));
- ASSERT_FALSE(anyOf(
- map(nonPrintableChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_printable));
- ASSERT_FALSE(anyOf(
- map(invalidAsciiChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_printable));
-
- ASSERT_TRUE(allOf(
- map(printableChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_printable));
- ASSERT_FALSE(anyOf(
- map(nonPrintableChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_printable));
- ASSERT_FALSE(anyOf(
- map(invalidAsciiChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_printable));
-
- Utf8 utf8{invalidAscii};
- bool isAscii = false;
- ASSERT_EQ(ext_lib_utf8_is_printable(nullptr, nullptr), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_printable(&utf8, nullptr), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_printable(nullptr, &isAscii), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_printable(&utf8, &isAscii), ExtInvalidInput);
- ASSERT_FALSE(isAscii);
-
- ASSERT_TRUE(allOf(
- map(printableChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_printable(&utf8Letter, &predicate);
- return isPredicateStatus == ExtSuccess && predicate;
- }));
- ASSERT_FALSE(anyOf(
- map(nonPrintableChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_printable(&utf8Letter, &predicate);
- return isPredicateStatus != ExtSuccess || predicate;
- }));
- ASSERT_FALSE(allOf(
- map(nonPrintableChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_printable(&utf8Letter, &predicate);
- return isPredicateStatus == ExtInvalidInput && !predicate;
- }));
+ ASSERT_FALSE(anyOf(nonPrintableChars.span().takeOkay(), charIsPrintable));
+ ASSERT_TRUE(allOf(nonPrintableChars.span().takeOkay(), charIsAscii));
+ ASSERT_EQ(nonPrintableChars.size() + printableChars.size(), INT8_MAX + 1);
+
+ auto invalidAsciiChars = invalidAsciiGenerator();
+ ASSERT_FALSE(anyOf(invalidAsciiChars, charIsPrintable));
+
+ ASSERT_FALSE(utf8IsPrintable(FudUtf8{Ascii{invalidAscii}}));
+
+ SpanGenerator<char, printableChars.size()> printableGenerator{printableChars.span()};
+ auto utf8PrintableGenerator = [&]() { return printableGenerator().map(toUtf8<uint16_t>); };
+ ASSERT_TRUE(allOf(utf8PrintableGenerator, utf8IsPrintable));
+
+ SpanGenerator<char> nonPrintableGenerator{nonPrintableChars.span().takeOkay()};
+ auto utf8NonPrintableGenerator = [&]() { return nonPrintableGenerator().map(toUtf8<uint16_t>); };
+ ASSERT_FALSE(anyOf(utf8NonPrintableGenerator, utf8IsPrintable));
}
TEST(Utf8Test, Utf8IsPunctuation)
@@ -1087,77 +611,32 @@ TEST(Utf8Test, Utf8IsPunctuation)
Array<char, numPunctuationChars> punctuationChars{};
copyMem<numPunctuationChars>(punctuationChars, punctuationCharLiteral);
- ASSERT_TRUE(allOf(punctuationChars, ext_lib_char_is_punctuation));
-
- auto punctuationSetResult{StaticSet<char, numPunctuationChars>::makeFromArray(punctuationChars)};
- ASSERT_TRUE(punctuationSetResult.isOkay());
- auto punctuationSet{std::move(punctuationSetResult.getOkay())};
+ ASSERT_TRUE(allOf(punctuationChars.span(), charIsPunctuation));
constexpr size_t numNonPunctuationChars = validAsciiSize - numPunctuationChars;
- FixedVector<char, numNonPunctuationChars> nonPunctuationChars{};
- for (char idx = 0; idx < INT8_MAX; ++idx) {
- if (!punctuationSet.isKey(idx)) {
- ASSERT_TRUE(nonPunctuationChars.pushBack(idx));
+ 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))) {
+ ASSERT_EQ(nonPunctuationChars.pushBack(static_cast<char>(idx)), FudStatus::Success);
}
}
- ASSERT_FALSE(anyOf(nonPunctuationChars, ext_lib_char_is_punctuation));
-
- auto invalidAsciiChars = generateInvalidAsciiChars();
- ASSERT_FALSE(anyOf(invalidAsciiChars, ext_lib_char_is_punctuation));
-
- ASSERT_TRUE(allOf(
- map(punctuationChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_punctuation));
- ASSERT_FALSE(anyOf(
- map(nonPunctuationChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_punctuation));
- ASSERT_FALSE(anyOf(
- map(invalidAsciiChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_punctuation));
-
- ASSERT_TRUE(allOf(
- map(punctuationChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_punctuation));
- ASSERT_FALSE(anyOf(
- map(nonPunctuationChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_punctuation));
- ASSERT_FALSE(anyOf(
- map(invalidAsciiChars, [](auto input) { return ExtUtf8Char4{static_cast<utf8>(input)}; }),
- ext_lib_char4_is_punctuation));
-
- Utf8 utf8{invalidAscii};
- bool isAscii = false;
- ASSERT_EQ(ext_lib_utf8_is_punctuation(nullptr, nullptr), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_punctuation(&utf8, nullptr), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_punctuation(nullptr, &isAscii), ExtNullPointer);
- ASSERT_EQ(ext_lib_utf8_is_punctuation(&utf8, &isAscii), ExtInvalidInput);
- ASSERT_FALSE(isAscii);
-
- ASSERT_TRUE(allOf(
- map(punctuationChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_punctuation(&utf8Letter, &predicate);
- return isPredicateStatus == ExtSuccess && predicate;
- }));
- ASSERT_FALSE(anyOf(
- map(nonPunctuationChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_punctuation(&utf8Letter, &predicate);
- return isPredicateStatus != ExtSuccess || predicate;
- }));
- ASSERT_FALSE(allOf(
- map(nonPunctuationChars,
- [](char letter) { return FudUtf8::makeUtf8(ExtUtf8Char4{static_cast<utf8>(letter)}); }),
- [](auto& utf8Letter) {
- bool predicate = false;
- auto isPredicateStatus = ext_lib_utf8_is_punctuation(&utf8Letter, &predicate);
- return isPredicateStatus == ExtInvalidInput && !predicate;
- }));
+ ASSERT_FALSE(anyOf(nonPunctuationChars.span().takeOkay(), charIsPunctuation));
+ ASSERT_TRUE(allOf(nonPunctuationChars.span().takeOkay(), charIsAscii));
+ ASSERT_EQ(nonPunctuationChars.size() + punctuationChars.size(), INT8_MAX + 1);
+
+ auto invalidAsciiChars = invalidAsciiGenerator();
+ ASSERT_FALSE(anyOf(invalidAsciiChars, charIsPunctuation));
+
+ ASSERT_FALSE(utf8IsPunctuation(FudUtf8{Ascii{invalidAscii}}));
+
+ SpanGenerator<char, punctuationChars.size()> punctuationGenerator{punctuationChars.span()};
+ auto utf8PunctuationGenerator = [&]() { return punctuationGenerator().map(toUtf8<uint16_t>); };
+ ASSERT_TRUE(allOf(utf8PunctuationGenerator, utf8IsPunctuation));
+
+ SpanGenerator<char> nonPunctuationGenerator{nonPunctuationChars.span().takeOkay()};
+ auto utf8NonPunctuationGenerator = [&]() { return nonPunctuationGenerator().map(toUtf8<uint16_t>); };
+ ASSERT_FALSE(anyOf(utf8NonPunctuationGenerator, utf8IsPunctuation));
}
-#endif
} // namespace fud