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

Method execute

tests/HostTests/modules/ObjectMap.cpp:30–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28 }
29
30 void execute() override
31 {
32 TestMap map;
33
34 TEST_CASE("Add items")
35 {
36 for(unsigned i = 0; i < 5; ++i) {
37 String key = "Object " + String(i);
38 debug_i("map[\"%s\"] = new", key.c_str());
39 map[key] = new TestClass;
40 }
41 REQUIRE(map.count() == 5);
42 REQUIRE(objectCount == 5);
43 }
44
45 TEST_CASE("Set duplicate items")
46 {
47 for(unsigned i = 0; i < 5; ++i) {
48 String key = "Object " + String(i);
49 debug_i("map[\"%s\"] = new", key.c_str());
50 map[key] = new TestClass;
51 }
52 REQUIRE(map.count() == 5);
53 REQUIRE(objectCount == 5);
54 }
55
56 TEST_CASE("Non-existent values")
57 {
58 TestMap::Value value = map["non existent key"];
59 debug_i("map[\"%s\"] = %p", value.getKey().c_str(), (void*)value);
60 REQUIRE(map.count() == 5);
61 value = new TestClass;
62 REQUIRE(map.count() == 6);
63 }
64
65 TEST_CASE("extract")
66 {
67 auto obj = map.extract("Object 0");
68 REQUIRE(map.count() == 5);
69 REQUIRE(objectCount == 6);
70 debug_i("\"Object 0\" -> %p", obj);
71 delete obj;
72 REQUIRE(objectCount == 5);
73 }
74
75 TEST_CASE("Set to null")
76 {
77 for(unsigned i = 0; i < 5; ++i) {
78 String key = "Object " + String(i);
79 debug_i("map[\"%s\"] = nullptr", key.c_str());
80 map[key] = nullptr;
81 }
82 REQUIRE(map.count() == 6);
83 REQUIRE(objectCount == 1);
84 }
85
86 TEST_CASE("clear")
87 {

Callers

nothing calls this directly

Calls 6

getKeyMethod · 0.80
StringClass · 0.50
c_strMethod · 0.45
countMethod · 0.45
extractMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected