From 80077cea8612883ef65f412ae36b4ed7ffab9528 Mon Sep 17 00:00:00 2001 From: Maciej Zygmanowski Date: Wed, 19 May 2021 13:29:23 +0200 Subject: AK: Add String::find_all() and String::count() --- Tests/AK/TestString.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'Tests/AK/TestString.cpp') 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"; -- cgit v1.2.3