mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-11 02:29:21 +00:00
AK+LibUnicode: Provide Unicode-aware String case transformations
Since AK can't refer to LibUnicode directly, the strategy here is that if you need case transformations, you can link LibUnicode and receive them. If you try to use either of these methods without linking it, then you'll of course get a linker error (note we don't do any fallbacks to e.g. ASCII case transformations). If you don't need these methods, you don't have to link LibUnicode.
This commit is contained in:
parent
12f6793223
commit
6fcc1c7426
Notes:
sideshowbarker
2024-07-17 03:10:07 +09:00
Author: https://github.com/trflynn89
Commit: 6fcc1c7426
Pull-request: https://github.com/SerenityOS/serenity/pull/16918
Reviewed-by: https://github.com/linusg ✅
6 changed files with 77 additions and 0 deletions
|
@ -107,3 +107,41 @@ TEST_CASE(replace)
|
|||
EXPECT_EQ(result, "anon@courage:~"sv);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE(to_lowercase)
|
||||
{
|
||||
{
|
||||
auto string = MUST(String::from_utf8("Aa"sv));
|
||||
auto result = MUST(string.to_lowercase());
|
||||
EXPECT_EQ(result, "aa"sv);
|
||||
}
|
||||
{
|
||||
auto string = MUST(String::from_utf8("Ωω"sv));
|
||||
auto result = MUST(string.to_lowercase());
|
||||
EXPECT_EQ(result, "ωω"sv);
|
||||
}
|
||||
{
|
||||
auto string = MUST(String::from_utf8("İi̇"sv));
|
||||
auto result = MUST(string.to_lowercase());
|
||||
EXPECT_EQ(result, "i̇i̇"sv);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE(to_uppercase)
|
||||
{
|
||||
{
|
||||
auto string = MUST(String::from_utf8("Aa"sv));
|
||||
auto result = MUST(string.to_uppercase());
|
||||
EXPECT_EQ(result, "AA"sv);
|
||||
}
|
||||
{
|
||||
auto string = MUST(String::from_utf8("Ωω"sv));
|
||||
auto result = MUST(string.to_uppercase());
|
||||
EXPECT_EQ(result, "ΩΩ"sv);
|
||||
}
|
||||
{
|
||||
auto string = MUST(String::from_utf8("ʼn"sv));
|
||||
auto result = MUST(string.to_uppercase());
|
||||
EXPECT_EQ(result, "ʼN"sv);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue