diff options
author | Jacques Lucke <jacques@blender.org> | 2021-03-04 19:37:46 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-03-04 19:38:01 +0300 |
commit | bb1f02510b69a70ab9bde68be1a4d51c47d72d57 (patch) | |
tree | 5919d50809056aa2206f6de884081c810cfe13ae /source/blender/blenlib/tests | |
parent | d09b874244c8ef7385aff136acdaae6aae67ea7e (diff) |
BLI: support mutable lookup from multi value map
Diffstat (limited to 'source/blender/blenlib/tests')
-rw-r--r-- | source/blender/blenlib/tests/BLI_multi_value_map_test.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/source/blender/blenlib/tests/BLI_multi_value_map_test.cc b/source/blender/blenlib/tests/BLI_multi_value_map_test.cc index 7501fbe0d87..a910f2935d4 100644 --- a/source/blender/blenlib/tests/BLI_multi_value_map_test.cc +++ b/source/blender/blenlib/tests/BLI_multi_value_map_test.cc @@ -29,6 +29,27 @@ TEST(multi_value_map, LookupExistant) EXPECT_EQ(map.lookup(3)[0], 6); } +TEST(multi_value_map, LookupMutable) +{ + MultiValueMap<int, int> map; + map.add(1, 2); + map.add(4, 5); + map.add(4, 6); + map.add(6, 7); + + MutableSpan<int> span = map.lookup(4); + EXPECT_EQ(span.size(), 2); + span[0] = 10; + span[1] = 20; + + map.add(4, 5); + MutableSpan<int> new_span = map.lookup(4); + EXPECT_EQ(new_span.size(), 3); + EXPECT_EQ(new_span[0], 10); + EXPECT_EQ(new_span[1], 20); + EXPECT_EQ(new_span[2], 5); +} + TEST(multi_value_map, AddMultiple) { MultiValueMap<int, int> map; |