aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorEsteban Manchado Velázquez <emanchado@demiurgo.org>2012-02-20 17:00:16 +0100
committerNick Mathewson <nickm@torproject.org>2012-03-08 21:16:45 -0500
commit6beec6a37338216f53e5e319c60005c1b970419a (patch)
tree041d03e8752095a2a2954f9a692fc5e599e47690 /src/test
parentfa4ca5ddc1f69911fa2dab08cf6d9ea6273daae3 (diff)
downloadtor-6beec6a37338216f53e5e319c60005c1b970419a.tar.gz
tor-6beec6a37338216f53e5e319c60005c1b970419a.zip
Add two small tests for tor_sscanf
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_util.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 7625e2f5de..6c14718454 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -1288,6 +1288,11 @@ test_util_sscanf(void)
/* No '%'-strings: always "success" */
test_eq(0, tor_sscanf("hello world", "hello world"));
test_eq(0, tor_sscanf("hello world", "good bye"));
+ /* Excess data */
+ test_eq(0, tor_sscanf("hello 3", "%u", &u1)); /* have to match the start */
+ test_eq(0, tor_sscanf(" 3 hello", "%u", &u1));
+ test_eq(0, tor_sscanf(" 3 hello", "%2u", &u1)); /* not even in this case */
+ test_eq(1, tor_sscanf("3 hello", "%u", &u1)); /* but trailing is alright */
/* Numbers (ie. %u) */
test_eq(0, tor_sscanf("hello world 3", "hello worlb %u", &u1)); /* d vs b */