diff options
author | Andreas Kling <kling@serenityos.org> | 2022-01-05 17:00:17 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-01-05 18:57:14 +0100 |
commit | 558fb0a04ae33609a62d4d29de9d89ce0cdd7b13 (patch) | |
tree | cb27032fd5cf598ad27107c9261d564f31e1169e /Tests/AK/TestVector.cpp | |
parent | 5279a04c787d0a9521f96ddecc9690997bf2f16d (diff) | |
download | serenity-558fb0a04ae33609a62d4d29de9d89ce0cdd7b13.zip |
AK: Make Vector::remove_all_matching() return removal success
This matches the behavior of other remove_*_matching() functions.
Diffstat (limited to 'Tests/AK/TestVector.cpp')
-rw-r--r-- | Tests/AK/TestVector.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Tests/AK/TestVector.cpp b/Tests/AK/TestVector.cpp index bf3d807431..2289c24639 100644 --- a/Tests/AK/TestVector.cpp +++ b/Tests/AK/TestVector.cpp @@ -259,6 +259,29 @@ TEST_CASE(vector_remove) EXPECT_EQ(ints[0], 4); } +TEST_CASE(remove_all_matching) +{ + Vector<int> ints; + + ints.append(1); + ints.append(2); + ints.append(3); + ints.append(4); + + EXPECT_EQ(ints.size(), 4u); + + EXPECT_EQ(ints.remove_all_matching([&](int value) { return value > 2; }), true); + EXPECT_EQ(ints.remove_all_matching([&](int) { return false; }), false); + + EXPECT_EQ(ints.size(), 2u); + + EXPECT_EQ(ints.remove_all_matching([&](int) { return true; }), true); + + EXPECT(ints.is_empty()); + + EXPECT_EQ(ints.remove_all_matching([&](int) { return true; }), false); +} + TEST_CASE(nonnullownptrvector) { struct Object { |