AK: Explicitly check for null data in Utf8View

The underlying CPU-specific instructions for operating on UTF-8 strings
behave differently for null inputs. Add an explicit check for this state
for consistency.
This commit is contained in:
Timothy Flynn 2024-07-21 07:48:27 -04:00 committed by Andreas Kling
commit 144452d638
Notes: github-actions[bot] 2024-07-21 17:58:05 +00:00
2 changed files with 22 additions and 0 deletions

View file

@ -48,6 +48,18 @@ TEST_CASE(decode_utf8)
EXPECT_EQ(i, expected_size);
}
TEST_CASE(null_view)
{
Utf8View view;
EXPECT(view.validate(Utf8View::AllowSurrogates::No));
EXPECT(view.validate(Utf8View::AllowSurrogates::Yes));
EXPECT_EQ(view.byte_length(), 0zu);
EXPECT_EQ(view.length(), 0zu);
for ([[maybe_unused]] auto it : view)
FAIL("Iterating a null UTF-8 string should not produce any values");
}
TEST_CASE(validate_invalid_ut8)
{
size_t valid_bytes;