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

Method execute

tests/HostTests/modules/ArduinoString.cpp:27–439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25 }
26
27 void execute() override
28 {
29 TEST_CASE("String::trim", "[core][String]")
30 {
31 String str;
32 str = " abcd123 ";
33 str.trim();
34 REQUIRE(str == "abcd123");
35 }
36
37 TEST_CASE("String::replace", "[core][String]")
38 {
39 String str;
40 str = "The quick brown fox jumped over the lazy dog.";
41 String find = "fox";
42 String replace = "vulpes vulpes";
43 str.replace(find, replace);
44 REQUIRE(str == "The quick brown vulpes vulpes jumped over the lazy dog.");
45 }
46
47 TEST_CASE("String(value, base)", "[core][String]")
48 {
49 String strbase2(9999, 2);
50 String strbase8(9999, 8);
51 String strbase10(9999, 10);
52 String strbase16(9999, 16);
53 REQUIRE(strbase2 == "10011100001111");
54 REQUIRE(strbase8 == "23417");
55 REQUIRE(strbase10 == "9999");
56 REQUIRE(strbase16 == "270f");
57 String strnegi(-9999);
58 String strnegf(-2.123, 3);
59 REQUIRE(strnegi == "-9999");
60 REQUIRE(strnegf == "-2.123");
61 String strbase16l((long)999999, 16);
62 REQUIRE(strbase16l == "f423f");
63 }
64
65 TEST_CASE("String constructors", "[core][String]")
66 {
67 String s0('c');
68 REQUIRE(s0 == "c");
69 String bin((unsigned char)5, 4);
70 REQUIRE(bin == "11");
71 String ib((unsigned int)999, 16);
72 REQUIRE(ib == "3e7");
73 String lb((unsigned long)3000000000, 8);
74 REQUIRE(lb == "26264057000");
75 String sl1((long)-2000000000, 10);
76 REQUIRE(sl1 == "-2000000000");
77 String s1("abcd");
78 String s2(s1);
79 REQUIRE(s1 == s2);
80 String* s3 = new String("manos");
81 s2 = *s3;
82 delete s3;
83 REQUIRE(s2 == "manos");
84 s3 = new String("thisismuchlongerthantheother");

Callers

nothing calls this directly

Calls 15

reserveMethod · 0.80
endsWithMethod · 0.80
getBytesMethod · 0.80
toLowerCaseMethod · 0.80
toUpperCaseMethod · 0.80
setCharAtMethod · 0.80
~StringMethod · 0.80
FFunction · 0.50
StringClass · 0.50
trimMethod · 0.45
replaceMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected