From d0d85742fc16aedb8e2145ca76fa77bd47ec2e54 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Sat, 17 Apr 2021 18:39:35 +0200 Subject: BLI: support multiple arguments for value in *_as methods of Map This allows us to build more complex values in-place in the map. Before those values had to be build separately and then moved into the map. Existing calls to the Map API remain unchanged. --- source/blender/blenlib/tests/BLI_map_test.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source/blender/blenlib/tests/BLI_map_test.cc') diff --git a/source/blender/blenlib/tests/BLI_map_test.cc b/source/blender/blenlib/tests/BLI_map_test.cc index f1ae8fb3921..bb15f7f0d8d 100644 --- a/source/blender/blenlib/tests/BLI_map_test.cc +++ b/source/blender/blenlib/tests/BLI_map_test.cc @@ -604,6 +604,15 @@ TEST(map, GenericAlgorithms) EXPECT_EQ(std::count(map.keys().begin(), map.keys().end(), 7), 1); } +TEST(map, AddAsVariadic) +{ + Map map; + map.add_as(3, "hello", 2); + map.add_as(2, "test", 1); + EXPECT_EQ(map.lookup(3), "he"); + EXPECT_EQ(map.lookup(2), "t"); +} + /** * Set this to 1 to activate the benchmark. It is disabled by default, because it prints a lot. */ -- cgit v1.2.3