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

9
9
10
10
11
-
12
11
ZeroErr is a smart assert library, a lightweight unit test framework and a quick logging framework. It integrates those features and provided an unite and clear interface for seperate using or joint using.
Note: The project is currently in the experimental stage, and the API may change significantly. It is not recommended to use it in a production environment.
15
16
16
-
[Introducation of Print Feature](./docs/print.en.md)
17
17
18
18
## Why we need another unit testing framework
19
19
@@ -138,6 +138,28 @@ TEST_CASE("match ostream") {
138
138
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
139
140
140
141
+
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.
142
+
143
+
```c++
144
+
118 static void function() {
145
+
119 LOG("function log {i}", 1);
146
+
120 LOG("function log {sum}, {i}", 10, 1);
147
+
121 }
148
+
...
149
+
150
+
TEST_CASE("access log in Test case") {
151
+
zeroerr::suspendLog();
152
+
function();
153
+
CHECK(LOG_GET(function, 119, i, int) == 1);
154
+
CHECK(LOG_GET(function, 120, sum, int) == 10);
155
+
CHECK(LOG_GET(function, 120, i, int) == 1);
156
+
zeroerr::resumeLog();
157
+
}
158
+
```
159
+
160
+
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)
Copy file name to clipboardExpand all lines: docs/en/introduction.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -125,6 +125,30 @@ Once you set `ZEROERR_HAVE_SAME_OUTPUT` marco, the system will check the output
125
125
126
126
127
127
128
+
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.
129
+
130
+
```c++
131
+
118staticvoidfunction() {
132
+
119 LOG("function log {i}", 1);
133
+
120 LOG("function log {sum}, {i}", 10, 1);
134
+
121 }
135
+
...
136
+
137
+
TEST_CASE("access log in Test case") {
138
+
zeroerr::suspendLog();
139
+
function();
140
+
CHECK(LOG_GET(function, 119, i, int) == 1);
141
+
CHECK(LOG_GET(function, 120, sum, int) == 10);
142
+
CHECK(LOG_GET(function, 120, i, int) == 1);
143
+
zeroerr::resumeLog();
144
+
}
145
+
```
146
+
147
+
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)
0 commit comments