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.en.md
+30-30Lines changed: 30 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ Hope you get 0 errors and 0 warnings everyday!
8
8

9
9
10
10
11
-
ZeroErr is a smart assertion library, a lightweight unit testing framework and a structure logging framework. It integrates those features and provided an unite and clear interface for seperate using or joint using.
11
+
ZeroErr is a smart assertion library, a lightweight unit testing framework and a structure logging framework. It integrates those features and provided an unite and clear interface for separated usage or combined usage.
@@ -21,7 +21,7 @@ The current popular unit testing frameworks, e.g. Catch2, doctest, Boost.Test an
21
21
22
22
### 1. Generic Printing
23
23
24
-
Most unit testing frameworks and logger libraries can not provide a generic printing for user customized type. Especially, when using containers, struct and pointers (including smart pointers), user have to manualy write code to generate the log message or print those information during unit testing failed cases.
24
+
Most unit testing frameworks and logger libraries can not provide a generic printing for user customized types. Especially, when using containers, structures and pointers (including smart pointers), user have to manually write code to generate the log message or print those information during unit testing failed cases.
25
25
26
26
This library `zeroerr` gives you an ability to print generically for all types:
27
27
@@ -36,7 +36,7 @@ Similar to other C++ unit testing frameworks, `zeroerr` will convert this piece
36
36
37
37

38
38
39
-
For the custom struct type with override `std::ostream& operator<<(std::ostream&, Type)` stream output, you can use it not only for this type but also all contains using this type, including multiple recurisve contains:
39
+
For the custom struct type with override `std::ostream& operator<<(std::ostream&, Type)` stream output, you can use it not only for this type but also all contains using this type, including multiple recursive contains:
40
40
41
41
```c++
42
42
struct Node {
@@ -94,9 +94,9 @@ This functin `PrintExt` will match all the class who's base class is `Value` and
94
94
95
95

96
96
97
-
### 2. Joint using of assert, log and unit testing
97
+
### 2. Combined usage of assert, log and unit testing
98
98
99
-
If you use one logging framework, an unit testing framework and a smart assertion libary, you can not easily combine them together. In `zeroerr`, if an assertion is failed, the logger will recevie an event and stored the event in your log file. If you are using an assertion in unit testing, the assertion failure, logged fatal events can be recorded and reported.
99
+
If you use one logging framework, an unit testing framework and an assertion library, it's not a easy work to combine them together. There is a lot of benefits to use assertion, logging and unit testing together. In `zeroerr`, if an assertion is failed, the logger will receive an event and stored the event in your log file. If you are using an assertion in unit testing, the assertion failure, logged fatal events can be recorded and reported.
100
100
101
101
```c++
102
102
int fib(int n) {
@@ -121,13 +121,33 @@ TEST_CASE("fib function test") {
121
121
122
122

123
123
124
+
For the logging system, the unit testing can access the log data to ensure that the function has executed the expected logic and results.
In order to access the log, we need to pause the log system first, to avoid the data being output to the file, then call the function, access the data in the log through the `LOG_GET` macro, and finally resume the log system. (Currently experimental, only the first call of each log point can be accessed)
142
+
143
+
124
144
Further more, the unit testing can check the logged result if it matches the previous running result (a golden file) to avoid writing any code in the test case.
125
145
126
146
```c++
127
147
TEST_CASE("match ostream") {
128
148
// match output can be done in the following workflow
129
149
// 1. user mark the test case which are comparing output use 'ZEROERR_HAVE_SAME_OUTPUT'
130
-
// 2. If the output is not exist, the result has been used as a correct verifier.
150
+
// 2. If the output is not exist, the result will be store to the disk.
131
151
// 3. If the output is exist, compare with it and report error if output is not match.
132
152
std::cerr << "a = 100" << std::endl;
133
153
@@ -137,26 +157,6 @@ TEST_CASE("match ostream") {
137
157
138
158
Once you set `ZEROERR_HAVE_SAME_OUTPUT` marco, the system will check the output stream and save the first run result into a file. Then, the next run will compare the result to see if it the same. (Currently experimental)
139
159
140
-
Finally, for the log system, the unit testing can access the log data to ensure that the function has executed the expected logic and results.
141
-
142
-
```c++
143
-
118 static void function() {
144
-
119 LOG("function log {i}", 1);
145
-
120 LOG("function log {sum}, {i}", 10, 1);
146
-
121 }
147
-
...
148
-
149
-
TEST_CASE("access log in Test case") {
150
-
zeroerr::suspendLog();
151
-
function();
152
-
CHECK(LOG_GET(function, 119, i, int) == 1);
153
-
CHECK(LOG_GET(function, 120, sum, int) == 10);
154
-
CHECK(LOG_GET(function, 120, i, int) == 1);
155
-
zeroerr::resumeLog();
156
-
}
157
-
```
158
-
159
-
In order to access the log, we need to pause the log system first, to avoid the data being output to the file, then call the function, access the data in the log through the `LOG_GET` macro, and finally resume the log system. (Currently experimental, only the first call of each log point can be accessed)
160
160
161
161
## 3. Fuzzing Support
162
162
@@ -200,10 +200,10 @@ Here are a list of features we provided:
200
200
You can only include what you need. If you need only assertion but no unit testing, no problem.
201
201
202
202
2. Optional thread safety
203
-
You can choose to build with/without thread safety. For some simple single thread program, log is no need to be multithread safed.
203
+
You can choose to build with/without thread safety.
204
204
205
205
3. Fastest log
206
-
Using a lock-free queue for logging and multiple level of log writing policies. You can choose to only write to disk with the most important events.
206
+
Multiple level of log writing policies. You can choose to only write to disk with the most important events.
207
207
208
208
4. Customized print / log / assert printing format
209
209
You can customize your printing format for everything. There is a templated callback function for the printing.
@@ -223,7 +223,7 @@ You can use your unit test as a documentation of function behavior. The output o
223
223
After assertion failed, the logging result will print automatically even if you didn't redirect to your error stream
224
224
225
225
10. Logging Category
226
-
Logging information can have customized category and only display one categroy based on your assertion or configuration
226
+
Logging information can have customized category and only display one category based on your assertion or configuration
227
227
228
228
11. Logging for Unit Testing
229
229
You can use a correct logging result as your unit testing golden file. So you just need to manually verify your log once and save it. The unit testing framework will use the golden file to verify your unit testing result.
@@ -239,7 +239,7 @@ While logging at the end, we can record the time consuming for this function.
0 commit comments