summaryrefslogtreecommitdiff
path: root/Tests/AK/TestUtf16.cpp
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2023-01-07 13:59:10 -0500
committerLinus Groh <mail@linusgroh.de>2023-01-08 12:13:15 +0100
commitd793262beba3a113bed4c728b572a78583b43277 (patch)
treee30bd93b43361cc563406dcd934e95f264d24bc9 /Tests/AK/TestUtf16.cpp
parent1edb96376b51519fe9a7aff2d281f243ca19fd45 (diff)
downloadserenity-d793262beba3a113bed4c728b572a78583b43277.zip
AK+Everywhere: Make UTF-16 to UTF-8 converter fallible
This could fail to allocate the underlying storage needed to store the UTF-8 data. Propagate this error.
Diffstat (limited to 'Tests/AK/TestUtf16.cpp')
-rw-r--r--Tests/AK/TestUtf16.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/Tests/AK/TestUtf16.cpp b/Tests/AK/TestUtf16.cpp
index 56b2057e17..174c959e7a 100644
--- a/Tests/AK/TestUtf16.cpp
+++ b/Tests/AK/TestUtf16.cpp
@@ -56,14 +56,14 @@ TEST_CASE(encode_utf8)
DeprecatedString utf8_string("Привет, мир! 😀 γειά σου κόσμος こんにちは世界");
auto string = MUST(AK::utf8_to_utf16(utf8_string));
Utf16View view { string };
- EXPECT_EQ(view.to_utf8(Utf16View::AllowInvalidCodeUnits::Yes), utf8_string);
- EXPECT_EQ(view.to_utf8(Utf16View::AllowInvalidCodeUnits::No), utf8_string);
+ EXPECT_EQ(MUST(view.to_utf8(Utf16View::AllowInvalidCodeUnits::Yes)), utf8_string);
+ EXPECT_EQ(MUST(view.to_utf8(Utf16View::AllowInvalidCodeUnits::No)), utf8_string);
}
{
auto encoded = Array { (u16)0xd83d };
Utf16View view { encoded };
- EXPECT_EQ(view.to_utf8(Utf16View::AllowInvalidCodeUnits::Yes), "\xed\xa0\xbd"sv);
- EXPECT_EQ(view.to_utf8(Utf16View::AllowInvalidCodeUnits::No), "\ufffd"sv);
+ EXPECT_EQ(MUST(view.to_utf8(Utf16View::AllowInvalidCodeUnits::Yes)), "\xed\xa0\xbd"sv);
+ EXPECT_EQ(MUST(view.to_utf8(Utf16View::AllowInvalidCodeUnits::No)), "\ufffd"sv);
}
}
@@ -269,14 +269,14 @@ TEST_CASE(substring_view)
view = view.substring_view(7, 2);
EXPECT(view.length_in_code_units() == 2);
- EXPECT_EQ(view.to_utf8(), "😀"sv);
+ EXPECT_EQ(MUST(view.to_utf8()), "😀"sv);
}
{
Utf16View view { string };
view = view.substring_view(7, 1);
EXPECT(view.length_in_code_units() == 1);
- EXPECT_EQ(view.to_utf8(Utf16View::AllowInvalidCodeUnits::Yes), "\xed\xa0\xbd"sv);
- EXPECT_EQ(view.to_utf8(Utf16View::AllowInvalidCodeUnits::No), "\ufffd"sv);
+ EXPECT_EQ(MUST(view.to_utf8(Utf16View::AllowInvalidCodeUnits::Yes)), "\xed\xa0\xbd"sv);
+ EXPECT_EQ(MUST(view.to_utf8(Utf16View::AllowInvalidCodeUnits::No)), "\ufffd"sv);
}
}