diff options
Diffstat (limited to 'AK/Tests')
-rw-r--r-- | AK/Tests/TestString.cpp | 2 | ||||
-rw-r--r-- | AK/Tests/TestStringUtils.cpp | 11 | ||||
-rw-r--r-- | AK/Tests/TestStringView.cpp | 2 |
3 files changed, 15 insertions, 0 deletions
diff --git a/AK/Tests/TestString.cpp b/AK/Tests/TestString.cpp index 5576bcec90..9c8dd51d45 100644 --- a/AK/Tests/TestString.cpp +++ b/AK/Tests/TestString.cpp @@ -97,6 +97,8 @@ TEST_CASE(ends_with) EXPECT(!test_string.ends_with('E')); EXPECT(test_string.ends_with("ABCDEF")); EXPECT(!test_string.ends_with("ABC")); + EXPECT(test_string.ends_with("def", CaseSensitivity::CaseInsensitive)); + EXPECT(!test_string.ends_with("def", CaseSensitivity::CaseSensitive)); } TEST_CASE(copy_string) diff --git a/AK/Tests/TestStringUtils.cpp b/AK/Tests/TestStringUtils.cpp index 79e4b98af5..0fc2bd038f 100644 --- a/AK/Tests/TestStringUtils.cpp +++ b/AK/Tests/TestStringUtils.cpp @@ -144,4 +144,15 @@ TEST_CASE(convert_to_uint) EXPECT(ok && actual == 12345u); } +TEST_CASE(ends_with) +{ + String test_string = "ABCDEF"; + EXPECT(AK::StringUtils::ends_with(test_string, "DEF", CaseSensitivity::CaseSensitive)); + EXPECT(AK::StringUtils::ends_with(test_string, "ABCDEF", CaseSensitivity::CaseSensitive)); + EXPECT(!AK::StringUtils::ends_with(test_string, "ABCDE", CaseSensitivity::CaseSensitive)); + EXPECT(!AK::StringUtils::ends_with(test_string, "ABCDEFG", CaseSensitivity::CaseSensitive)); + EXPECT(AK::StringUtils::ends_with(test_string, "def", CaseSensitivity::CaseInsensitive)); + EXPECT(!AK::StringUtils::ends_with(test_string, "def", CaseSensitivity::CaseSensitive)); +} + TEST_MAIN(StringUtils) diff --git a/AK/Tests/TestStringView.cpp b/AK/Tests/TestStringView.cpp index e26fa65f63..ded60c943e 100644 --- a/AK/Tests/TestStringView.cpp +++ b/AK/Tests/TestStringView.cpp @@ -80,6 +80,8 @@ TEST_CASE(ends_with) EXPECT(test_string_view.ends_with("ABCDEF")); EXPECT(!test_string_view.ends_with("ABCDE")); EXPECT(!test_string_view.ends_with("ABCDEFG")); + EXPECT(test_string_view.ends_with("def", CaseSensitivity::CaseInsensitive)); + EXPECT(!test_string_view.ends_with("def", CaseSensitivity::CaseSensitive)); } TEST_CASE(lines) |