diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-03-06 20:25:44 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-03-06 20:25:44 +0000 |
commit | 5d1bee87ffe3dcdaa9e7960b0fed836aa1d01b9b (patch) | |
tree | 5f9aea61df183fd3a5b88223789babc1fb859a67 /src/common/test.h | |
parent | c9e2766e7598a669d3acf3ae0e45e8be8b5945b0 (diff) | |
download | tor-5d1bee87ffe3dcdaa9e7960b0fed836aa1d01b9b.tar.gz tor-5d1bee87ffe3dcdaa9e7960b0fed836aa1d01b9b.zip |
r12468@Kushana: nickm | 2007-03-06 15:24:00 -0500
More unit tests: gcov is fun.
svn:r9748
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 9edda8d296..41b795a89a 100644 --- a/src/common/test.h +++ b/src/common/test.h @@ -71,21 +71,28 @@ extern int have_failed; #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); \ - 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_neq_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_neq(expr1, expr2) \ + test_neq_type(long, "%ld", expr1, expr2) + +#define test_neq_ptr(expr1, expr2) \ + test_neq_type(void *, "%p", expr1, expr2) + #define test_streq(expr1, expr2) \ STMT_BEGIN \ const char *v1=(expr1), *v2=(expr2); \ |