klibc-bot for maximilian attems
2013-Aug-21 09:54 UTC
[klibc] [klibc:master] tests: Fix sscanf integer tests
Commit-ID: 686f1931b7dc102c32b59db638a3082d5c2251e5 Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=686f1931b7dc102c32b59db638a3082d5c2251e5 Author: maximilian attems <max at stro.at> AuthorDate: Mon, 10 Jun 2013 18:15:43 -0400 Committer: maximilian attems <max at stro.at> CommitDate: Wed, 21 Aug 2013 11:50:43 +0200 tests: Fix sscanf integer tests Drop the double tests that klibc doesn't care about and that where hence failing in the first place. Check the returned integer values too. Fixes Bug: https://bugs.gentoo.org/show_bug.cgi?id=464908 Reported-by: Mike Pagano <mpagano at gentoo.org> Signed-off-by: maximilian attems <max at stro.at> --- usr/klibc/tests/sscanf.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/usr/klibc/tests/sscanf.c b/usr/klibc/tests/sscanf.c index 0102ee3..c06aae4 100644 --- a/usr/klibc/tests/sscanf.c +++ b/usr/klibc/tests/sscanf.c @@ -3,35 +3,32 @@ int main() { int ret, err = 0, e1, e2; - double d1, d2; - const char j1[] = "3.0E+10", j2[] = "12E-01-0.1E-2"; const char a1[] = "3.0", a2[] = "-12,1000"; - /* XXX: check sscanf returned values too */ - - /* double tests */ - ret = sscanf(j1, "%11lf", &d1); - if (ret != 1) { - printf("Error wrong sscanf double return %d.\n", ret); - err++; - } - ret = sscanf(j2, "%11lf%11lf", &d1, &d2); - if (ret != 2) { - printf("Error wrong sscanf double return %d.\n", ret); - err++; - } - /* int tests */ ret = sscanf(a1, "%1d", &e1); if (ret != 1) { printf("Error wrong sscanf int return %d.\n", ret); err++; } - ret = sscanf(a2, "%1d%2d", &e1, &e2); + if (e1 != 3) { + printf("Error wrong sscanf int reading %d.\n", e1); + err++; + } + ret = sscanf(a2, "%3d,%4d", &e1, &e2); if (ret != 2) { printf("Error wrong sscanf int return %d.\n", ret); err++; } + if (e1 != -12) { + printf("Error wrong sscanf int reading %d.\n", e1); + err++; + } + if (e2 != 1000) { + printf("Error wrong sscanf int reading %d.\n", e2); + err++; + } + /* XXX: add more int tests */ if (err) return err;
Maybe Matching Threads
- [PATCH 1/1] tests: Fix sscanf test where width = 1 and integer is negative
- [PATCH 1/1, RESEND] tests: Fix sscanf test where width = 1 and integer is negative
- [PATCH 1/1] Modify --param support to include additional option
- [PATCH] support the gcc parameter --param in klcc
- [PATCH 1/1] tests: Fix sscanf test where width = 1 and integer is negative