summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2021-08-26 13:55:41 -0400
committerLinus Groh <mail@linusgroh.de>2021-08-26 22:04:09 +0100
commit262e4126346a650b442363887fe9683c56f71d1f (patch)
tree49d3bde5daa857fc0e6f76c6b7680a6d58055e4a /Tests
parentd2af27d2d046111f3828914257e2f4dff065e365 (diff)
downloadserenity-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.cpp14
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);
+}