diff options
author | Thomas Schwinge <thomas@codesourcery.com> | 2013-12-20 09:29:29 +0100 |
---|---|---|
committer | Thomas Schwinge <thomas@codesourcery.com> | 2013-12-20 09:29:29 +0100 |
commit | a65dd355fb80a05215e15ae97649de52aec885e3 (patch) | |
tree | 81701bb0c6b648630f2bf1729a85d7f5eb49e67b /stdio-common/tst-sscanf.c | |
parent | 296a5732f94abe4d5699dc981e4ccfb950b48cee (diff) | |
parent | b4578bab30f72cddd2cf38abfb39f9c8dc892249 (diff) |
Merge branch 'baseline' into refs/top-bases/tschwinge/Roger_Whittaker
Diffstat (limited to 'stdio-common/tst-sscanf.c')
-rw-r--r-- | stdio-common/tst-sscanf.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/stdio-common/tst-sscanf.c b/stdio-common/tst-sscanf.c index 1edb227199..a77bc7e30b 100644 --- a/stdio-common/tst-sscanf.c +++ b/stdio-common/tst-sscanf.c @@ -92,6 +92,8 @@ struct test { L("foo bar"), L("foo bar"), 0 }, { L("foo bar"), L("foo %d"), 0 }, { L("foo bar"), L("foon%d"), 0 }, + { L("foo (nil)"), L("foo %p"), 1}, + { L("foo (nil)"), L("foo %4p"), 0}, { L("foo "), L("foo %n"), 0 }, { L("foo%bar1"), L("foo%%bar%d"), 1 }, /* Some OSes skip whitespace here while others don't. */ @@ -109,6 +111,19 @@ struct test double_tests[] = { L("-inf"), L("%g"), 1 } }; +struct test2 +{ + const CHAR *str; + const CHAR *fmt; + int retval; + char residual; +} double_tests2[] = +{ + { L("0e+0"), L("%g%c"), 1, 0 }, + { L("0xe+0"), L("%g%c"), 2, '+' }, + { L("0x.e+0"), L("%g%c"), 2, '+' }, +}; + int main (void) { @@ -196,5 +211,26 @@ main (void) } } + for (i = 0; i < sizeof (double_tests2) / sizeof (double_tests2[0]); ++i) + { + double dummy; + int ret; + char c = 0; + + if ((ret = SSCANF (double_tests2[i].str, double_tests2[i].fmt, + &dummy, &c)) != double_tests2[i].retval) + { + printf ("double_tests2[%d] returned %d != %d\n", + i, ret, double_tests2[i].retval); + result = 1; + } + else if (ret == 2 && c != double_tests2[i].residual) + { + printf ("double_tests2[%d] stopped at '%c' != '%c'\n", + i, c, double_tests2[i].residual); + result = 1; + } + } + return result; } |