mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:37:35 +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
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…
Add table
Add a link
Reference in a new issue