MCPcopy Create free account
hub / github.com/SmingHub/Sming / execute

Method execute

tests/HostTests/modules/Wiring.cpp:54–288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52 }
53
54 void execute() override
55 {
56 TEST_CASE("HashMap<String, String>")
57 {
58 auto startMem = MallocCount::getCurrent();
59
60 HashMap<String, String> map;
61 map["a"] = "value(a)";
62 map["b"] = "value(b)";
63 map["c"] = "value(c)";
64 map["d"] = "value(d)";
65
66 Serial << "Heap " << MallocCount::getCurrent() - startMem << endl;
67
68 print(map);
69
70 for(auto e : map) {
71 REQUIRE(e->startsWith("value"));
72 }
73
74 for(auto e : map) {
75 *e += ": gobbed";
76 }
77 for(auto e : map) {
78 REQUIRE(e->endsWith("gobbed"));
79 }
80
81 REQUIRE_EQ(map["b"], "value(b): gobbed");
82
83 print(map);
84 }
85
86 TEST_CASE("HashMap<MimeType, size_t>")
87 {
88 using TestMap = HashMap<MimeType, uint16_t>;
89 TestMap map;
90 fillMap(map);
91 print(map);
92
93 Serial.println();
94
95 using Func = Delegate<void(TestMap & map)>;
96 auto time = [](const String& description, const Func& function) {
97 Serial << description << " ..." << endl;
98 TestMap map;
99 fillMap(map);
100 CpuCycleTimer timer;
101 function(map);
102 auto elapsed = timer.elapsedTime();
103 print(map);
104 Serial << "... took " << elapsed.toString() << endl << endl;
105 };
106
107 time("sort by key String", [](auto& map) {
108 map.sort([](const auto& e1, const auto& e2) { return toString(e1.key()) < toString(e2.key()); });
109 });
110
111 time("Sort by key numerically",

Callers

nothing calls this directly

Calls 15

getCurrentFunction · 0.85
fillMapFunction · 0.85
MacAddressClass · 0.85
endsWithMethod · 0.80
printlnMethod · 0.80
elapsedTimeMethod · 0.80
setElementAtMethod · 0.80
insertElementAtMethod · 0.80
trimToSizeMethod · 0.80
copyIntoMethod · 0.80
addElementMethod · 0.80
printFunction · 0.70

Tested by

no test coverage detected