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

Function test_insert_and_erase

tests/misc/containers.cpp:448–470  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

446// Insert/erase operations
447template<template<typename> class ContainerTemplate>
448void test_insert_and_erase() {
449 using Container = ContainerTemplate<TestItem>;
450 Container container;
451 container.push_back(fl::move(TestItem(10)));
452 container.push_back(fl::move(TestItem(30)));
453 FL_CHECK(container.size() == 2);
454
455 // Insert at position 1
456 auto it = container.begin();
457 ++it;
458 TestItem item(20);
459 int initial_move_count = item.move_count;
460 container.insert(it, fl::move(item));
461
462 FL_CHECK(container.size() == 3);
463 FL_CHECK(item.move_count > initial_move_count);
464
465 // Erase middle element
466 it = container.begin();
467 ++it;
468 container.erase(it);
469 FL_CHECK(container.size() == 2);
470}
471
472// ============================================================================
473// Map Container Test Functions (PATTERN 2: Concrete Container Type)

Callers

nothing calls this directly

Calls 6

TestItemClass · 0.85
push_backMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
insertMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected