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: Contributing.en.md
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,3 +8,14 @@ We encourage developers to contribute to this project, but please follow the rul
8
8
5. Please make sure to use English for comments in the code to avoid compiler encoding problems
9
9
6. Make sure that the modified project has been completely built once, so that the merged version `zeroerr.hpp` file in the root directory is consistent with the source code
10
10
7. We welcome the extension of special environment use and the integration of third-party libraries. Please put these extensions in the extension directory
11
+
12
+
13
+
## Tips
14
+
15
+
### Enable the pre-commit hook
16
+
This hook script can help auto build and test the project before you submit a commit:
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)
0 commit comments