mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
AK: Add a Utf16View method to retrieve an iterator at a code unit offset
This commit is contained in:
parent
4aa355658f
commit
bbda6d13f7
Notes:
github-actions[bot]
2025-08-07 00:07:51 +00:00
Author: https://github.com/trflynn89
Commit: bbda6d13f7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5746
Reviewed-by: https://github.com/gmta ✅
2 changed files with 21 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue