diff options
author | Jacques Lucke <jacques@blender.org> | 2020-06-16 13:16:07 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-06-16 13:16:07 +0300 |
commit | 38c9573b2388c37b1df7547a836c790d0f16f02c (patch) | |
tree | 93708562ea494c03ab795005f894dc56a0bc72f5 /tests/gtests | |
parent | d2587f6f930cd858c0d646c2bdd5242ed2506cdf (diff) |
BLI: fix Map.foreach_item method
Diffstat (limited to 'tests/gtests')
-rw-r--r-- | tests/gtests/blenlib/BLI_map_test.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/gtests/blenlib/BLI_map_test.cc b/tests/gtests/blenlib/BLI_map_test.cc index 96e9879abe7..85b2f642654 100644 --- a/tests/gtests/blenlib/BLI_map_test.cc +++ b/tests/gtests/blenlib/BLI_map_test.cc @@ -458,6 +458,25 @@ TEST(map, ConstKeysAndValues) EXPECT_FALSE(map.contains("54")); } +TEST(map, ForeachItem) +{ + Map<int, int> map; + map.add(3, 4); + map.add(1, 8); + + Vector<int> keys; + Vector<int> values; + map.foreach_item([&](int key, int value) { + keys.append(key); + values.append(value); + }); + + EXPECT_EQ(keys.size(), 2); + EXPECT_EQ(values.size(), 2); + EXPECT_EQ(keys.first_index_of(3), values.first_index_of(4)); + EXPECT_EQ(keys.first_index_of(1), values.first_index_of(8)); +} + /** * Set this to 1 to activate the benchmark. It is disabled by default, because it prints a lot. */ |