summaryrefslogtreecommitdiff
path: root/test/test_utf8.cpp
diff options
context:
space:
mode:
authorDominick Allen <djallen@librehumanitas.org>2024-11-03 13:04:00 -0600
committerDominick Allen <djallen@librehumanitas.org>2024-11-03 13:04:00 -0600
commit1e89700693e92bb9c78ace739c71431b74d91e22 (patch)
tree08d40bf1c650987fac55805ce4b930a19c065fec /test/test_utf8.cpp
parent9b4b87765d48d2d6aed6ac1f40c4aa2684fad766 (diff)
Rename FudUtf8 to Utf8.
Diffstat (limited to 'test/test_utf8.cpp')
-rw-r--r--test/test_utf8.cpp82
1 files changed, 41 insertions, 41 deletions
diff --git a/test/test_utf8.cpp b/test/test_utf8.cpp
index e5cb89a..a8e4969 100644
--- a/test/test_utf8.cpp
+++ b/test/test_utf8.cpp
@@ -65,7 +65,7 @@ constexpr size_t invalidAsciiSize = UINT8_MAX + 1 - validAsciiSize;
constexpr size_t numControlChars = 33;
constexpr char printableCharOffset = 0x20;
-constexpr auto invalidAscii = FudUtf8::invalidAsciiCode.character();
+constexpr auto invalidAscii = Utf8::invalidAsciiCode.character();
auto invalidAsciiGenerator()
{
@@ -75,7 +75,7 @@ auto invalidAsciiGenerator()
template <typename T>
auto toUtf8(T letter)
{
- return FudUtf8::make(static_cast<utf8>(letter));
+ return Utf8::make(static_cast<utf8>(letter));
}
template <typename T>
@@ -88,18 +88,18 @@ TEST(Utf8Test, Utf8Creation)
{
const Array<utf8, 4> threeByte = {THREE_BYTE};
- FudUtf8 utf8Point{FudUtf8::make(threeByte)};
+ Utf8 utf8Point{Utf8::make(threeByte)};
ASSERT_NE(utf8Point.data(), nullptr);
ASSERT_EQ(utf8Point.size(), 3);
ASSERT_NE(utf8Point.hash(), -1);
const Array<utf8, 4> asciiLetter = {'A'};
- utf8Point = FudUtf8::make(asciiLetter);
+ utf8Point = Utf8::make(asciiLetter);
ASSERT_NE(utf8Point.data(), nullptr);
ASSERT_EQ(utf8Point.size(), 1);
const Array<utf8, 4> twoByte = {TWO_BYTE};
- utf8Point = FudUtf8::make(twoByte);
+ utf8Point = Utf8::make(twoByte);
ASSERT_NE(utf8Point.data(), nullptr);
ASSERT_EQ(utf8Point.size(), 2);
ASSERT_NE(utf8Point.hash(), -1);
@@ -109,13 +109,13 @@ TEST(Utf8Test, Utf8Creation)
static_cast<utf8>(FOUR_BYTE[1]),
static_cast<utf8>(FOUR_BYTE[2]),
static_cast<utf8>(FOUR_BYTE[3])};
- utf8Point = FudUtf8::make(fourByte);
+ utf8Point = Utf8::make(fourByte);
ASSERT_NE(utf8Point.data(), nullptr);
ASSERT_EQ(utf8Point.size(), 4);
ASSERT_NE(utf8Point.hash(), -1);
const Array<utf8, 4> invalidBytes = {0xFF, 0xFF, 0xFF, 0xFF};
- utf8Point = FudUtf8::make(invalidBytes);
+ utf8Point = Utf8::make(invalidBytes);
ASSERT_EQ(utf8Point.data(), nullptr);
ASSERT_EQ(utf8Point.size(), 0);
ASSERT_EQ(utf8Point.hash(), -1);
@@ -174,29 +174,29 @@ TEST(Utf8Test, Utf8MultiByte)
ASSERT_TRUE(characterOpt.hasValue());
// MULTI_BYTE_LITERAL "test今日素敵はですねƩ®😀z"
- const Array<FudUtf8, 16> multiByteCharacters{
- FudUtf8::make(Utf8Variant{Ascii{'t'}}),
- FudUtf8::make(Utf8Variant{Ascii{'e'}}),
- FudUtf8::make(Utf8Variant{Ascii{'s'}}),
- FudUtf8::make(Utf8Variant{Ascii{'t'}}),
- FudUtf8::from(StringView{sizeof("今"), "今"}, 0),
- FudUtf8::from(StringView{sizeof("日"), "日"}, 0),
- FudUtf8::from(StringView{sizeof("素"), "素"}, 0),
- FudUtf8::from(StringView{sizeof("敵"), "敵"}, 0),
- FudUtf8::from(StringView{sizeof("は"), "は"}, 0),
- FudUtf8::from(StringView{sizeof("で"), "で"}, 0),
- FudUtf8::from(StringView{sizeof("す"), "す"}, 0),
- FudUtf8::from(StringView{sizeof("ね"), "ね"}, 0),
- FudUtf8::from(StringView{sizeof("Ʃ"), "Ʃ"}, 0),
- FudUtf8::from(StringView{sizeof("®"), "®"}, 0),
- FudUtf8::from(StringView{sizeof("😀"), "😀"}, 0),
- FudUtf8::make(Utf8Variant{Ascii{'z'}}),
+ const Array<Utf8, 16> multiByteCharacters{
+ Utf8::make(Utf8Variant{Ascii{'t'}}),
+ Utf8::make(Utf8Variant{Ascii{'e'}}),
+ Utf8::make(Utf8Variant{Ascii{'s'}}),
+ Utf8::make(Utf8Variant{Ascii{'t'}}),
+ Utf8::from(StringView{sizeof("今"), "今"}, 0),
+ Utf8::from(StringView{sizeof("日"), "日"}, 0),
+ Utf8::from(StringView{sizeof("素"), "素"}, 0),
+ Utf8::from(StringView{sizeof("敵"), "敵"}, 0),
+ Utf8::from(StringView{sizeof("は"), "は"}, 0),
+ Utf8::from(StringView{sizeof("で"), "で"}, 0),
+ Utf8::from(StringView{sizeof("す"), "す"}, 0),
+ Utf8::from(StringView{sizeof("ね"), "ね"}, 0),
+ Utf8::from(StringView{sizeof("Ʃ"), "Ʃ"}, 0),
+ Utf8::from(StringView{sizeof("®"), "®"}, 0),
+ Utf8::from(StringView{sizeof("😀"), "😀"}, 0),
+ Utf8::make(Utf8Variant{Ascii{'z'}}),
};
size_t idx = 0;
while (characterOpt.hasValue()) {
auto character = characterOpt.value();
- if (character != FudUtf8{Utf8Variant{Ascii{'\0'}}}) {
+ if (character != Utf8{Utf8Variant{Ascii{'\0'}}}) {
EXPECT_TRUE(character.size() >= 1);
ASSERT_LT(idx, multiByteCharacters.size());
EXPECT_EQ(character.size(), multiByteCharacters[idx].size());
@@ -209,7 +209,7 @@ TEST(Utf8Test, Utf8MultiByte)
utf8Iter.reset();
ASSERT_TRUE(utf8Iter.next().hasValue());
- FudUtf8 invalid = FudUtf8::invalidAscii();
+ Utf8 invalid = Utf8::invalidAscii();
ASSERT_FALSE(invalid.valid());
ASSERT_EQ(invalid.size(), 0);
ASSERT_EQ(invalid.data(), nullptr);
@@ -228,14 +228,14 @@ TEST(Utf8Test, Utf8IsAscii)
ASSERT_FALSE(anyOf([&]() -> Option<char> { return invalidCharIota().map(toLetter<int16_t>); }, static_cast<CharPredicate>(isAscii)));
- FudUtf8 unicode{FudUtf8::invalidAscii()};
+ Utf8 unicode{Utf8::invalidAscii()};
ASSERT_FALSE(isAscii(unicode));
charIota.set(0);
- ASSERT_TRUE(allOf([&]() -> Option<FudUtf8> { return charIota().map(toUtf8<int16_t>); }, static_cast<FudUtf8Predicate>(isAscii)));
+ ASSERT_TRUE(allOf([&]() -> Option<Utf8> { return charIota().map(toUtf8<int16_t>); }, static_cast<FudUtf8Predicate>(isAscii)));
invalidCharIota.set(invalidAsciiSize);
- ASSERT_FALSE(anyOf([&]() -> Option<FudUtf8> { return invalidCharIota().map(toUtf8<int16_t>); }, static_cast<FudUtf8Predicate>(isAscii)));
+ ASSERT_FALSE(anyOf([&]() -> Option<Utf8> { return invalidCharIota().map(toUtf8<int16_t>); }, static_cast<FudUtf8Predicate>(isAscii)));
}
template <typename T, size_t Size = SIZE_MAX>
@@ -280,7 +280,7 @@ TEST(Utf8Test, Utf8IsAlphanumeric)
auto invalidAsciiChars = invalidAsciiGenerator();
ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast<CharPredicate>(isAlphanumeric)));
- ASSERT_FALSE(isAlphanumeric(FudUtf8{Ascii{invalidAscii}}));
+ ASSERT_FALSE(isAlphanumeric(Utf8{Ascii{invalidAscii}}));
auto iotaGenerator = invalidAsciiGenerator();
auto generator = generate(
@@ -317,7 +317,7 @@ TEST(Utf8Test, Utf8IsAlpha)
auto invalidAsciiChars = invalidAsciiGenerator();
ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast<CharPredicate>(isAlpha)));
- ASSERT_FALSE(isAlpha(FudUtf8{Ascii{invalidAscii}}));
+ ASSERT_FALSE(isAlpha(Utf8{Ascii{invalidAscii}}));
SpanGenerator<utf8, alphaChars.size()> alphaGenerator{alphaChars.span()};
auto utf8AlphaGenerator = [&]() { return alphaGenerator().map(toUtf8<uint16_t>); };
@@ -349,7 +349,7 @@ TEST(Utf8Test, Utf8IsLower)
auto invalidAsciiChars = invalidAsciiGenerator();
ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast<CharPredicate>(isLowercase)));
- ASSERT_FALSE(isLowercase(FudUtf8{Ascii{invalidAscii}}));
+ ASSERT_FALSE(isLowercase(Utf8{Ascii{invalidAscii}}));
SpanGenerator<utf8, lowerChars.size()> lowerGenerator{lowerChars.span()};
auto utf8LowerGenerator = [&]() { return lowerGenerator().map(toUtf8<uint16_t>); };
@@ -381,7 +381,7 @@ TEST(Utf8Test, Utf8IsUpper)
auto invalidAsciiChars = invalidAsciiGenerator();
ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast<CharPredicate>(isUppercase)));
- ASSERT_FALSE(isUppercase(FudUtf8{Ascii{invalidAscii}}));
+ ASSERT_FALSE(isUppercase(Utf8{Ascii{invalidAscii}}));
SpanGenerator<utf8, upperChars.size()> upperGenerator{upperChars.span()};
auto utf8UpperGenerator = [&]() { return upperGenerator().map(toUtf8<uint16_t>); };
@@ -413,7 +413,7 @@ TEST(Utf8Test, Utf8IsDigit)
auto invalidAsciiChars = invalidAsciiGenerator();
ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast<CharPredicate>(isDigit)));
- ASSERT_FALSE(isDigit(FudUtf8{Ascii{invalidAscii}}));
+ ASSERT_FALSE(isDigit(Utf8{Ascii{invalidAscii}}));
SpanGenerator<utf8, digitChars.size()> digitGenerator{digitChars.span()};
auto utf8DigitGenerator = [&]() { return digitGenerator().map(toUtf8<uint16_t>); };
@@ -445,7 +445,7 @@ TEST(Utf8Test, Utf8IsHexDigit)
auto invalidAsciiChars = invalidAsciiGenerator();
ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast<CharPredicate>(isHexDigit)));
- ASSERT_FALSE(isHexDigit(FudUtf8{Ascii{invalidAscii}}));
+ ASSERT_FALSE(isHexDigit(Utf8{Ascii{invalidAscii}}));
SpanGenerator<utf8, hexDigitChars.size()> hexDigitGenerator{hexDigitChars.span()};
auto utf8HexDigitGenerator = [&]() { return hexDigitGenerator().map(toUtf8<uint16_t>); };
@@ -477,7 +477,7 @@ TEST(Utf8Test, Utf8IsControl)
auto invalidAsciiChars = invalidAsciiGenerator();
ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast<CharPredicate>(isControl)));
- ASSERT_FALSE(isControl(FudUtf8{Ascii{invalidAscii}}));
+ ASSERT_FALSE(isControl(Utf8{Ascii{invalidAscii}}));
SpanGenerator<utf8, controlChars.size()> controlGenerator{controlChars.span()};
auto utf8ControlGenerator = [&]() { return controlGenerator().map(toUtf8<uint16_t>); };
@@ -512,7 +512,7 @@ TEST(Utf8Test, Utf8IsGraphical)
auto invalidAsciiChars = invalidAsciiGenerator();
ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast<CharPredicate>(isGraphical)));
- ASSERT_FALSE(isGraphical(FudUtf8{Ascii{invalidAscii}}));
+ ASSERT_FALSE(isGraphical(Utf8{Ascii{invalidAscii}}));
SpanGenerator<utf8, graphicalChars.size()> graphicalGenerator{graphicalChars.span()};
auto utf8GraphicalGenerator = [&]() { return graphicalGenerator().map(toUtf8<uint16_t>); };
@@ -547,7 +547,7 @@ TEST(Utf8Test, Utf8IsSpace)
auto invalidAsciiChars = invalidAsciiGenerator();
ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast<CharPredicate>(isSpace)));
- ASSERT_FALSE(isSpace(FudUtf8{Ascii{invalidAscii}}));
+ ASSERT_FALSE(isSpace(Utf8{Ascii{invalidAscii}}));
SpanGenerator<utf8, spaceChars.size()> spaceGenerator{spaceChars.span()};
auto utf8SpaceGenerator = [&]() { return spaceGenerator().map(toUtf8<uint16_t>); };
@@ -582,7 +582,7 @@ TEST(Utf8Test, Utf8IsBlank)
auto invalidAsciiChars = invalidAsciiGenerator();
ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast<CharPredicate>(isBlank)));
- ASSERT_FALSE(isBlank(FudUtf8{Ascii{invalidAscii}}));
+ ASSERT_FALSE(isBlank(Utf8{Ascii{invalidAscii}}));
SpanGenerator<utf8, blankChars.size()> blankGenerator{blankChars.span()};
auto utf8BlankGenerator = [&]() { return blankGenerator().map(toUtf8<uint16_t>); };
@@ -617,7 +617,7 @@ TEST(Utf8Test, Utf8IsPrintable)
auto invalidAsciiChars = invalidAsciiGenerator();
ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast<CharPredicate>(isPrintable)));
- ASSERT_FALSE(isPrintable(FudUtf8{Ascii{invalidAscii}}));
+ ASSERT_FALSE(isPrintable(Utf8{Ascii{invalidAscii}}));
SpanGenerator<utf8, printableChars.size()> printableGenerator{printableChars.span()};
auto utf8PrintableGenerator = [&]() { return printableGenerator().map(toUtf8<uint16_t>); };
@@ -652,7 +652,7 @@ TEST(Utf8Test, Utf8IsPunctuation)
auto invalidAsciiChars = invalidAsciiGenerator();
ASSERT_FALSE(anyOf(invalidAsciiChars, static_cast<CharPredicate>(isPunctuation)));
- ASSERT_FALSE(isPunctuation(FudUtf8{Ascii{invalidAscii}}));
+ ASSERT_FALSE(isPunctuation(Utf8{Ascii{invalidAscii}}));
SpanGenerator<utf8, punctuationChars.size()> punctuationGenerator{punctuationChars.span()};
auto utf8PunctuationGenerator = [&]() { return punctuationGenerator().map(toUtf8<uint16_t>); };