aboutsummaryrefslogtreecommitdiff
path: root/src/ext
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/ext
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/ext')
-rw-r--r--src/ext/tinytest_macros.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/ext/tinytest_macros.h b/src/ext/tinytest_macros.h
index 9ff69b1d5..5bb8f8ec6 100644
--- a/src/ext/tinytest_macros.h
+++ b/src/ext/tinytest_macros.h
@@ -144,6 +144,10 @@
tt_assert_test_fmt_type(a,b,str_test,type,test,type,fmt, \
{print_=value_;},{},die_on_fail)
+#define tt_assert_test_type_opt(a,b,str_test,type,test,fmt,die_on_fail) \
+ tt_assert_test_fmt_type(a,b,str_test,type,test,type,fmt, \
+ {print_=value_?value_:"<NULL>";},{},die_on_fail)
+
/* Helper: assert that a op b, when cast to type. Format the values with
* printf format fmt on failure. */
#define tt_assert_op_type(a,op,b,type,fmt) \
@@ -163,8 +167,9 @@
(val1_ op val2_),"%p",TT_EXIT_TEST_FUNCTION)
#define tt_str_op(a,op,b) \
- tt_assert_test_type(a,b,#a" "#op" "#b,const char *, \
- (strcmp(val1_,val2_) op 0),"<%s>",TT_EXIT_TEST_FUNCTION)
+ tt_assert_test_type_opt(a,b,#a" "#op" "#b,const char *, \
+ (val1_ && val2_ && strcmp(val1_,val2_) op 0),"<%s>", \
+ TT_EXIT_TEST_FUNCTION)
#define tt_want_int_op(a,op,b) \
tt_assert_test_type(a,b,#a" "#op" "#b,long,(val1_ op val2_),"%ld",(void)0)