aboutsummaryrefslogtreecommitdiff
path: root/src/test/test.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-03-06 12:12:13 -0500
committerNick Mathewson <nickm@torproject.org>2014-03-06 12:12:13 -0500
commit065097b81bad3326a9bd536fbdf646f408638a94 (patch)
treef4601fb374fa2750f68268e6481b3337bea3d38f /src/test/test.h
parenta50690e68f8a332321e88f0ac8c3046186bc1c1f (diff)
downloadtor-065097b81bad3326a9bd536fbdf646f408638a94.tar
tor-065097b81bad3326a9bd536fbdf646f408638a94.tar.gz
tinytest tt_{mem,str}_op now handle NULLs better
Now a NULL argument to either makes it fail, not crash. Fies bug 9004; bugfix on 0.2.2.4-alpha.
Diffstat (limited to 'src/test/test.h')
-rw-r--r--src/test/test.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/test/test.h b/src/test/test.h
index a89b558e5..b902c6e47 100644
--- a/src/test/test.h
+++ b/src/test/test.h
@@ -38,12 +38,17 @@
#define test_mem_op(expr1, op, expr2, len) \
tt_assert_test_fmt_type(expr1,expr2,#expr1" "#op" "#expr2, \
const char *, \
- (memcmp(val1_, val2_, len) op 0), \
+ (val1_ && val2_ && memcmp(val1_, val2_, len) op 0), \
char *, "%s", \
{ size_t printlen = (len)*2+1; \
- print_ = tor_malloc(printlen); \
- base16_encode(print_, printlen, value_, \
- (len)); }, \
+ if (value_) { \
+ print_ = tor_malloc(printlen); \
+ base16_encode(print_, printlen, value_, \
+ (len)); \
+ } else { \
+ print_ = tor_strdup("null"); \
+ } \
+ }, \
{ tor_free(print_); }, \
TT_EXIT_TEST_FUNCTION \
);