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:
authorJacques Lucke <jacques@blender.org>2020-04-28 14:55:36 +0300
committerJacques Lucke <jacques@blender.org>2020-04-28 14:55:36 +0300
commit9c65ac73112f1a0f837cb50a2a446129acf19081 (patch)
tree7ef58bff4aeae04e8dafde734ca5e2b5ac0f99e1 /tests/gtests
parent2c6022108070b53f0293aaba177bc63d184161c7 (diff)
BLI: add Map.lookup_or_add_default method
Diffstat (limited to 'tests/gtests')
-rw-r--r--tests/gtests/blenlib/BLI_map_test.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/gtests/blenlib/BLI_map_test.cc b/tests/gtests/blenlib/BLI_map_test.cc
index e9e4b1895ab..5a19216fa7c 100644
--- a/tests/gtests/blenlib/BLI_map_test.cc
+++ b/tests/gtests/blenlib/BLI_map_test.cc
@@ -213,6 +213,17 @@ TEST(map, AddOverride)
EXPECT_EQ(map.lookup(3), 7.0f);
}
+TEST(map, LookupOrAddDefault)
+{
+ IntFloatMap map;
+ map.lookup_or_add_default(3) = 6;
+ EXPECT_EQ(map.lookup(3), 6);
+ map.lookup_or_add_default(5) = 2;
+ EXPECT_EQ(map.lookup(5), 2);
+ map.lookup_or_add_default(3) += 4;
+ EXPECT_EQ(map.lookup(3), 10);
+}
+
TEST(map, MoveConstructorSmall)
{
IntFloatMap map1;