summaryrefslogtreecommitdiff
path: root/Tests/AK
diff options
context:
space:
mode:
authorMax Wipfli <mail@maxwipfli.ch>2021-07-01 18:12:21 +0200
committerAndreas Kling <kling@serenityos.org>2021-07-02 21:54:21 +0200
commit9cc35d1ba3660f7ecdff54040a7249bb95c755fc (patch)
treed6e07c91e220a38fdc1ad152606aa2b1f5bc8719 /Tests/AK
parent17eddf3ac4cc334a989bfd1f1f36c47439d5d18c (diff)
downloadserenity-9cc35d1ba3660f7ecdff54040a7249bb95c755fc.zip
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.
Diffstat (limited to 'Tests/AK')
-rw-r--r--Tests/AK/TestStringView.cpp25
1 files changed, 9 insertions, 16 deletions
diff --git a/Tests/AK/TestStringView.cpp b/Tests/AK/TestStringView.cpp
index fa079c9ebb..a01b908a4d 100644
--- a/Tests/AK/TestStringView.cpp
+++ b/Tests/AK/TestStringView.cpp
@@ -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)