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

Function test_map_insert_erase_iterators

tests/test_container_helpers.h:964–987  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

962// Verifies: insert returns valid iterator, erase returns next iterator
963template<template<typename, typename> class MapTemplate>
964void test_map_insert_erase_iterators() {
965 using MapContainer = MapTemplate<int, fl::shared_ptr<int>>;
966
967 MapContainer m;
968 populate_map(m, 5, make_shared_int(50));
969 populate_map(m, 15, make_shared_int(150));
970
971 // Insert and get iterator
972 auto result = m.insert(fl::pair<int, fl::shared_ptr<int>>(10, make_shared_int(100)));
973 FL_CHECK(result.second == true); // insertion took place
974 FL_CHECK(result.first != m.end());
975 FL_CHECK(result.first->first == 10);
976
977 // Erase and verify next iterator
978 auto erase_result = m.erase(result.first);
979 // After erase, either at end or the key should be > 10
980 bool valid = (erase_result == m.end());
981 if (!valid) {
982 valid = erase_result->first > 10;
983 }
984 FL_CHECK(valid);
985
986 FL_CHECK(m.size() == 2); // Two elements left
987}
988
989// Test count and contains
990// Verifies: key lookup operations work correctly

Callers

nothing calls this directly

Calls 6

populate_mapFunction · 0.85
make_shared_intFunction · 0.85
insertMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected