X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Ffunctional%2Fwcstol.c;h=2f0e8a418c28673b48ab1c1f4c893de904c0566a;hb=007ed0d41e3c6ff01cef245e9b35d62d2da87a6d;hp=abd76afda086abebeb63db9a569d020a2b01b4db;hpb=2cf89517c5b25c2524fe0c0c01ed277d7307a852;p=libc-test diff --git a/src/functional/wcstol.c b/src/functional/wcstol.c index abd76af..2f0e8a4 100644 --- a/src/functional/wcstol.c +++ b/src/functional/wcstol.c @@ -7,11 +7,11 @@ #define TEST(r, f, x, m) ( \ errno = 0, msg = #f, ((r) = (f)) == (x) || \ - (error("%s failed (" m ")\n", #f, r, x), 0) ) + (t_error("%s failed (" m ")\n", #f, r, x), 0) ) #define TEST2(r, f, x, m) ( \ ((r) = (f)) == (x) || \ - (error("%s failed (" m ")\n", msg, r, x), 0) ) + (t_error("%s failed (" m ")\n", msg, r, x), 0) ) int main(void) { @@ -46,8 +46,30 @@ int main(void) 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, 0, "spurious errno %d != %d"); + } else if (sizeof(long) == 8) { + TEST(l, wcstol(s=L"9223372036854775808", &c, 0), 9223372036854775807L, "uncaught overflow %ld != %ld"); + TEST2(i, c-s, 19, "wrong final position %d != %d"); + TEST2(i, errno, ERANGE, "missing errno %d != %d"); + TEST(l, wcstol(s=L"-9223372036854775809", &c, 0), -9223372036854775807L-1, "uncaught overflow %ld != %ld"); + TEST2(i, c-s, 20, "wrong final position %d != %d"); + TEST2(i, errno, ERANGE, "missing errno %d != %d"); + TEST(ul, wcstoul(s=L"18446744073709551616", &c, 0), 18446744073709551615UL, "uncaught overflow %lu != %lu"); + TEST2(i, c-s, 20, "wrong final position %d != %d"); + TEST2(i, errno, ERANGE, "missing errno %d != %d"); + 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, 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, 0, "spurious errno %d != %d"); + TEST(ul, wcstoul(s=L"-9223372036854775808", &c, 0), -9223372036854775808UL, "rejected negative %lu != %lu"); + TEST2(i, c-s, 20, "wrong final position %d != %d"); + TEST2(i, errno, 0, "spurious errno %d != %d"); + TEST(ul, wcstoul(s=L"-9223372036854775809", &c, 0), -9223372036854775809UL, "rejected negative %lu != %lu"); + TEST2(i, c-s, 20, "wrong final position %d != %d"); + TEST2(i, errno, 0, "spurious errno %d != %d"); } else { - TEST(i, 0, 1, "64bit tests not implemented"); + t_error("sizeof(long) == %d, not implemented\n", (int)sizeof(long)); } TEST(l, wcstol(L"z", 0, 36), 35, "%ld != %ld"); @@ -63,5 +85,5 @@ int main(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; + return t_status; }