diff options
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); } |