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

Method execute

tests/HostTests/modules/CStringArray.cpp:12–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10 }
11
12 void execute() override
13 {
14 // Use to help diagnose any issues
15 /*
16 auto debug = [](const CStringArray& csa) {
17 debug_hex(DBG, "csa", csa.c_str(), csa.length());
18 debug_d("csa.count() = %u", csa.count());
19 };
20 */
21
22 // FlashStrings are super-handy for this sort of thing as they're counted
23 DEFINE_FSTR_LOCAL(FS_Basic, "a\0"
24 "b\0"
25 "c\0"
26 "d\0");
27 DEFINE_FSTR_LOCAL(FS_BasicJoined, "a,b,c,d")
28
29 TEST_CASE("Empty construction")
30 {
31 // Default object is empty
32 CStringArray csa1;
33 REQUIRE(csa1.count() == 0);
34 CStringArray csa2("");
35 REQUIRE(csa2.count() == 0);
36 // Contains one empty string
37 CStringArray csa3("\0", 1);
38 REQUIRE(csa3.count() == 1);
39 // Construct using assignment from String
40 String s(FS_Basic);
41 CStringArray csa4 = s;
42 REQUIRE(csa4.count() == 4);
43 }
44
45 TEST_CASE("Destruction")
46 {
47 CStringArray csa = FS_Basic;
48 REQUIRE(csa.count() == 4);
49 csa.clear();
50 REQUIRE(csa.count() == 0);
51 // Assignment to null should clear the array
52 csa = FS_Basic;
53 REQUIRE(csa.count() == 4);
54 csa = nullptr;
55 REQUIRE(csa.count() == 0);
56 }
57
58 TEST_CASE("Single element")
59 {
60 CStringArray csa = "a";
61 REQUIRE(csa.count() == 1);
62 csa = "a\0b\0c\0";
63 REQUIRE(csa.count() == 1);
64 }
65
66 TEST_CASE("Array, no final NUL")
67 {
68 CStringArray csa = F("a\0"
69 "b\0"

Callers

nothing calls this directly

Calls 15

toUpperCaseMethod · 0.80
indexMethod · 0.80
offsetMethod · 0.80
frontMethod · 0.80
pushFrontMethod · 0.80
popFrontMethod · 0.80
backMethod · 0.80
pushBackMethod · 0.80
popBackMethod · 0.80
FFunction · 0.50
StringClass · 0.50
countMethod · 0.45

Tested by

no test coverage detected