diff options
Diffstat (limited to 'src/common/test.h')
-rw-r--r-- | src/common/test.h | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/common/test.h b/src/common/test.h index 34845146d..99abc0b5a 100644 --- a/src/common/test.h +++ b/src/common/test.h @@ -49,21 +49,28 @@ extern int have_failed; return; \ } STMT_END -#define test_eq(expr1, expr2) \ - STMT_BEGIN \ - long v1=(long)(expr1), v2=(long)(expr2); \ - if (v1==v2) { printf("."); fflush(stdout); } else { \ - have_failed = 1; \ - printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n"\ - " (%ld != %ld)\n", \ - _SHORT_FILE_, \ - __LINE__, \ - PRETTY_FUNCTION, \ - #expr1, #expr2, \ - v1, v2); \ - return; \ +#define test_eq_type(tp, fmt, expr1, expr2) \ + STMT_BEGIN \ + tp v1=(tp)(expr1); \ + tp v2=(tp)(expr2); \ + if (v1==v2) { printf("."); fflush(stdout); } else { \ + have_failed = 1; \ + printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n" \ + " "fmt "!="fmt"\n", \ + _SHORT_FILE_, \ + __LINE__, \ + PRETTY_FUNCTION, \ + #expr1, #expr2, \ + v1, v2); \ + return; \ } STMT_END +#define test_eq(expr1, expr2) \ + test_eq_type(long, "%ld", expr1, expr2) + +#define test_eq_ptr(expr1, expr2) \ + test_eq_type(void*, "%p", expr1, expr2) + #define test_neq(expr1, expr2) \ STMT_BEGIN \ long v1=(long)(expr1), v2=(long)(expr2); \ |