diff options
author | Brian Gianforcaro <b.gianfo@gmail.com> | 2020-05-26 03:31:56 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-26 13:17:19 +0200 |
commit | e5045b62b8e02f60a0fd723a3d0da29e10d5c3dd (patch) | |
tree | fe6699a7e640b804ec0a22281d024e3b396120db /AK/Tests | |
parent | 129462cca77853828aed1d5c8e6a03d75353b35a (diff) | |
download | serenity-e5045b62b8e02f60a0fd723a3d0da29e10d5c3dd.zip |
AK: Expand string tests to include ends_with case insensitivity
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) |