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/blenlib/BLI_map_test.cc')
-rw-r--r--tests/gtests/blenlib/BLI_map_test.cc24
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/gtests/blenlib/BLI_map_test.cc b/tests/gtests/blenlib/BLI_map_test.cc
index 8d5b178aea6..3acb76e09f0 100644
--- a/tests/gtests/blenlib/BLI_map_test.cc
+++ b/tests/gtests/blenlib/BLI_map_test.cc
@@ -2,7 +2,8 @@
#include "BLI_map.h"
#include "BLI_set.h"
-using IntFloatMap = BLI::Map<int, float>;
+using BLI::Map;
+using IntFloatMap = Map<int, float>;
TEST(map, DefaultConstructor)
{
@@ -258,3 +259,24 @@ TEST(map, Clear)
EXPECT_FALSE(map.contains(1));
EXPECT_FALSE(map.contains(2));
}
+
+TEST(map, UniquePtrValue)
+{
+ auto value1 = std::unique_ptr<int>(new int());
+ auto value2 = std::unique_ptr<int>(new int());
+ auto value3 = std::unique_ptr<int>(new int());
+
+ int *value1_ptr = value1.get();
+
+ Map<int, std::unique_ptr<int>> map;
+ map.add_new(1, std::move(value1));
+ map.add(2, std::move(value2));
+ map.add_override(3, std::move(value3));
+ map.lookup_or_add(4, []() { return std::unique_ptr<int>(new int()); });
+ map.add_new(5, std::unique_ptr<int>(new int()));
+ map.add(6, std::unique_ptr<int>(new int()));
+ map.add_override(7, std::unique_ptr<int>(new int()));
+
+ EXPECT_EQ(map.lookup(1).get(), value1_ptr);
+ EXPECT_EQ(map.lookup_ptr(100), nullptr);
+}