[klibc] [klibc:master] tests: Add simple sscanf check
klibc-bot for maximilian attems
max at stro.at
Tue May 22 00:06:02 PDT 2012
Commit-ID: 72a6e871639c36b949c6aa3d8429100e63d20796
Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=72a6e871639c36b949c6aa3d8429100e63d20796
Author: maximilian attems <max at stro.at>
AuthorDate: Tue, 22 May 2012 08:53:36 +0200
Committer: maximilian attems <max at stro.at>
CommitDate: Tue, 22 May 2012 09:00:43 +0200
[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 at stro.at>
---
usr/klibc/tests/Kbuild | 1 +
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 d7f1d51..c7ca531 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 0000000..0102ee3
--- /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;
+}
More information about the klibc
mailing list