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 'source/blender/blenlib/tests/BLI_map_test.cc')
-rw-r--r--source/blender/blenlib/tests/BLI_map_test.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/source/blender/blenlib/tests/BLI_map_test.cc b/source/blender/blenlib/tests/BLI_map_test.cc
index 70c1887a527..f1ae8fb3921 100644
--- a/source/blender/blenlib/tests/BLI_map_test.cc
+++ b/source/blender/blenlib/tests/BLI_map_test.cc
@@ -587,6 +587,23 @@ TEST(map, EnumKey)
EXPECT_EQ(map.lookup(TestEnum::B), 10);
}
+TEST(map, GenericAlgorithms)
+{
+ Map<int, int> map;
+ map.add(5, 2);
+ map.add(1, 4);
+ map.add(2, 2);
+ map.add(7, 1);
+ map.add(8, 6);
+ EXPECT_TRUE(std::any_of(map.keys().begin(), map.keys().end(), [](int v) { return v == 1; }));
+ EXPECT_TRUE(std::any_of(map.values().begin(), map.values().end(), [](int v) { return v == 1; }));
+ EXPECT_TRUE(std::any_of(
+ map.items().begin(), map.items().end(), [](auto item) { return item.value == 1; }));
+ EXPECT_EQ(std::count(map.values().begin(), map.values().end(), 2), 2);
+ EXPECT_EQ(std::count(map.values().begin(), map.values().end(), 4), 1);
+ EXPECT_EQ(std::count(map.keys().begin(), map.keys().end(), 7), 1);
+}
+
/**
* Set this to 1 to activate the benchmark. It is disabled by default, because it prints a lot.
*/