MCPcopy Create free account
hub / github.com/FastLED/FastLED / test_map_move_semantics

Function test_map_move_semantics

tests/test_container_helpers.h:317–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

315// Works for: map, unordered_map, SortedHeapMap, unsorted_map_fixed, HashMapLru
316template<typename MapContainer>
317void test_map_move_semantics() {
318 auto ptr = make_shared_int(100);
319
320 MapContainer source;
321 populate_map(source, 1, ptr);
322
323 FL_REQUIRE(ptr.use_count() == 2);
324 FL_REQUIRE(source.size() == 1);
325
326 MapContainer destination;
327 destination = fl::move(source);
328
329 FL_CHECK(source.size() == 0);
330 FL_CHECK(source.empty());
331 FL_CHECK(destination.size() == 1);
332
333 // Retrieve and check value, but let it go out of scope immediately
334 {
335 auto retrieved = retrieve_map(destination, 1);
336 FL_CHECK(*retrieved == 100);
337 }
338 FL_CHECK(ptr.use_count() == 2);
339
340 destination.clear();
341 FL_CHECK(ptr.use_count() == 1);
342}
343
344// Test smart pointer move semantics (unique_ptr, shared_ptr, optional, variant, expected)
345template<typename SmartPtr>

Callers

nothing calls this directly

Calls 7

make_shared_intFunction · 0.85
populate_mapFunction · 0.85
retrieve_mapFunction · 0.85
use_countMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected