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

Function test_map_find_and_iterate

tests/test_container_helpers.h:886–906  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

884// Verifies: find() returns valid iterator, dereferencing works
885template<template<typename, typename> class MapTemplate>
886void test_map_find_and_iterate() {
887 using MapContainer = MapTemplate<int, fl::shared_ptr<int>>;
888
889 MapContainer m;
890 auto ptr42 = make_shared_int(42);
891 populate_map(m, 5, ptr42);
892 populate_map(m, 10, make_shared_int(100));
893
894 // Find and dereference
895 auto it = m.find(5);
896 FL_CHECK(it != m.end());
897 FL_CHECK(it->first == 5);
898 FL_CHECK(*it->second == 42);
899
900 // Iterate from find result
901 int count = 0;
902 for (auto it2 = it; it2 != m.end(); ++it2) {
903 count++;
904 }
905 FL_CHECK(count >= 1); // At least the found element and beyond
906}
907
908// Test const iterator functionality
909// Verifies: const_iterator works with find

Callers

nothing calls this directly

Calls 4

make_shared_intFunction · 0.85
populate_mapFunction · 0.85
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected