diff options
Diffstat (limited to 'source/blender/blenlib/tests/BLI_map_test.cc')
-rw-r--r-- | source/blender/blenlib/tests/BLI_map_test.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/blenlib/tests/BLI_map_test.cc b/source/blender/blenlib/tests/BLI_map_test.cc index dbbd4843abc..0ca07309836 100644 --- a/source/blender/blenlib/tests/BLI_map_test.cc +++ b/source/blender/blenlib/tests/BLI_map_test.cc @@ -640,6 +640,24 @@ TEST(map, RemoveDuringIteration) EXPECT_EQ(map.lookup(3), 3); } +TEST(map, RemoveIf) +{ + Map<int64_t, int64_t> map; + for (const int64_t i : IndexRange(100)) { + map.add(i * i, i); + } + map.remove_if([](auto item) { return item.key > 100; }); + EXPECT_EQ(map.size(), 11); + for (const int64_t i : IndexRange(100)) { + if (i <= 10) { + EXPECT_EQ(map.lookup(i * i), i); + } + else { + EXPECT_FALSE(map.contains(i * i)); + } + } +} + TEST(map, LookupKey) { Map<std::string, int> map; |