summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-04-10 17:27:16 +0100
committerAndreas Kling <kling@serenityos.org>2023-04-13 09:53:47 +0200
commit89e55c5297e7b510ed04d7b126397bc61459c1f9 (patch)
tree469756584c0c58bd8eaba6860d0797f2458b1516 /Tests
parent1352f8820b0102477ba80083babe2db3e1edfdae (diff)
downloadserenity-89e55c5297e7b510ed04d7b126397bc61459c1f9.zip
AK+Tests: Add Vector::find_first_index_if()
Diffstat (limited to 'Tests')
-rw-r--r--Tests/AK/TestVector.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/Tests/AK/TestVector.cpp b/Tests/AK/TestVector.cpp
index 9e0c5f8067..6bf010b8b7 100644
--- a/Tests/AK/TestVector.cpp
+++ b/Tests/AK/TestVector.cpp
@@ -423,6 +423,14 @@ TEST_CASE(should_find_index)
EXPECT(!v.find_first_index(42).has_value());
}
+TEST_CASE(should_find_predicate_index)
+{
+ Vector<int> v { 1, 2, 3, 4, 0, 6, 7, 8, 0, 0 };
+
+ EXPECT_EQ(4u, v.find_first_index_if([](auto const v) { return v == 0; }).value());
+ EXPECT(!v.find_first_index_if([](auto const v) { return v == 123; }).has_value());
+}
+
TEST_CASE(should_contain_start)
{
// Tests whether value is found if at the start of the range.