Line | Branch | Exec | Source |
---|---|---|---|
1 | #include <script.h> | ||
2 | |||
3 | #include <app.hpp> | ||
4 | #include <testing.hpp> | ||
5 | |||
6 | 1 | void print(const char* msg) | |
7 | { | ||
8 | 1 | std::cout << msg << std::endl; | |
9 | 1 | } | |
10 | |||
11 | 1 | cpp::result::result_void test_parser() | |
12 | { | ||
13 | script::command cmd; | ||
14 | 1 | std::string operand; | |
15 | |||
16 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
1 | script::parse("# this is some comment", cmd, operand); |
17 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
1 | CHECK_("Check Commment", cmd == script::command::COMMENT); |
18 | |||
19 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
1 | script::parse("text this is some test text", cmd, operand); |
20 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
1 | CHECK_("Check Text", cmd == script::command::TEXT); |
21 | |||
22 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
1 | script::parse("process", cmd, operand); |
23 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
1 | CHECK_("Check Process", cmd == script::command::PROCESS); |
24 | |||
25 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
1 | script::parse("print", cmd, operand); |
26 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
1 | CHECK_("Check Print", cmd == script::command::PRINT); |
27 | |||
28 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
1 | script::parse("load file", cmd, operand); |
29 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
1 | CHECK_("Check Load", cmd == script::command::LOAD); |
30 | |||
31 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
1 | script::parse("save file", cmd, operand); |
32 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
1 | CHECK_("Check Save", cmd == script::command::SAVE); |
33 | |||
34 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | return cpp::result::SUCCESS; |
35 | 1 | } | |
36 | |||
37 | 1 | cpp::result::result_void test_engine() | |
38 | { | ||
39 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | script::engine eng{print}; |
40 | |||
41 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
1 | eng.run(script::command::TEXT, "test text"); |
42 | |||
43 |
2/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
|
1 | CHECK_("Check Test", eng.get_memory() == "test text"); |
44 | |||
45 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
1 | eng.run(script::command::PROCESS, ""); |
46 | |||
47 |
2/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
|
1 | CHECK_("Check Process", eng.get_memory() == "Test Text"); |
48 | |||
49 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
1 | eng.run(script::command::SAVE, "_current_content.txt"); |
50 | |||
51 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
1 | eng.run(script::command::TEXT, "nothing"); |
52 | |||
53 |
2/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
|
1 | CHECK_("Check Save", eng.get_memory() == "nothing"); |
54 | |||
55 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
1 | eng.run(script::command::LOAD, "_current_content.txt"); |
56 | |||
57 |
2/8✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
|
1 | CHECK_("Check Load", eng.get_memory() == "Test Text"); |
58 | |||
59 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
2 | const auto res = eng.run(script::command::LOAD, "_invalid_file.txt"); |
60 | |||
61 |
1/6✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
|
1 | CHECK_("Check Load invalid file", !res.empty()); |
62 | |||
63 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | return cpp::result::SUCCESS; |
64 | 1 | } | |
65 | |||
66 | 1 | cpp::result::result_void test_compiler_runtime() | |
67 | { | ||
68 | 1 | std::vector<char> data; | |
69 | |||
70 | { | ||
71 | 1 | std::vector<std::string> lines; | |
72 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
1 | lines.push_back("text this is a test headline"); |
73 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
1 | lines.push_back("process"); |
74 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
|
1 | lines.push_back("print"); |
75 | |||
76 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | const auto res = script::compile(lines, data); |
77 | |||
78 |
1/6✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
|
1 | CHECK_("Check compile succes", res.empty()); |
79 | |||
80 |
1/6✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
|
1 | CHECK_("Check compile result", !data.empty()); |
81 | |||
82 |
1/6✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
|
1 | CHECK_("Check compile result size", data.size() == 43); |
83 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | } |
84 | { | ||
85 |
1/2✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
1 | const auto res_runtime = script::runtime(data, print); |
86 | |||
87 |
1/6✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
|
1 | CHECK_("Check runtime succes", res_runtime.empty()); |
88 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | } |
89 | |||
90 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | return cpp::result::SUCCESS; |
91 | 1 | } | |
92 | |||
93 | 1 | int main() | |
94 | { | ||
95 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
|
1 | if (!cpp::testing::run_test("Test Parser", test_parser)) |
96 | ✗ | return cpp::app::FAILURE; | |
97 | |||
98 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
|
1 | if (!cpp::testing::run_test("Test Engine", test_engine)) |
99 | ✗ | return cpp::app::FAILURE; | |
100 | |||
101 |
2/4✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
|
1 | if (!cpp::testing::run_test("Test Comiler and Runtime", |
102 | test_compiler_runtime)) | ||
103 | ✗ | return cpp::app::FAILURE; | |
104 | |||
105 | 1 | return cpp::app::SUCCESS; | |
106 | } | ||
107 |