diff options
author | maximilian attems <max@stro.at> | 2012-05-22 08:53:36 +0200 |
---|---|---|
committer | maximilian attems <max@stro.at> | 2012-05-22 09:00:43 +0200 |
commit | 72a6e871639c36b949c6aa3d8429100e63d20796 (patch) | |
tree | 6fd41629bf1d744d9794f5e54e893079411ecb0a | |
parent | 4600662f24eeee70ee28bc768cdaebb84bbc3345 (diff) | |
download | klibc-72a6e871639c36b949c6aa3d8429100e63d20796.tar.gz |
[klibc] tests: Add simple sscanf check
klibc currently fails on the double numbers.
The int part is done well.
Signed-off-by: maximilian attems <max@stro.at>
-rw-r--r-- | usr/klibc/tests/Kbuild | 1 | ||||
-rw-r--r-- | usr/klibc/tests/sscanf.c | 39 |
2 files changed, 40 insertions, 0 deletions
diff --git a/usr/klibc/tests/Kbuild b/usr/klibc/tests/Kbuild index d7f1d510b52f7..c7ca531f726db 100644 --- a/usr/klibc/tests/Kbuild +++ b/usr/klibc/tests/Kbuild @@ -38,6 +38,7 @@ setjmptest.shared-y := setjmptest.o sigint.shared-y := sigint.o sig-nodefer.shared-y := sig-nodefer.o socket.shared-y := socket.o +sscanf.shared-y := sscanf.o stat.shared-y := stat.o statfs.shared-y := statfs.o stdio.shared-y := stdio.o diff --git a/usr/klibc/tests/sscanf.c b/usr/klibc/tests/sscanf.c new file mode 100644 index 0000000000000..0102ee339bf31 --- /dev/null +++ b/usr/klibc/tests/sscanf.c @@ -0,0 +1,39 @@ +#include <stdio.h> + +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 (ret != 2) { + printf("Error wrong sscanf int return %d.\n", ret); + err++; + } + + if (err) + return err; + return 0; +} |