]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
testfw: Print passed assertions in verbose mode
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 1 Aug 2010 16:20:01 +0000 (18:20 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 1 Aug 2010 16:20:01 +0000 (18:20 +0200)
test/framework.c
test/framework.h

index 527790ff236307009b219f09bc483ce83d12ff3e..87a475b5ec2465331596c3dd81d29fa91c64e661 100644 (file)
@@ -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)");
index 55c98793d921c07e81654f431988ce5a25e9b4ea..90afdaa905745cea460b8b40377ad79b0e28c7ce 100644 (file)
@@ -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,