aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-08-03 07:03:29 -0400
committerNick Mathewson <nickm@torproject.org>2018-08-03 07:03:29 -0400
commit622a057e7e5d9f757d040283c7089d1fab847ae3 (patch)
tree12bc2d934283defbef8b5331201f2d850656318b /src/test
parentaf97879446b025c91ec6f27ae463a9e656806a08 (diff)
parentee12c11dd4e81d44020ded9f275ec030de0a2d1f (diff)
downloadtor-622a057e7e5d9f757d040283c7089d1fab847ae3.tar.gz
tor-622a057e7e5d9f757d040283c7089d1fab847ae3.zip
Merge remote-tracking branch 'public/string_coverage'
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_util.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 99fee4c5a5..888038bea5 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -3163,6 +3163,21 @@ test_util_sscanf(void *arg)
test_feq(d3, -900123123.2000787);
test_feq(d4, 3.2);
+ /* missing float */
+ r = tor_sscanf("3 ", "%d %lf", &int1, &d1);
+ tt_int_op(r, OP_EQ, 1);
+ tt_int_op(int1, OP_EQ, 3);
+
+ /* not a float */
+ r = tor_sscanf("999 notafloat", "%d %lf", &int1, &d1);
+ tt_int_op(r, OP_EQ, 1);
+ tt_int_op(int1, OP_EQ, 999);
+
+ /* %s but no buffer. */
+ char *nullbuf = NULL;
+ r = tor_sscanf("hello", "%3s", nullbuf);
+ tt_int_op(r, OP_EQ, 0);
+
done:
tor_free(huge);
}