diff options
Diffstat (limited to 'source/blender/blenlib/tests/BLI_map_test.cc')
-rw-r--r-- | source/blender/blenlib/tests/BLI_map_test.cc | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/source/blender/blenlib/tests/BLI_map_test.cc b/source/blender/blenlib/tests/BLI_map_test.cc index dbbd4843abc..69ae82d6f05 100644 --- a/source/blender/blenlib/tests/BLI_map_test.cc +++ b/source/blender/blenlib/tests/BLI_map_test.cc @@ -560,8 +560,8 @@ TEST(map, PopExceptions) TEST(map, AddOrModifyExceptions) { Map<ExceptionThrower, ExceptionThrower> map; - auto create_fn = [](ExceptionThrower *UNUSED(v)) { throw std::runtime_error(""); }; - auto modify_fn = [](ExceptionThrower *UNUSED(v)) {}; + auto create_fn = [](ExceptionThrower * /*v*/) { throw std::runtime_error(""); }; + auto modify_fn = [](ExceptionThrower * /*v*/) {}; EXPECT_ANY_THROW({ map.add_or_modify(3, create_fn, modify_fn); }); } @@ -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; |