mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
Add two small tests for tor_sscanf
This commit is contained in:
parent
fa4ca5ddc1
commit
6beec6a373
@ -1288,6 +1288,11 @@ test_util_sscanf(void)
|
|||||||
/* No '%'-strings: always "success" */
|
/* No '%'-strings: always "success" */
|
||||||
test_eq(0, tor_sscanf("hello world", "hello world"));
|
test_eq(0, tor_sscanf("hello world", "hello world"));
|
||||||
test_eq(0, tor_sscanf("hello world", "good bye"));
|
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) */
|
/* Numbers (ie. %u) */
|
||||||
test_eq(0, tor_sscanf("hello world 3", "hello worlb %u", &u1)); /* d vs b */
|
test_eq(0, tor_sscanf("hello world 3", "hello worlb %u", &u1)); /* d vs b */
|
||||||
|
Loading…
Reference in New Issue
Block a user