mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
AK: Fix bounds assertions in Utf16View::iterator_offset
This commit is contained in:
parent
67723ef83c
commit
d9502505c2
Notes:
github-actions[bot]
2025-07-28 16:32:51 +00:00
Author: https://github.com/trflynn89
Commit: d9502505c2
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5627
Reviewed-by: https://github.com/gmta ✅
2 changed files with 15 additions and 2 deletions
|
|
@ -495,6 +495,19 @@ TEST_CASE(code_point_offset_of)
|
|||
EXPECT_EQ(view.code_point_offset_of(13), 11uz);
|
||||
}
|
||||
|
||||
TEST_CASE(iterator_offset)
|
||||
{
|
||||
Utf16View view { u"😂 foo 😀 bar"sv };
|
||||
size_t expected_offset = 0;
|
||||
|
||||
for (auto it = view.begin(); it != view.end(); ++it) {
|
||||
EXPECT_EQ(view.iterator_offset(it), expected_offset);
|
||||
expected_offset += it.length_in_code_units();
|
||||
}
|
||||
|
||||
EXPECT_EQ(view.iterator_offset(view.end()), view.length_in_code_units());
|
||||
}
|
||||
|
||||
TEST_CASE(replace)
|
||||
{
|
||||
auto result = u""sv.replace({}, {}, ReplaceMode::FirstOnly);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue