diff options
author | Timothy Flynn <trflynn89@pm.me> | 2023-01-16 11:28:27 -0500 |
---|---|---|
committer | Tim Flynn <trflynn89@pm.me> | 2023-01-16 18:33:44 -0500 |
commit | d6ddca0c0f1f6d3a86672a5bb04d2fb56377beff (patch) | |
tree | 8ad3dec13dbabbec70766905475c556d63113bd2 /Tests | |
parent | bc51017a03087057dc8e8f437b4049f2ab7ebba1 (diff) | |
download | serenity-d6ddca0c0f1f6d3a86672a5bb04d2fb56377beff.zip |
AK+LibUnicode: Provide Unicode-aware String titlecase transformation
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/AK/TestString.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Tests/AK/TestString.cpp b/Tests/AK/TestString.cpp index 727b30190e..42f5ffc63f 100644 --- a/Tests/AK/TestString.cpp +++ b/Tests/AK/TestString.cpp @@ -163,6 +163,30 @@ TEST_CASE(to_uppercase) } } +TEST_CASE(to_titlecase) +{ + { + auto string = MUST(String::from_utf8("foo bar baz"sv)); + auto result = MUST(string.to_titlecase()); + EXPECT_EQ(result, "Foo Bar Baz"sv); + } + { + auto string = MUST(String::from_utf8("foo \n \r bar \t baz"sv)); + auto result = MUST(string.to_titlecase()); + EXPECT_EQ(result, "Foo \n \r Bar \t Baz"sv); + } + { + auto string = MUST(String::from_utf8("f\"oo\" b'ar'"sv)); + auto result = MUST(string.to_titlecase()); + EXPECT_EQ(result, "F\"Oo\" B'Ar'"sv); + } + { + auto string = MUST(String::from_utf8("123dollars"sv)); + auto result = MUST(string.to_titlecase()); + EXPECT_EQ(result, "123Dollars"sv); + } +} + TEST_CASE(is_one_of) { auto foo = MUST(String::from_utf8("foo"sv)); |