diff options
author | Maciej Zygmanowski <sppmacd@pm.me> | 2021-05-19 13:29:23 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-05-19 20:51:51 +0100 |
commit | 80077cea8612883ef65f412ae36b4ed7ffab9528 (patch) | |
tree | d35cc4e626acfb8af484114f7764f785bf0dc76c /Tests/AK/TestString.cpp | |
parent | e9898a6031addb7b2b3e673399d1fca32997f160 (diff) | |
download | serenity-80077cea8612883ef65f412ae36b4ed7ffab9528.zip |
AK: Add String::find_all() and String::count()
Diffstat (limited to 'Tests/AK/TestString.cpp')
-rw-r--r-- | Tests/AK/TestString.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Tests/AK/TestString.cpp b/Tests/AK/TestString.cpp index b61828199e..40953ec418 100644 --- a/Tests/AK/TestString.cpp +++ b/Tests/AK/TestString.cpp @@ -168,6 +168,26 @@ TEST_CASE(replace) EXPECT(test_string == "111._.|||._.|||"); } +TEST_CASE(count) +{ + String test_string = "Well, hello Friends!"; + u32 count = test_string.count("Friends"); + EXPECT(count == 1); + + count = test_string.count("ell"); + EXPECT(count == 2); + + count = test_string.count("!"); + EXPECT(count == 1); + + test_string = String("111._.111._.111"); + count = test_string.count("111"); + EXPECT(count == 3); + + count = test_string.count("._."); + EXPECT(count == 2); +} + TEST_CASE(substring) { String test = "abcdef"; |