diff options
Diffstat (limited to 'tests/gtests/blenlib/BLI_string_map_test.cc')
-rw-r--r-- | tests/gtests/blenlib/BLI_string_map_test.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/gtests/blenlib/BLI_string_map_test.cc b/tests/gtests/blenlib/BLI_string_map_test.cc index 5e671da86c7..41cda920a89 100644 --- a/tests/gtests/blenlib/BLI_string_map_test.cc +++ b/tests/gtests/blenlib/BLI_string_map_test.cc @@ -232,3 +232,20 @@ TEST(string_map, UniquePtrValues) std::unique_ptr<int> *b = map.lookup_ptr("A"); EXPECT_EQ(a.get(), b->get()); } + +TEST(string_map, AddOrModify) +{ + StringMap<int> map; + auto create_func = [](int *value) { + *value = 10; + return true; + }; + auto modify_func = [](int *value) { + *value += 5; + return false; + }; + EXPECT_TRUE(map.add_or_modify("Hello", create_func, modify_func)); + EXPECT_EQ(map.lookup("Hello"), 10); + EXPECT_FALSE(map.add_or_modify("Hello", create_func, modify_func)); + EXPECT_EQ(map.lookup("Hello"), 15); +} |