mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:47:44 +00:00
AK: Add String::find_all() and String::count()
This commit is contained in:
parent
e9898a6031
commit
80077cea86
3 changed files with 56 additions and 6 deletions
|
@ -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";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue