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

Function test_map_const_iterators

tests/test_container_helpers.h:911–932  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

909// Verifies: const_iterator works with find
910template<template<typename, typename> class MapTemplate>
911void test_map_const_iterators() {
912 using MapContainer = MapTemplate<int, fl::shared_ptr<int>>;
913
914 MapContainer m;
915 populate_map(m, 7, make_shared_int(77));
916 populate_map(m, 8, make_shared_int(88));
917
918 const MapContainer& const_m = m;
919
920 // Const find
921 auto const_it = const_m.find(7);
922 FL_CHECK(const_it != const_m.end());
923 FL_CHECK(const_it->first == 7);
924 FL_CHECK(*const_it->second == 77);
925
926 // Const iteration
927 int count = 0;
928 for (auto it = const_m.begin(); it != const_m.end(); ++it) {
929 count++;
930 }
931 FL_CHECK(count == 2);
932}
933
934// Test lower_bound and upper_bound
935// Verifies: binary search operations return valid iterators

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected