From: Joel Rosdahl Date: Sun, 1 Aug 2010 16:20:01 +0000 (+0200) Subject: testfw: Print passed assertions in verbose mode X-Git-Tag: v3.1~115 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=feb1e2d7b4cc2d93308001ecf1764989b7b65837;p=thirdparty%2Fccache.git testfw: Print passed assertions in verbose mode --- diff --git a/test/framework.c b/test/framework.c index 527790ff2..87a475b5e 100644 --- a/test/framework.c +++ b/test/framework.c @@ -173,9 +173,12 @@ void cct_test_end() } void -cct_check_passed(void) +cct_check_passed(const char *file, int line, const char *what) { ++passed_asserts; + if (verbose) { + printf("%s:%d: Passed assertion: %s\n", file, line, what); + } } void @@ -201,7 +204,7 @@ cct_check_int_eq(const char *file, int line, const char *expression, int expected, int actual) { if (expected == actual) { - cct_check_passed(); + cct_check_passed(file, line, expression); return 1; } else { char *exp_str = format("%i", expected); @@ -218,7 +221,7 @@ cct_check_uns_eq(const char *file, int line, const char *expression, unsigned expected, unsigned actual) { if (expected == actual) { - cct_check_passed(); + cct_check_passed(file, line, expression); return 1; } else { char *exp_str = format("%i", expected); @@ -237,7 +240,7 @@ cct_check_str_eq(const char *file, int line, const char *expression, int result; if (expected && actual && str_eq(actual, expected)) { - cct_check_passed(); + cct_check_passed(file, line, expression); result = 1; } else { char *exp_str = expected ? format("\"%s\"", expected) : x_strdup("(null)"); @@ -265,7 +268,7 @@ cct_check_args_eq(const char *file, int line, const char *expression, int result; if (expected && actual && args_equal(actual, expected)) { - cct_check_passed(); + cct_check_passed(file, line, expression); result = 1; } else { char *exp_str = expected ? args_to_string(expected) : x_strdup("(null)"); diff --git a/test/framework.h b/test/framework.h index 55c98793d..90afdaa90 100644 --- a/test/framework.h +++ b/test/framework.h @@ -52,7 +52,7 @@ #define CHECK(assertion) \ do { \ if ((assertion)) { \ - cct_check_passed(); \ + cct_check_passed(__FILE__, __LINE__, #assertion); \ } else { \ cct_check_failed(__FILE__, __LINE__, #assertion, NULL, NULL); \ cct_test_end(); \ @@ -127,7 +127,7 @@ void cct_suite_begin(const char *name); void cct_suite_end(); void cct_test_begin(const char *name); void cct_test_end(); -void cct_check_passed(void); +void cct_check_passed(const char *file, int line, const char *assertion); void cct_check_failed(const char *file, int line, const char *assertion, const char *expected, const char *actual); int cct_check_int_eq(const char *file, int line, const char *expression,