diff options
author | Timothy Flynn <trflynn89@pm.me> | 2023-01-06 13:19:34 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-01-08 12:13:15 +0100 |
commit | 1edb96376b51519fe9a7aff2d281f243ca19fd45 (patch) | |
tree | 6c1cafa408e6640a02f64d1c626c796a42bc95ea /Tests | |
parent | d8044c5358ab8440286f39c3d1efe2c5f39bc115 (diff) | |
download | serenity-1edb96376b51519fe9a7aff2d281f243ca19fd45.zip |
AK+Everywhere: Make UTF-8 and UTF-32 to UTF-16 converters fallible
These could fail to allocate the underlying storage needed to store the
UTF-16 data. Propagate these errors.
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/AK/TestUtf16.cpp | 10 | ||||
-rw-r--r-- | Tests/LibRegex/Regex.cpp | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/Tests/AK/TestUtf16.cpp b/Tests/AK/TestUtf16.cpp index ee21a72319..56b2057e17 100644 --- a/Tests/AK/TestUtf16.cpp +++ b/Tests/AK/TestUtf16.cpp @@ -14,7 +14,7 @@ TEST_CASE(decode_ascii) { - auto string = AK::utf8_to_utf16("Hello World!11"sv); + auto string = MUST(AK::utf8_to_utf16("Hello World!11"sv)); Utf16View view { string }; size_t valid_code_units = 0; @@ -33,7 +33,7 @@ TEST_CASE(decode_ascii) TEST_CASE(decode_utf8) { - auto string = AK::utf8_to_utf16("Привет, мир! 😀 γειά σου κόσμος こんにちは世界"sv); + auto string = MUST(AK::utf8_to_utf16("Привет, мир! 😀 γειά σου κόσμος こんにちは世界"sv)); Utf16View view { string }; size_t valid_code_units = 0; @@ -54,7 +54,7 @@ TEST_CASE(encode_utf8) { { DeprecatedString utf8_string("Привет, мир! 😀 γειά σου κόσμος こんにちは世界"); - auto string = AK::utf8_to_utf16(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); @@ -91,7 +91,7 @@ TEST_CASE(decode_utf16) TEST_CASE(iterate_utf16) { - auto string = AK::utf8_to_utf16("Привет 😀"sv); + auto string = MUST(AK::utf8_to_utf16("Привет 😀"sv)); Utf16View view { string }; auto iterator = view.begin(); @@ -263,7 +263,7 @@ TEST_CASE(decode_invalid_utf16) TEST_CASE(substring_view) { - auto string = AK::utf8_to_utf16("Привет 😀"sv); + auto string = MUST(AK::utf8_to_utf16("Привет 😀"sv)); { Utf16View view { string }; view = view.substring_view(7, 2); diff --git a/Tests/LibRegex/Regex.cpp b/Tests/LibRegex/Regex.cpp index 366b414819..0e6281bdb1 100644 --- a/Tests/LibRegex/Regex.cpp +++ b/Tests/LibRegex/Regex.cpp @@ -754,7 +754,7 @@ TEST_CASE(ECMA262_unicode_match) for (auto& test : tests) { Regex<ECMA262> re(test.pattern, (ECMAScriptFlags)regex::AllFlags::Global | test.options); - auto subject = AK::utf8_to_utf16(test.subject); + auto subject = MUST(AK::utf8_to_utf16(test.subject)); Utf16View view { subject }; if constexpr (REGEX_DEBUG) { @@ -868,7 +868,7 @@ TEST_CASE(ECMA262_property_match) for (auto& test : tests) { Regex<ECMA262> re(test.pattern, (ECMAScriptFlags)regex::AllFlags::Global | regex::ECMAScriptFlags::BrowserExtended | test.options); - auto subject = AK::utf8_to_utf16(test.subject); + auto subject = MUST(AK::utf8_to_utf16(test.subject)); Utf16View view { subject }; if constexpr (REGEX_DEBUG) { |