mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:18:11 +00:00
AK: Implement String::find_any_of() and StringView::find_any_of()
This implements StringUtils::find_any_of() and uses it in String::find_any_of() and StringView::find_any_of(). All uses of find_{first,last}_of have been replaced with find_any_of(), find() or find_last(). find_{first,last}_of have subsequently been removed.
This commit is contained in:
parent
17eddf3ac4
commit
9cc35d1ba3
12 changed files with 44 additions and 52 deletions
|
@ -123,26 +123,19 @@ TEST_CASE(find_last)
|
|||
EXPECT_EQ(test_string_view.find_last('/'), 0U);
|
||||
}
|
||||
|
||||
TEST_CASE(find_first_of)
|
||||
TEST_CASE(find_any_of)
|
||||
{
|
||||
auto test_string_view = "aabbcc_xy_ccbbaa"sv;
|
||||
EXPECT_EQ(test_string_view.find_first_of("bc"), 2U);
|
||||
EXPECT_EQ(test_string_view.find_first_of("yx"), 7U);
|
||||
EXPECT_EQ(test_string_view.find_first_of("defg").has_value(), false);
|
||||
EXPECT_EQ(test_string_view.find_any_of("bc", StringView::SearchDirection::Forward), 2U);
|
||||
EXPECT_EQ(test_string_view.find_any_of("yx", StringView::SearchDirection::Forward), 7U);
|
||||
EXPECT_EQ(test_string_view.find_any_of("defg", StringView::SearchDirection::Forward).has_value(), false);
|
||||
EXPECT_EQ(test_string_view.find_any_of("bc", StringView::SearchDirection::Backward), 13U);
|
||||
EXPECT_EQ(test_string_view.find_any_of("yx", StringView::SearchDirection::Backward), 8U);
|
||||
EXPECT_EQ(test_string_view.find_any_of("fghi", StringView::SearchDirection::Backward).has_value(), false);
|
||||
|
||||
test_string_view = "/"sv;
|
||||
EXPECT_EQ(test_string_view.find_first_of("/"), 0U);
|
||||
}
|
||||
|
||||
TEST_CASE(find_last_of)
|
||||
{
|
||||
auto test_string_view = "aabbcc_xy_ccbbaa"sv;
|
||||
EXPECT_EQ(test_string_view.find_last_of("bc"), 13U);
|
||||
EXPECT_EQ(test_string_view.find_last_of("yx"), 8U);
|
||||
EXPECT_EQ(test_string_view.find_last_of("fghi").has_value(), false);
|
||||
|
||||
test_string_view = "/"sv;
|
||||
EXPECT_EQ(test_string_view.find_last_of("/"), 0U);
|
||||
EXPECT_EQ(test_string_view.find_any_of("/", StringView::SearchDirection::Forward), 0U);
|
||||
EXPECT_EQ(test_string_view.find_any_of("/", StringView::SearchDirection::Backward), 0U);
|
||||
}
|
||||
|
||||
TEST_CASE(split_view)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue