From 031ccb2d9e7993ed46bd40a5c3c78af86cb46ba4 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Wed, 14 Sep 2022 04:41:50 +0300 Subject: test: group unittests into sections --- src/unittest.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/unittest.c') 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); } -- cgit v1.2.3