Przeglądaj źródła

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.
NHOrus 3 lat temu
rodzic
commit
f5025c5cb3
1 zmienionych plików z 3 dodań i 0 usunięć
  1. 3 0
      Tests/AK/TestHashMap.cpp

+ 3 - 0
Tests/AK/TestHashMap.cpp

@@ -83,8 +83,11 @@ TEST_CASE(remove_all_matching)
     EXPECT_EQ(map.size(), 4u);
     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.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_EQ(map.size(), 2u);
+
     EXPECT(map.contains(3));
     EXPECT(map.contains(3));
     EXPECT(map.contains(4));
     EXPECT(map.contains(4));