Mercurial > hg > th-libs
changeset 363:68e8ad3327b8
Improve tests output.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 25 Feb 2016 12:19:10 +0200 |
parents | a688d34c11d4 |
children | f2e6e3352f2d |
files | tests.c |
diffstat | 1 files changed, 17 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/tests.c Thu Feb 25 11:59:06 2016 +0200 +++ b/tests.c Thu Feb 25 12:19:10 2016 +0200 @@ -12,6 +12,7 @@ typedef struct { char *header, *res; + BOOL shown; } test_ctx; @@ -33,19 +34,26 @@ static const int arg_nopts = sizeof(arg_opts) / sizeof(arg_opts[0]); -void tprintv(const int level, const char *fmt, va_list ap) +BOOL tprintv(const int level, const char *fmt, va_list ap) { if (level <= th_verbosityLevel) + { vfprintf(stdout, fmt, ap); + return TRUE; + } + else + return FALSE; } -void tprint(const int level, const char *fmt, ...) +BOOL tprint(const int level, const char *fmt, ...) { + BOOL retv; va_list ap; va_start(ap, fmt); - tprintv(level, fmt, ap); + retv = tprintv(level, fmt, ap); va_end(ap); + return retv; } @@ -146,12 +154,16 @@ { if (check) { - tprint(2, "%s: OK\n", ctx->header); + if (!ctx->shown && tprint(2, "%s: OK\n", ctx->header)) + ctx->shown = TRUE; + tests_passed++; } else { - tprint(0, "%s: FAIL\n", ctx->header); + if (!ctx->shown && tprint(0, "%s: FAIL\n", ctx->header)) + ctx->shown = TRUE; + if (fmt != NULL) { tprint(0, " - ");