diff options
author | Esteban Manchado Velázquez <emanchado@demiurgo.org> | 2012-02-20 22:53:08 +0100 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-03-08 21:16:46 -0500 |
commit | dbd170f752b422004835def53f84b786f32c9a08 (patch) | |
tree | 76b4988aae3f42cca9adb935b42936eadde8f263 /src/test/test_util.c | |
parent | 8e88377905edd10df10da1fc39dfe247c2270663 (diff) | |
download | tor-dbd170f752b422004835def53f84b786f32c9a08.tar.gz tor-dbd170f752b422004835def53f84b786f32c9a08.zip |
Some more corner cases for tor_sscanf
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r-- | src/test/test_util.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index c63f97d7f6..e2050f8d77 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -1379,10 +1379,14 @@ test_util_sscanf(void) char s1[10], s2[10], s3[10], ch; int r; - /* Simple tests (malformed patterns and literal matching) */ + /* Simple tests (malformed patterns, literal matching, ...) */ test_eq(-1, tor_sscanf("123", "%i", &r)); /* %i is not supported */ test_eq(-1, tor_sscanf("wrong", "%5c", s1)); /* %c cannot have a number. */ test_eq(-1, tor_sscanf("hello", "%s", s1)); /* %s needs a number. */ + test_eq(-1, tor_sscanf("prettylongstring", "%999999s", s1)); + test_eq(-1, tor_sscanf("prettylongstring", "%0s", s1)); + test_eq(-1, tor_sscanf("We're the 99 monkeys", "We're the 99%%")); + test_eq(0, tor_sscanf("prettylongstring", "%10s", NULL)); /* No '%'-strings: always "success" */ test_eq(0, tor_sscanf("hello world", "hello world")); test_eq(0, tor_sscanf("hello world", "good bye")); @@ -1477,6 +1481,8 @@ test_util_sscanf(void) test_eq(2, tor_sscanf("76trombones", "%6u%9s", &u1, s1)); /* %u%s */ test_eq(76, u1); test_streq(s1, "trombones"); + test_eq(1, tor_sscanf("prettylongstring", "%999s", s1)); + test_streq(s1, "prettylongstring"); /* %s doesn't eat spaces */ test_eq(2, tor_sscanf("hello world", "%9s %9s", s1, s2)); test_streq(s1, "hello"); |