diff options
author | Timothy Flynn <trflynn89@pm.me> | 2021-08-26 13:55:41 -0400 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-08-26 22:04:09 +0100 |
commit | 262e4126346a650b442363887fe9683c56f71d1f (patch) | |
tree | 49d3bde5daa857fc0e6f76c6b7680a6d58055e4a /Tests | |
parent | d2af27d2d046111f3828914257e2f4dff065e365 (diff) | |
download | serenity-262e4126346a650b442363887fe9683c56f71d1f.zip |
AK: Implement method to convert a String/StringView to title case
This implementation preserves consecutive spaces in the orginal string.
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/AK/TestStringUtils.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Tests/AK/TestStringUtils.cpp b/Tests/AK/TestStringUtils.cpp index 315c14f1da..948adde861 100644 --- a/Tests/AK/TestStringUtils.cpp +++ b/Tests/AK/TestStringUtils.cpp @@ -304,3 +304,17 @@ TEST_CASE(to_snakecase) EXPECT_EQ(AK::StringUtils::to_snakecase("FBar"), "f_bar"); EXPECT_EQ(AK::StringUtils::to_snakecase("FooB"), "foo_b"); } + +TEST_CASE(to_titlecase) +{ + EXPECT_EQ(AK::StringUtils::to_titlecase(""sv), ""sv); + EXPECT_EQ(AK::StringUtils::to_titlecase("f"sv), "F"sv); + EXPECT_EQ(AK::StringUtils::to_titlecase("foobar"sv), "Foobar"sv); + EXPECT_EQ(AK::StringUtils::to_titlecase("Foobar"sv), "Foobar"sv); + EXPECT_EQ(AK::StringUtils::to_titlecase("FOOBAR"sv), "Foobar"sv); + EXPECT_EQ(AK::StringUtils::to_titlecase("foo bar"sv), "Foo Bar"sv); + EXPECT_EQ(AK::StringUtils::to_titlecase("foo bAR"sv), "Foo Bar"sv); + EXPECT_EQ(AK::StringUtils::to_titlecase("foo bar"sv), "Foo Bar"sv); + EXPECT_EQ(AK::StringUtils::to_titlecase("foo bar"sv), "Foo Bar"sv); + EXPECT_EQ(AK::StringUtils::to_titlecase(" foo bar "sv), " Foo Bar "sv); +} |