From b13eb4115455cba98e6fcf62b0ebd5663724b5aa Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Mon, 9 Jan 2017 22:02:27 +0000 Subject: [PATCH] wcstol: implement 64-bit tests --- src/functional/wcstol.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/functional/wcstol.c b/src/functional/wcstol.c index 9801f41..2f0e8a4 100644 --- a/src/functional/wcstol.c +++ b/src/functional/wcstol.c @@ -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"); -- 2.20.1