diff options
author | Jakob Kaivo <jkk@ung.org> | 2019-02-28 20:33:28 -0500 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2019-02-28 20:33:28 -0500 |
commit | 3a316e083fdcdf851ba9534a1f2e528e7e0a12b0 (patch) | |
tree | 5c1e15abaa69c4e7bf85f9e4d9b9e4a1bfe8803e | |
parent | e6a6a3b47a0da3ae477d4b832e9b1bd05f4a8128 (diff) |
clean up output, add verbosity option
-rw-r--r-- | test.c | 24 |
1 files changed, 18 insertions, 6 deletions
@@ -3,6 +3,7 @@ static int passed; static int failed; +int verbose = 0; typedef enum { DEFAULT = 39, @@ -29,17 +30,22 @@ static void print_result(int success, const char *format, ...) passed++; } else { color = RED; + indicator = '-'; failed++; } set_output_color(color); - printf("%c ", indicator); + putchar(indicator); - va_start(ap, format); - vprintf(format, ap); - va_end(ap); + if (verbose) { + putchar(' '); - printf("%c", success ? '\n' : '\n'); + va_start(ap, format); + vprintf(format, ap); + va_end(ap); + + putchar(success ? '\n' : '\n'); + } set_output_color(DEFAULT); } @@ -54,6 +60,10 @@ void testing_header(const char *header) void testing_end(void) { + if (!verbose) { + putchar('\n'); + } + printf("%d tests passed, %d tests failed\n", passed, failed); passed = 0; @@ -62,7 +72,9 @@ void testing_end(void) void testing_comment(const char *comment) { - printf("- %s\n", comment); + if (verbose) { + printf("- %s\n", comment); + } } void test_int_equals_imp(const char *expression, int result, int expected) |