mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-28 21:26:22 +00:00
AK: Return an empty optional when UTF-16 code unit lookup fails
Accidentally returned the wrong type here.
This commit is contained in:
parent
baddac5155
commit
ed63a60247
Notes:
github-actions[bot]
2025-07-28 10:27:03 +00:00
Author: https://github.com/trflynn89
Commit: ed63a60247
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5610
2 changed files with 7 additions and 1 deletions
|
@ -420,7 +420,7 @@ public:
|
|||
|
||||
if (has_ascii_storage()) {
|
||||
if (!AK::is_ascii(needle))
|
||||
return false;
|
||||
return {};
|
||||
|
||||
auto byte = static_cast<char>(needle);
|
||||
return AK::memmem_optional(m_string.ascii + start_offset, length_in_code_units() - start_offset, &byte, sizeof(byte));
|
||||
|
|
|
@ -547,6 +547,12 @@ TEST_CASE(contains)
|
|||
EXPECT(u"😀"sv.contains(u'\xd83d'));
|
||||
EXPECT(u"😀"sv.contains(u'\xde00'));
|
||||
|
||||
EXPECT(!Utf16View { ""sv }.contains(u'a'));
|
||||
EXPECT(Utf16View { "a"sv }.contains(u'a'));
|
||||
EXPECT(!Utf16View { "b"sv }.contains(u'a'));
|
||||
EXPECT(!Utf16View { "b"sv }.contains(u'\xd83d'));
|
||||
EXPECT(!Utf16View { "b"sv }.contains(u'\xde00'));
|
||||
|
||||
EXPECT(u""sv.contains(u""sv));
|
||||
EXPECT(!u""sv.contains(u"a"sv));
|
||||
EXPECT(u"a"sv.contains(u"a"sv));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue