aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormaximilian attems <max@stro.at>2013-06-10 18:15:43 -0400
committermaximilian attems <max@stro.at>2013-08-21 11:50:43 +0200
commit686f1931b7dc102c32b59db638a3082d5c2251e5 (patch)
tree0fe720ca45d26d9413168ba19f00ba255c6285df
parentddd013b7f83367317cf16d529936bc6abdd4ed80 (diff)
downloadklibc-686f1931b7dc102c32b59db638a3082d5c2251e5.tar.gz
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@gentoo.org> Signed-off-by: maximilian attems <max@stro.at>
-rw-r--r--usr/klibc/tests/sscanf.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/usr/klibc/tests/sscanf.c b/usr/klibc/tests/sscanf.c
index 0102ee339bf317..c06aae47de4901 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;