diff options
author | eug-vs <eugene@eug-vs.xyz> | 2022-09-14 04:41:50 +0300 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2022-09-14 04:41:50 +0300 |
commit | 031ccb2d9e7993ed46bd40a5c3c78af86cb46ba4 (patch) | |
tree | 6f95027d51b093f72c1e33f57da176a02d7819d4 /src/unittest.c | |
parent | efa8671eecdabcdccecde87c1d05acbc89295f49 (diff) | |
download | j1chess-031ccb2d9e7993ed46bd40a5c3c78af86cb46ba4.tar.gz |
test: group unittests into sections
Diffstat (limited to 'src/unittest.c')
-rw-r--r-- | src/unittest.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/unittest.c b/src/unittest.c index 753dac3..e4f7929 100644 --- a/src/unittest.c +++ b/src/unittest.c @@ -3,6 +3,7 @@ #include "unittest.h" static int TOTAL = 0; +static int SECTION_TOTAL = 0; static int SUCCESS = 0; @@ -16,10 +17,16 @@ bool assert(bool expression, const char* message) { void unit_test(bool expression, const char* subject) { TOTAL++; - printf( "%d. %s: %s\n", TOTAL, subject, expression? draw(GRN, PASS) : draw(RED, FAIL)); + SECTION_TOTAL++; + printf( "%d.%d %s: %s\n", TOTAL, SECTION_TOTAL, subject, expression? draw(GRN, PASS) : draw(RED, FAIL)); if (expression) SUCCESS++; } +void start_test_section(const char* name) { + printf("%s %s %s\n", CYAN, name, RESET); + SECTION_TOTAL = 0; +} + double coverage() { return 100 * (TOTAL? (double)SUCCESS/TOTAL : 1); } |