mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
AK: Allow comparing UTF-16 strings to UTF-8 strings
Before now, you could compare a Utf16View to a StringView, but it would only be valid if the StringView were ASCII. When porting code to UTF-16, it will be handy to have a code point-aware implementation for non-ASCII StringViews.
This commit is contained in:
parent
319e7aa03b
commit
0bf565b97f
Notes:
github-actions[bot]
2025-08-05 11:08:55 +00:00
Author: https://github.com/trflynn89
Commit: 0bf565b97f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5698
3 changed files with 35 additions and 2 deletions
|
|
@ -1070,7 +1070,7 @@ TEST_CASE(equals_ascii)
|
|||
test("ababababab"sv, "πππππ"_utf16);
|
||||
|
||||
// Non-ASCII string comparison.
|
||||
EXPECT_NE("π"sv, "π"_utf16);
|
||||
EXPECT_EQ("π"sv, "π"_utf16);
|
||||
}
|
||||
|
||||
TEST_CASE(equals_ignoring_ascii_case)
|
||||
|
|
|
|||
|
|
@ -442,6 +442,24 @@ TEST_CASE(to_ascii_titlecase)
|
|||
EXPECT_EQ(u"foo π bar"sv.to_ascii_titlecase(), u"Foo π Bar"sv);
|
||||
}
|
||||
|
||||
TEST_CASE(equals_utf8)
|
||||
{
|
||||
EXPECT_EQ(u""sv, ""sv);
|
||||
|
||||
EXPECT_EQ(u"foo bar"sv, "foo bar"sv);
|
||||
EXPECT_NE(u"foo bar"sv, "foo ba"sv);
|
||||
EXPECT_NE(u"foo bar"sv, "foo"sv);
|
||||
EXPECT_NE(u"foo bar"sv, ""sv);
|
||||
|
||||
EXPECT_EQ(u"foo π bar"sv, "foo π bar"sv);
|
||||
EXPECT_NE(u"foo π bar"sv, "foo π"sv);
|
||||
EXPECT_NE(u"foo π bar"sv, "foo"sv);
|
||||
EXPECT_NE(u"foo π bar"sv, ""sv);
|
||||
|
||||
EXPECT_NE(u"foo π bar"sv, "foo π bar"sv);
|
||||
EXPECT_NE(u"foo π bar"sv, "foo π bar"sv);
|
||||
}
|
||||
|
||||
TEST_CASE(equals_ignoring_case)
|
||||
{
|
||||
auto string1 = Utf16String::from_utf8("foobar"sv);
|
||||
|
|
|
|||
Loadingβ¦
Add table
Add a link
Reference in a new issue