mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-02 12:30:31 +00:00
Tests: Add test for String::find with empty needle
This adds a test case for String::find and String::find_all with empty needles. The expected behavior is in line with what the C++ standard library (and other languages standard libraries) expect.
This commit is contained in:
parent
9cc35d1ba3
commit
4b87dd5c5c
Notes:
sideshowbarker
2024-07-18 11:05:57 +09:00
Author: https://github.com/MaxWipfli Commit: https://github.com/SerenityOS/serenity/commit/4b87dd5c5c2 Pull-request: https://github.com/SerenityOS/serenity/pull/8368 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/trflynn89
1 changed files with 11 additions and 0 deletions
|
@ -271,3 +271,14 @@ TEST_CASE(find)
|
|||
EXPECT_EQ(a.find('b', 4), Optional<size_t> { 6 });
|
||||
EXPECT_EQ(a.find('b', 9), Optional<size_t> {});
|
||||
}
|
||||
|
||||
TEST_CASE(find_with_empty_needle)
|
||||
{
|
||||
String string = "";
|
||||
EXPECT_EQ(string.find(""sv), 0u);
|
||||
EXPECT_EQ(string.find_all(""sv), (Vector<size_t> { 0u }));
|
||||
|
||||
string = "abc";
|
||||
EXPECT_EQ(string.find(""sv), 0u);
|
||||
EXPECT_EQ(string.find_all(""sv), (Vector<size_t> { 0u, 1u, 2u, 3u }));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue