diff options
author | Richard Braun <rbraun@sceen.net> | 2017-06-11 00:46:52 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2017-06-11 00:46:52 +0200 |
commit | 62eebd19dfd71a16df670590d0c61fbd50f18d24 (patch) | |
tree | 11e899fa69c73ab5e80a164bd9827fc8cebd7691 /test/test_fmt_sscanf.c | |
parent | 77a2a8ad9c3590e04b49cdd64b5e5a342afa1d60 (diff) |
fmt: fix 0 and octal integer parsing
Diffstat (limited to 'test/test_fmt_sscanf.c')
-rw-r--r-- | test/test_fmt_sscanf.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/test_fmt_sscanf.c b/test/test_fmt_sscanf.c index b2a4e74..8abab69 100644 --- a/test/test_fmt_sscanf.c +++ b/test/test_fmt_sscanf.c @@ -677,6 +677,38 @@ test_38(void) #undef STRING } +static void +test_39(void) +{ + int reta, retb; + unsigned int ia, ib; + +#define STRING "0" +#define FORMAT "%u" + reta = sscanf(STRING, FORMAT, &ia); + retb = fmt_sscanf(STRING, FORMAT, &ib); + check(reta == retb); + check(ia == ib); +#undef FORMAT +#undef STRING +} + +static void +test_40(void) +{ + int reta, retb; + int ia, ib; + +#define STRING "-0" +#define FORMAT "%d" + reta = sscanf(STRING, FORMAT, &ia); + retb = fmt_sscanf(STRING, FORMAT, &ib); + check(reta == retb); + check(ia == ib); +#undef FORMAT +#undef STRING +} + int main(int argc, char *argv[]) { @@ -721,6 +753,8 @@ main(int argc, char *argv[]) test_36(); test_37(); test_38(); + test_39(); + test_40(); return 0; } |