Skip to content

Commit 94d1bba

Browse files
committed
update
1 parent d52f796 commit 94d1bba

1 file changed

Lines changed: 30 additions & 30 deletions

File tree

Readme.en.md

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Hope you get 0 errors and 0 warnings everyday!
88
![](./docs/fig/zeroerr.jpg)
99

1010

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.
1212

1313
[English Documentation](https://sunxfancy.github.io/zeroerr/en/) | [项目文档](https://sunxfancy.github.io/zeroerr/zh/)
1414

@@ -21,7 +21,7 @@ The current popular unit testing frameworks, e.g. Catch2, doctest, Boost.Test an
2121

2222
### 1. Generic Printing
2323

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.
2525

2626
This library `zeroerr` gives you an ability to print generically for all types:
2727

@@ -36,7 +36,7 @@ Similar to other C++ unit testing frameworks, `zeroerr` will convert this piece
3636
3737
![case1](docs/fig/case1.png)
3838
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:
4040
4141
```c++
4242
struct Node {
@@ -94,9 +94,9 @@ This functin `PrintExt` will match all the class who's base class is `Value` and
9494
9595
![case3-llvm](./docs/fig/case3.png)
9696
97-
### 2. Joint using of assert, log and unit testing
97+
### 2. Combined usage of assert, log and unit testing
9898
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.
100100
101101
```c++
102102
int fib(int n) {
@@ -121,13 +121,33 @@ TEST_CASE("fib function test") {
121121

122122
![joint1](docs/fig/joint1.png)
123123

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.
125+
126+
```c++
127+
118 static void function() {
128+
119 int k = system_call();
129+
120 LOG_IF(k != 0, "System call failed, error code = {k}", k);
130+
121 }
131+
...
132+
133+
TEST_CASE("access log in Test case") {
134+
zeroerr::suspendLog();
135+
function();
136+
CHECK(LOG_GET(function, 120, k, int) == ERROR_CODE);
137+
zeroerr::resumeLog();
138+
}
139+
```
140+
141+
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+
124144
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.
125145

126146
```c++
127147
TEST_CASE("match ostream") {
128148
// match output can be done in the following workflow
129149
// 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.
131151
// 3. If the output is exist, compare with it and report error if output is not match.
132152
std::cerr << "a = 100" << std::endl;
133153

@@ -137,26 +157,6 @@ TEST_CASE("match ostream") {
137157
138158
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)
139159
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)
160160
161161
## 3. Fuzzing Support
162162
@@ -200,10 +200,10 @@ Here are a list of features we provided:
200200
You can only include what you need. If you need only assertion but no unit testing, no problem.
201201

202202
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.
204204

205205
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.
207207

208208
4. Customized print / log / assert printing format
209209
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
223223
After assertion failed, the logging result will print automatically even if you didn't redirect to your error stream
224224

225225
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
227227

228228
11. Logging for Unit Testing
229229
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.
239239
* dbg
240240
* print (without use extern functions)
241241
* assert
242-
* color (if always enable)
242+
* color (if always enabled)
243243

244244

245245
## The logo generation

0 commit comments

Comments
 (0)