Index: uspace/lib/posix/source/stdio/scanf.c
===================================================================
--- uspace/lib/posix/source/stdio/scanf.c	(revision c85a57f12649ef695469bac41ca451943f828502)
+++ uspace/lib/posix/source/stdio/scanf.c	(revision e37ddde16660f8897030fbc536ff4ff973c03065)
@@ -1220,119 +1220,4 @@
 }
 
-// FIXME: put the testcases to the app/tester after scanf is included into libc
-
-#if 0
-
-//#include <stdio.h>
-//#include <malloc.h>
-//#include <string.h>
-
-#define test_val(fmt, exp_val, act_val) \
-	if (exp_val == act_val) { \
-		printf("succ, expected "fmt", actual "fmt"\n", exp_val, act_val); \
-	} else { \
-		printf("fail, expected "fmt", actual "fmt"\n", exp_val, act_val); \
-		++fail; \
-	}
-
-#define test_str(fmt, exp_str, act_str) \
-	if (posix_strcmp(exp_str, act_str) == 0) { \
-		printf("succ, expected "fmt", actual "fmt"\n", exp_str, act_str); \
-	} else { \
-		printf("fail, expected "fmt", actual "fmt"\n", exp_str, act_str); \
-		++fail; \
-	}
-
-void __posix_scanf_test(void);
-void __posix_scanf_test(void)
-{
-	int fail = 0;
-
-	int ret;
-
-	unsigned char uhh;
-	signed char shh;
-	unsigned short uh;
-	short sh;
-	unsigned udef;
-	int sdef;
-	unsigned long ul;
-	long sl;
-	unsigned long long ull;
-	long long sll;
-	void *p;
-	
-	float f;
-	double d;
-	long double ld;
-
-	char str[20];
-	char seq[20];
-	char scanset[20];
-
-	char *pstr;
-	char *pseq;
-	char *pscanset;
-	
-	ret = posix_sscanf(
-	    "\n j tt % \t -121314 98765 aqw 0765 0x77 0xABCDEF88 -99 884",
-	    " j tt %%%3hhd%1hhu%3hd %3hu%u aqw%n %lo%llx %p %li %lld",
-	    &shh, &uhh, &sh, &uh, &udef, &sdef, &ul, &ull, &p, &sl, &sll);
-	test_val("%d", -12, shh);
-	test_val("%u", 1, uhh);
-	test_val("%d", 314, sh);
-	test_val("%u", 987, uh);
-	test_val("%u", 65, udef);
-	test_val("%d", 28, sdef);
-	test_val("%lo", (unsigned long) 0765, ul);
-	test_val("%llx", (unsigned long long) 0x77, ull);
-	test_val("%p", (void *) 0xABCDEF88, p);
-	test_val("%ld", (long) -99, sl);
-	test_val("%lld", (long long) 884, sll);
-	test_val("%d", 10, ret);
-
-	ret = posix_sscanf(
-	    "\n \t\t1.0 -0x555.AP10 1234.5678e12",
-	    "%f %lf %Lf",
-	    &f, &d, &ld);
-	test_val("%f", 1.0, f);
-	test_val("%lf", (double) -0x555.AP10, d);
-	test_val("%Lf", (long double) 1234.5678e12, ld);
-	test_val("%d", 3, ret);
-	 
-	ret = posix_sscanf(
-	    "\n\n\thello world    \n",
-	    "%5s %ms",
-	    str, &pstr);
-	test_str("%s", "hello", str);
-	test_str("%s", "world", pstr);
-	test_val("%d", 2, ret);
-	free(pstr);
-
-	ret = posix_sscanf(
-	    "\n\n\thello world    \n",
-	    " %5c %mc",
-	    seq, &pseq);
-	seq[5] = '\0';
-	pseq[1] = '\0';
-	test_str("%s", "hello", seq);
-	test_str("%s", "w", pseq);
-	test_val("%d", 2, ret);
-	free(pseq);
-
-	ret = posix_sscanf(
-	    "\n\n\th-e-l-l-o world-]    \n",
-	    " %9[-eh-o] %m[^]-]",
-	    scanset, &pscanset);
-	test_str("%s", "h-e-l-l-o", scanset);
-	test_str("%s", "world", pscanset);
-	test_val("%d", 2, ret);
-	free(pscanset);
-
-	printf("Failed: %d\n", fail);
-}
-
-#endif
-
 /** @}
  */
Index: uspace/lib/posix/test/scanf.c
===================================================================
--- uspace/lib/posix/test/scanf.c	(revision c85a57f12649ef695469bac41ca451943f828502)
+++ uspace/lib/posix/test/scanf.c	(revision e37ddde16660f8897030fbc536ff4ff973c03065)
@@ -35,4 +35,5 @@
 #include <pcut/pcut.h>
 
+#define EPSILON 0.000001
 
 PCUT_INIT
@@ -62,4 +63,115 @@
 }
 
+/*
+ * The following tests were copied from stdio/scanf.c where they were
+ * commented-out. We ought to convert them to more independent tests
+ * eventually.
+ */
+
+PCUT_TEST(int_misc) {
+	unsigned char uhh;
+	signed char shh;
+	unsigned short uh;
+	short sh;
+	unsigned udef;
+	int sdef;
+	unsigned long ul;
+	long sl;
+	unsigned long long ull;
+	long long sll;
+	void *p;
+
+	int rc = posix_sscanf(
+		"\n j tt % \t -121314 98765 aqw 0765 0x77 0xABCDEF88 -99 884",
+		" j tt %%%3hhd%1hhu%3hd %3hu%u aqw%n %lo%llx %p %li %lld",
+		&shh, &uhh, &sh, &uh, &udef, &sdef, &ul, &ull, &p, &sl, &sll);
+
+	PCUT_ASSERT_INT_EQUALS(10, rc);
+
+	PCUT_ASSERT_INT_EQUALS(-12, shh);
+	PCUT_ASSERT_INT_EQUALS(1, uhh);
+	PCUT_ASSERT_INT_EQUALS(314, sh);
+	PCUT_ASSERT_INT_EQUALS(987, uh);
+	PCUT_ASSERT_INT_EQUALS(65, udef);
+	PCUT_ASSERT_INT_EQUALS(28, sdef);
+	PCUT_ASSERT_INT_EQUALS(0765, ul);
+	PCUT_ASSERT_INT_EQUALS(0x77, ull);
+	PCUT_ASSERT_INT_EQUALS(0xABCDEF88, (long long) (uintptr_t) p);
+	PCUT_ASSERT_INT_EQUALS(-99, sl);
+	PCUT_ASSERT_INT_EQUALS(884, sll);
+}
+
+PCUT_TEST(double_misc) {
+	float f;
+	double d;
+	long double ld;
+
+	int rc = posix_sscanf(
+		"\n \t\t1.0 -0x555.AP10 1234.5678e12",
+		"%f %lf %Lf",
+		&f, &d, &ld);
+
+	PCUT_ASSERT_INT_EQUALS(3, rc);
+
+	PCUT_ASSERT_DOUBLE_EQUALS(1.0, f, EPSILON);
+	PCUT_ASSERT_DOUBLE_EQUALS(-0x555.AP10, d, EPSILON);
+	PCUT_ASSERT_DOUBLE_EQUALS(1234.5678e12, ld, EPSILON);
+}
+
+PCUT_TEST(str_misc) {
+	char str[20];
+	char *pstr;
+
+	int rc = posix_sscanf(
+		"\n\n\thello world    \n",
+		"%5s %ms",
+		str, &pstr);
+
+	PCUT_ASSERT_INT_EQUALS(2, rc);
+
+	PCUT_ASSERT_STR_EQUALS("hello", str);
+	PCUT_ASSERT_STR_EQUALS("world", pstr);
+
+	free(pstr);
+}
+
+PCUT_TEST(str_matchers) {
+	char scanset[20];
+	char *pscanset;
+
+	int rc = posix_sscanf(
+		"\n\n\th-e-l-l-o world-]    \n",
+		" %9[-eh-o] %m[^]-]",
+		scanset, &pscanset);
+
+	PCUT_ASSERT_INT_EQUALS(2, rc);
+
+	PCUT_ASSERT_STR_EQUALS("h-e-l-l-o", scanset);
+	PCUT_ASSERT_STR_EQUALS("world", pscanset);
+
+	free(pscanset);
+}
+
+PCUT_TEST(char_misc) {
+	char seq[20];
+	char *pseq;
+
+	int rc = posix_sscanf(
+		"\n\n\thello world    \n",
+		" %5c %mc",
+		seq, &pseq);
+
+	PCUT_ASSERT_INT_EQUALS(2, rc);
+
+	/* Manually terminate the strings. */
+	seq[5] = 0;
+	pseq[1] = 0;
+
+	PCUT_ASSERT_STR_EQUALS("hello", seq);
+	PCUT_ASSERT_STR_EQUALS("w", pseq);
+
+	free(pseq);
+}
+
 #endif
 
