You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-10Lines changed: 1 addition & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,7 @@ Quick description, and links to the documentation of all the libraries of the pr
14
14
-[Text](./zero/ifc/text/README.md) - Offers utilities for text manipulation, string splitting, formatting, styling, and print to console functionalities.
15
15
-[Types](./zero/ifc/types/README.md) - Information about types and traits for types
16
16
-[Math](./zero/ifc/math/README.md) - Mathematical operations and functions
17
+
-[Test Suite](./zero/ifc/test-suite/README.md) - A flexible and simple test-suite.
17
18
18
19
## Sponsorship
19
20
@@ -48,16 +49,6 @@ system in a real world environment, so people can profit by taking examples of h
48
49
in a big scale project. Also, we introduce the changes of the latest releases available here, so it serves as well as
49
50
a kind of latest up-to-date guide.
50
51
51
-
## Testing tools
52
-
53
-
We are using [`catch2`](https://github.com/catchorg/Catch2) as the testing suite for `Zero`, in its *header-only* version.
54
-
55
-
We made a try to replace it with `boost::ut`, that spots that is compatible with modules, but we are getting all kind of errors in the process of convert the provided header to a precompiled module, so we will stay
56
-
with `catch2` for now.
57
-
58
-
Also, we are looking for generate a precompiled header of the Catch's suite in order to decrement
59
-
the tests compilation time.
60
-
61
52
## General guidelines and API design
62
53
63
54
This entry is a collection of both the things that we're looking for, or focusing on
Copy file name to clipboardExpand all lines: zero/ifc/test-suite/README.md
+79-12Lines changed: 79 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,6 +65,21 @@ Test cases within a suite can be registered using the `TEST_CASE(...)` function,
65
65
just like standalone tests, but choosing the overload that receives as its first parameter
66
66
a reference to the test suite.
67
67
68
+
### **Test Modes**
69
+
In the pursuit of flexibility and control over the test execution process, our testing framework offers different modes of operation. These modes determine the test runner's behavior in response to test failures, allowing users to tailor the testing process according to their specific needs or the nature of the tests being run.
70
+
71
+
1.**CONTINUE_ON_ERROR**
72
+
-**Description**: This mode ensures that all tests are executed regardless of any failures encountered. It's ideal for comprehensive error analysis or understanding the full extent of issues in the codebase.
73
+
-**Use Case**: Opt for this mode when a complete analysis of the system's state is required, particularly to identify all potential problems in a single test run.
74
+
75
+
2.**HALT_SUITE_ON_FAIL**
76
+
-**Description**: In this mode, the test suite halts the execution of the current suite or free tests upon encountering a failure, then proceeds to the next suite or free test. It allows for a quick bypass of problematic tests while still performing remaining tests.
77
+
-**Use Case**: Useful for scenarios where quickly identifying and addressing failures is important, without getting bogged down by tests in a problematic suite.
78
+
79
+
3.**ABORT_ALL_ON_FAIL (Default mode)**
80
+
-**Description**: This mode adopts a zero-tolerance approach towards test failures. As soon as any test fails, it immediately halts all further testing activities.
81
+
-**Use Case**: Use this mode to avoid wasting time on further tests when there's already a known issue that needs fixing.
82
+
68
83
## **Example of usage**
69
84
70
85
Here's an example of how to use the custom test-suite to write and run test cases:
@@ -76,52 +91,104 @@ import std; // Should be ready on all the major compilers for C++23. But until
76
91
// with the `Zork++` out of the box solution based on Clang modulemaps.
77
92
import tsuite;
78
93
79
-
//Define test functions. Should be void functions that later w'd be registered in a suite.
94
+
//Let's define some example test functions using the assertion function
80
95
voidtestAddition() {
81
96
int result = 2 + 2;
82
97
assertEquals(4, result);
98
+
assertEquals(4, result);
99
+
assertEquals(4, result);
100
+
}
101
+
102
+
// Let's define some more example test functions using the assertion function
103
+
voidtestSubtraction() {
104
+
int result = 3 - 2;
105
+
assertEquals(1, result);
106
+
assertEquals(23, result);
107
+
assertEquals(1, result);
108
+
}
109
+
110
+
111
+
// Let's define even more example test functions using the assertion function
112
+
voidtestMultiplication() {
113
+
int result = 2 * 2;
114
+
assertEquals(4, result);
115
+
assertEquals(4, result);
116
+
assertEquals(4, result);
83
117
}
84
118
119
+
85
120
// Passing two pointers to compare if the values that they point to are equals
86
121
voidtestPtrsAddition() {
87
122
int result = 2 + 2;
88
123
int expected = 4;
124
+
int wrongExpected = 16;
89
125
assertEquals(&expected, &result);
126
+
assertEquals(&wrongExpected, &result);
90
127
}
91
128
92
129
// Driver code
93
130
intmain() {
94
-
// Free tests cases registration examples
95
-
131
+
132
+
TEST_CASE("Multiplication Test", []() {
133
+
int result = 5 * 3;
134
+
assertEquals(15, result);
135
+
assertEquals(15, result);
136
+
});
137
+
138
+
96
139
// Register a new test case using a function pointer.
97
140
TEST_CASE("Addition Test With Pointers", testPtrsAddition);
98
-
99
-
// Users can register a new test case using lambdas, avoiding to write standalone functions
141
+
142
+
// Users can register a new test case using lambdas, avoiding writing standalone functions
100
143
TEST_CASE("Subtraction Test", []() {
101
144
int result = 5 - 3;
102
-
assertEquals(122435, result);
145
+
assertEquals(2, result);
146
+
assertEquals(2, result);
103
147
});
104
-
148
+
105
149
// Registering test cases into test suites, to group and relate tests that makes sense to exists
106
150
// as a part of a whole
107
-
151
+
108
152
// Instantiate a new test suite, giving it a unique identifier.
109
153
TestSuite suite {"My Suite"};
110
154
// Register test cases using function pointers into a test suite
111
155
TEST_CASE(suite, "Addition Test", testAddition);
112
-
// Force a warning that alerts the user that the test will be discarded, since already
156
+
// Forces a warning that alerts the user that the test will be discarded, since already
113
157
// exists one with the same identifier in the given suite
114
158
TEST_CASE(suite, "Addition Test", testAddition);
115
-
159
+
// Register a test case designed to fail, useful for testing the behavior
0 commit comments