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

Function FL_TEST_FILE

tests/fl/stl/multi_map.cpp:6–515  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4#include "test.h"
5
6FL_TEST_FILE(FL_FILEPATH) {
7
8using namespace fl;
9
10FL_TEST_CASE("fl::multi_map basic operations") {
11 fl::multi_map<int, fl::string> mm;
12
13 FL_SUBCASE("Empty multimap") {
14 FL_CHECK(mm.empty());
15 FL_CHECK(mm.size() == 0);
16 }
17
18 FL_SUBCASE("Insert single element") {
19 auto it = mm.insert({1, "one"});
20 FL_CHECK(mm.size() == 1);
21 FL_CHECK(mm.contains(1));
22 FL_CHECK(it->first == 1);
23 FL_CHECK(it->second == "one");
24 }
25
26 FL_SUBCASE("Insert duplicate keys") {
27 mm.insert({1, "first"});
28 mm.insert({1, "second"});
29 mm.insert({1, "third"});
30
31 FL_CHECK(mm.size() == 3);
32 FL_CHECK(mm.count(1) == 3);
33
34 // All values should be findable
35 auto range = mm.equal_range(1);
36 int count = 0;
37 for (auto it = range.first; it != range.second; ++it) {
38 count++;
39 }
40 FL_CHECK(count == 3);
41 }
42
43 FL_SUBCASE("Insert different keys") {
44 mm.insert({1, "one"});
45 mm.insert({2, "two"});
46 mm.insert({3, "three"});
47
48 FL_CHECK(mm.size() == 3);
49 FL_CHECK(mm.count(1) == 1);
50 FL_CHECK(mm.count(2) == 1);
51 FL_CHECK(mm.count(3) == 1);
52 }
53
54 FL_SUBCASE("Find operations") {
55 mm.insert({10, "ten"});
56 mm.insert({20, "twenty"});
57
58 auto it = mm.find(10);
59 FL_CHECK(it != mm.end());
60 FL_CHECK(it->first == 10);
61 FL_CHECK(it->second == "ten");
62
63 auto missing = mm.find(999);

Callers

nothing calls this directly

Calls 15

emptyMethod · 0.45
sizeMethod · 0.45
insertMethod · 0.45
containsMethod · 0.45
countMethod · 0.45
equal_rangeMethod · 0.45
findMethod · 0.45
endMethod · 0.45
eraseMethod · 0.45
clearMethod · 0.45
lower_boundMethod · 0.45
upper_boundMethod · 0.45

Tested by

no test coverage detected