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

Method execute

tests/HostTests/modules/Stream.cpp:30–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28 }
29
30 void execute() override
31 {
32 const FlashString& FS_abstract = Resource::abstract_txt;
33
34 MallocCount::setLogThreshold(0);
35
36 TEST_CASE("MemoryDataStream::moveString")
37 {
38 FSTR::Stream src(FS_abstract);
39 MemoryDataStream dest;
40 dest.copyFrom(&src);
41 String s;
42 REQUIRE(dest.moveString(s) == true);
43 REQUIRE(FS_abstract == s);
44 }
45
46 TEST_CASE("MemoryDataStream(String&&)")
47 {
48 // Move Stream into String
49 String s(FS_abstract);
50 MemoryDataStream stream(std::move(s));
51 TEST_ASSERT(!s);
52 TEST_ASSERT(FS_abstract.length() == size_t(stream.available()));
53 // And back again
54 stream.moveString(s);
55 TEST_ASSERT(FS_abstract == s);
56 REQUIRE(strlen(s.c_str()) == s.length());
57 }
58
59 TEST_CASE("LimitedMemoryStream::moveString (1)")
60 {
61 FSTR::Stream src(FS_abstract);
62 REQUIRE(size_t(src.available()) == FS_abstract.length());
63 LimitedMemoryStream dest(FS_abstract.length());
64 // Operation will drop last character as this is converted to NUL
65 dest.copyFrom(&src);
66 String s;
67 REQUIRE(dest.moveString(s) == false);
68 debug_i("src length = %u, s length = %u", FS_abstract.length(), s.length());
69 String s1(FS_abstract);
70 s1.remove(s1.length() - 1);
71 REQUIRE(s1 == s);
72 REQUIRE(strlen(s.c_str()) == s.length());
73 }
74
75 TEST_CASE("LimitedMemoryStream::moveString (2)")
76 {
77 FSTR::Stream src(FS_abstract);
78 REQUIRE(size_t(src.available()) == FS_abstract.length());
79 LimitedMemoryStream dest(FS_abstract.length() + 10);
80 // Operation will drop last character as this is converted to NUL
81 dest.copyFrom(&src);
82 String s;
83 REQUIRE(dest.moveString(s) == true);
84 REQUIRE(FS_abstract == s);
85 REQUIRE(strlen(s.c_str()) == s.length());
86 }
87

Callers

nothing calls this directly

Calls 15

setLogThresholdFunction · 0.85
m_printHexFunction · 0.85
getCurrentFunction · 0.85
getBoundaryMethod · 0.80
addElementMethod · 0.80
os_randomFunction · 0.50
copyFromMethod · 0.45
moveStringMethod · 0.45
lengthMethod · 0.45
availableMethod · 0.45
c_strMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected