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

Method execute

tests/HostTests/modules/Files.cpp:10–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8 }
9
10 void execute() override
11 {
12 const FlashString& testContent = Resource::README_md;
13
14 debug_i("testContent.length = 0x%08x", testContent.length());
15
16 DEFINE_FSTR_LOCAL(testFileName, "test.txt");
17
18 int res, pos, size;
19
20 {
21 FileHandle file{-1};
22
23 TEST_CASE("Initial position and size")
24 {
25 res = fileSetContent(testFileName, testContent);
26 debug_i("fileSetContent() returned %d", res);
27 REQUIRE(size_t(res) == testContent.length());
28 file = fileOpen(testFileName, File::ReadWrite);
29 size = fileSeek(file, 0, SeekOrigin::End);
30 pos = fileSeek(file, 100, SeekOrigin::Start);
31 debug_i("pos = %d, size = %d", pos, size);
32 REQUIRE(pos == 100);
33 REQUIRE(size_t(size) == testContent.length());
34 }
35
36 TEST_CASE("Reduce file sizes")
37 {
38 res = fileTruncate(file, 555);
39 pos = fileTell(file);
40 size = fileSeek(file, 0, SeekOrigin::End);
41 debug_i("res = %d, pos = %d, size = %d", res, pos, size);
42 REQUIRE(res == 0);
43 REQUIRE(pos == 100);
44 REQUIRE(size == 555);
45 }
46
47 TEST_CASE("Increase file size")
48 {
49 res = fileTruncate(file, 12345);
50 size = fileSeek(file, 0, SeekOrigin::End);
51 debug_i("res = %d, size = %d", res, size);
52 REQUIRE(res < 0);
53 REQUIRE(size == 555);
54 }
55
56 TEST_CASE("Close file")
57 {
58 fileClose(file);
59 REQUIRE(fileTell(file) < 0);
60 }
61 }
62
63 TEST_CASE("fileGetSize")
64 {
65 size = fileGetSize(testFileName);
66 debug_i("size = %u", size);
67 REQUIRE(size == 555);

Callers

nothing calls this directly

Calls 15

fileSetContentFunction · 0.85
fileOpenFunction · 0.85
fileSeekFunction · 0.85
fileTruncateFunction · 0.85
fileTellFunction · 0.85
fileCloseFunction · 0.85
fileGetSizeFunction · 0.85
getPosMethod · 0.80
lengthMethod · 0.45
idMethod · 0.45
truncateMethod · 0.45
getSizeMethod · 0.45

Tested by

no test coverage detected