AK: Add a Utf16View method to retrieve an iterator at a code unit offset

This commit is contained in:
Timothy Flynn 2025-08-06 07:15:46 -04:00 committed by Jelle Raaijmakers
parent 4aa355658f
commit bbda6d13f7
Notes: github-actions[bot] 2025-08-07 00:07:51 +00:00
2 changed files with 21 additions and 0 deletions

View file

@ -571,6 +571,18 @@ TEST_CASE(iterator_offset)
EXPECT_EQ(view.iterator_offset(view.end()), view.length_in_code_units());
}
TEST_CASE(iterator_at_code_unit_offset)
{
Utf16View view { u"😂 foo 😀 bar"sv };
for (size_t i = 0; i < view.length_in_code_units(); ++i) {
auto it = view.iterator_at_code_unit_offset(i);
EXPECT_EQ(*it, view.code_point_at(i));
}
EXPECT_EQ(view.iterator_at_code_unit_offset(view.length_in_code_units()), view.end());
}
TEST_CASE(replace)
{
auto result = u""sv.replace({}, {}, ReplaceMode::FirstOnly);