aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-01-13 16:38:48 -0500
committerNick Mathewson <nickm@torproject.org>2014-01-17 11:58:09 -0500
commit8a49fac9e0e201d0d1774c066bc6984ed7773401 (patch)
tree67fc9572a9d2858313271de8ca00d654412aee24
parentab0fdbb618f52effad41625e88ee341e402a4d6d (diff)
downloadtor-8a49fac9e0e201d0d1774c066bc6984ed7773401.tar
tor-8a49fac9e0e201d0d1774c066bc6984ed7773401.tar.gz
Coverate in util.c: test that tor_parse_* rejects negative base.
-rw-r--r--src/test/test_util.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 376e3aab8..9104088c9 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -1027,6 +1027,8 @@ test_util_strmisc(void)
test_eq(0L, tor_parse_long("10",-2,0,100,NULL,NULL));
test_eq(68284L, tor_parse_long("10abc",16,0,70000,NULL,NULL));
test_eq(68284L, tor_parse_long("10ABC",16,0,70000,NULL,NULL));
+ test_eq(0, tor_parse_long("10ABC",-1,0,70000,&i,NULL));
+ test_eq(i, 0);
/* Test parse_ulong */
test_eq(0UL, tor_parse_ulong("",10,0,100,NULL,NULL));
@@ -1038,6 +1040,8 @@ test_util_strmisc(void)
test_eq(0UL, tor_parse_ulong("8",8,0,100,NULL,NULL));
test_eq(50UL, tor_parse_ulong("50",10,50,100,NULL,NULL));
test_eq(0UL, tor_parse_ulong("-50",10,-100,100,NULL,NULL));
+ test_eq(0UL, tor_parse_ulong("50",-1,50,100,&i,NULL));
+ test_eq(0, i);
/* Test parse_uint64 */
test_assert(U64_LITERAL(10) == tor_parse_uint64("10 x",10,0,100, &i, &cp));
@@ -1050,6 +1054,9 @@ test_util_strmisc(void)
test_assert(U64_LITERAL(0) ==
tor_parse_uint64("12345678901",10,500,INT32_MAX, &i, &cp));
test_eq(0, i);
+ test_assert(U64_LITERAL(0) ==
+ tor_parse_uint64("123",-1,0,INT32_MAX, &i, &cp));
+ test_eq(0, i);
{
/* Test parse_double */