new test framework (one main per test)
[libc-test] / src / stdlib / wcstol.c
index fe8d747..abd76af 100644 (file)
@@ -13,7 +13,8 @@
        ((r) = (f)) == (x) || \
        (error("%s failed (" m ")\n", msg, r, x), 0) )
 
-void test_wcstol(void) {
+int main(void)
+{
        int i;
        long l;
        unsigned long ul;
@@ -33,18 +34,18 @@ void test_wcstol(void) {
                TEST(ul, wcstoul(s=L"4294967296", &c, 0), 4294967295UL, "uncaught overflow %lu != %lu");
                TEST2(i, c-s, 10, "wrong final position %d != %d");
                TEST2(i, errno, ERANGE, "missing errno %d != %d");
-               TEST(ul, wcstoul(s=L"-1", &c, 0), 4294967295UL, "uncaught overflow %lu != %lu");
+               TEST(ul, wcstoul(s=L"-1", &c, 0), -1UL, "rejected negative %lu != %lu");
                TEST2(i, c-s, 2, "wrong final position %d != %d");
-               TEST2(i, errno, ERANGE, "missing errno %d != %d");
-               TEST(ul, wcstoul(s=L"-2", &c, 0), 4294967295UL, "uncaught overflow %lu != %lu");
+               TEST2(i, errno, 0, "spurious errno %d != %d");
+               TEST(ul, wcstoul(s=L"-2", &c, 0), -2UL, "rejected negative %lu != %lu");
                TEST2(i, c-s, 2, "wrong final position %d != %d");
-               TEST2(i, errno, ERANGE, "missing errno %d != %d");
-               TEST(ul, wcstoul(s=L"-2147483648", &c, 0), 4294967295UL, "uncaught overflow %lu != %lu");
+               TEST2(i, errno, 0, "spurious errno %d != %d");
+               TEST(ul, wcstoul(s=L"-2147483648", &c, 0), -2147483648UL, "rejected negative %lu != %lu");
                TEST2(i, c-s, 11, "wrong final position %d != %d");
-               TEST2(i, errno, ERANGE, "missing errno %d != %d");
-               TEST(ul, wcstoul(s=L"-2147483649", &c, 0), 4294967295UL, "uncaught overflow %lu != %lu");
+               TEST2(i, errno, 0, "spurious errno %d != %d");
+               TEST(ul, wcstoul(s=L"-2147483649", &c, 0), -2147483649UL, "rejected negative %lu != %lu");
                TEST2(i, c-s, 11, "wrong final position %d != %d");
-               TEST2(i, errno, ERANGE, "missing errno %d != %d");
+               TEST2(i, errno, 0, "spurious errno %d != %d");
        } else {
                TEST(i, 0, 1, "64bit tests not implemented");
        }
@@ -62,4 +63,5 @@ void test_wcstol(void) {
        TEST(l, wcstol(s=L"123", &c, 37), 0, "%ld != %ld");
        TEST2(i, c-s, 0, "wrong final position %d != %d");
        TEST2(i, errno, EINVAL, "%d != %d");
+       return test_status;
 }