[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>
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 @@
 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;
+}