From f5025c5cb316d54da8928f8a2faec7298bf7a89b Mon Sep 17 00:00:00 2001 From: NHOrus Date: Thu, 6 Jan 2022 19:06:59 +0300 Subject: [PATCH] AK: Ensure negative predicate in TestHashMap could run unsuccessfully As it was, negative predicate test for remove_all_matching was run on empty hash map, and could not remove anything, so test always returned true. By duplicating it in state where hash maps contains elements, we make sure that negative predicate has something to do nothing on. --- Tests/AK/TestHashMap.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Tests/AK/TestHashMap.cpp b/Tests/AK/TestHashMap.cpp index b04ab35f32..25e248b7a6 100644 --- a/Tests/AK/TestHashMap.cpp +++ b/Tests/AK/TestHashMap.cpp @@ -83,8 +83,11 @@ TEST_CASE(remove_all_matching) EXPECT_EQ(map.size(), 4u); EXPECT_EQ(map.remove_all_matching([&](int key, String const& value) { return key == 1 || value == "Two"; }), true); - EXPECT_EQ(map.size(), 2u); + + EXPECT_EQ(map.remove_all_matching([&](int, String const&) { return false; }), false); + EXPECT_EQ(map.size(), 2u); + EXPECT(map.contains(3)); EXPECT(map.contains(4));