[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Add two small tests for tor_sscanf
commit 6beec6a37338216f53e5e319c60005c1b970419a
Author: Esteban Manchado Velázquez <emanchado@xxxxxxxxxxxx>
Date: Mon Feb 20 17:00:16 2012 +0100
Add two small tests for tor_sscanf
---
src/test/test_util.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 7625e2f..6c14718 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 */
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits