diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2023-02-17 20:15:10 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-02-19 17:15:47 +0100 |
commit | 2db168acc112e8f032d57f8225a8122c0e7f4207 (patch) | |
tree | add8e7858b1fe3861624a8392703d6172e4fe30c /Tests | |
parent | 3c5090e17257667514156900a552d875b46da27d (diff) | |
download | serenity-2db168acc112e8f032d57f8225a8122c0e7f4207.zip |
LibTextCodec+Everywhere: Port Decoders to new Strings
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/LibTextCodec/TestTextDecoders.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/Tests/LibTextCodec/TestTextDecoders.cpp b/Tests/LibTextCodec/TestTextDecoders.cpp index fe873bf7ff..d1658d337c 100644 --- a/Tests/LibTextCodec/TestTextDecoders.cpp +++ b/Tests/LibTextCodec/TestTextDecoders.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include <AK/String.h> #include <AK/Vector.h> #include <LibTest/TestCase.h> #include <LibTextCodec/Decoder.h> @@ -15,13 +16,13 @@ TEST_CASE(test_utf8_decode) auto test_string = "\xf0\x9f\x98\x80"sv; Vector<u32> processed_code_points; - decoder.process(test_string, [&](u32 code_point) { - processed_code_points.append(code_point); - }); + MUST(decoder.process(test_string, [&](u32 code_point) { + return processed_code_points.try_append(code_point); + })); EXPECT(processed_code_points.size() == 1); EXPECT(processed_code_points[0] == 0x1F600); - EXPECT(decoder.to_utf8(test_string) == test_string); + EXPECT(MUST(decoder.to_utf8(test_string)) == test_string); } TEST_CASE(test_utf16be_decode) @@ -31,9 +32,9 @@ TEST_CASE(test_utf16be_decode) auto test_string = "\x00s\x00\xe4\x00k\xd8=\xde\x00"sv; Vector<u32> processed_code_points; - decoder.process(test_string, [&](u32 code_point) { - processed_code_points.append(code_point); - }); + MUST(decoder.process(test_string, [&](u32 code_point) { + return processed_code_points.try_append(code_point); + })); EXPECT(processed_code_points.size() == 4); EXPECT(processed_code_points[0] == 0x73); EXPECT(processed_code_points[1] == 0xE4); @@ -48,9 +49,9 @@ TEST_CASE(test_utf16le_decode) auto test_string = "s\x00\xe4\x00k\x00=\xd8\x00\xde"sv; Vector<u32> processed_code_points; - decoder.process(test_string, [&](u32 code_point) { - processed_code_points.append(code_point); - }); + MUST(decoder.process(test_string, [&](u32 code_point) { + return processed_code_points.try_append(code_point); + })); EXPECT(processed_code_points.size() == 4); EXPECT(processed_code_points[0] == 0x73); EXPECT(processed_code_points[1] == 0xE4); |