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

Function test_smart_pointer_move_semantics

tests/test_container_helpers.h:346–362  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

344// Test smart pointer move semantics (unique_ptr, shared_ptr, optional, variant, expected)
345template<typename SmartPtr>
346void test_smart_pointer_move_semantics() {
347 auto ptr = make_shared_int(200);
348
349 SmartPtr source(ptr);
350
351 FL_REQUIRE(ptr.use_count() == 2);
352
353 SmartPtr destination;
354 destination = fl::move(source);
355
356 // Retrieve and check value, but let it go out of scope immediately
357 {
358 auto retrieved = retrieve(destination);
359 FL_CHECK(*retrieved == 200);
360 }
361 FL_CHECK(ptr.use_count() == 2);
362}
363
364// Test basic iterator support for containers with shared_ptr<int>
365// Verifies: begin/end, forward iteration, const iteration, move leaves empty

Callers

nothing calls this directly

Calls 3

make_shared_intFunction · 0.85
retrieveFunction · 0.85
use_countMethod · 0.45

Tested by

no test coverage detected