mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 12:49:19 +00:00
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.
This commit is contained in:
parent
d8044c5358
commit
1edb96376b
Notes:
sideshowbarker
2024-07-17 18:46:30 +09:00
Author: https://github.com/trflynn89
Commit: 1edb96376b
Pull-request: https://github.com/SerenityOS/serenity/pull/16895
Reviewed-by: https://github.com/linusg
13 changed files with 46 additions and 35 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue