Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tests/gtests')
-rw-r--r--tests/gtests/blenlib/BLI_string_map_test.cc17
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);
+}