diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-02-27 08:10:28 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-02-27 08:10:28 +0000 |
commit | d14f8f2547df35434547d8e3e2b4c1a6b7736597 (patch) | |
tree | 343bbb7f97529f51b222b770b127fffcaa88273b /src/common/test.h | |
parent | 5855ca92a3bdef2624a99c141dfd1884d461d09e (diff) | |
download | tor-d14f8f2547df35434547d8e3e2b4c1a6b7736597.tar.gz tor-d14f8f2547df35434547d8e3e2b4c1a6b7736597.zip |
r14516@tombo: nickm | 2008-02-27 03:10:26 -0500
Write some unit tests for a few functions and cases that needed them.
svn:r13751
Diffstat (limited to 'src/common/test.h')
-rw-r--r-- | src/common/test.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/common/test.h b/src/common/test.h index 72dde2b007..ead2bfadd3 100644 --- a/src/common/test.h +++ b/src/common/test.h @@ -125,14 +125,20 @@ extern int have_failed; #define test_memeq(expr1, expr2, len) \ STMT_BEGIN \ const void *_test_v1=(expr1), *_test_v2=(expr2); \ + char *mem1, *mem2; \ if (!memcmp(_test_v1,_test_v2,(len))) { \ printf("."); fflush(stdout); } else { \ have_failed = 1; \ - printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n", \ + mem1 = tor_malloc(len*2+1); \ + mem2 = tor_malloc(len*2+1); \ + base16_encode(mem1, len*2+1, _test_v1, len); \ + base16_encode(mem2, len*2+1, _test_v2, len); \ + printf("\nFile %s: line %d (%s): Assertion failed: (%s==%s)\n" \ + " %s != %s\n", \ _SHORT_FILE_, \ __LINE__, \ PRETTY_FUNCTION, \ - #expr1, #expr2); \ + #expr1, #expr2, mem1, mem2); \ return; \ } STMT_END |