X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Finttypes%2Fstrtoumax.c;h=9c9833eda92bd367d462f734e1fde975abf0c9b8;hp=0da7ec2889f31fffb2f510287e61a5d8dd5ad30c;hb=164e8c095e19af2595865d2713dd4d3d893b71e0;hpb=a0746ea9f2660205d2c885e34c515184442ddab1 diff --git a/functions/inttypes/strtoumax.c b/functions/inttypes/strtoumax.c index 0da7ec2..9c9833e 100755 --- a/functions/inttypes/strtoumax.c +++ b/functions/inttypes/strtoumax.c @@ -76,14 +76,16 @@ int main( void ) TESTCASE( strtoumax( overflow, &endptr, 0 ) == 0 ); TESTCASE( endptr == overflow ); errno = 0; -#if UINTMAX_MAX == 0xffffffffffffffffLL +/* uintmax_t -> long long -> 64 bit */ +#if UINTMAX_MAX >> 63 == 1 /* testing "even" overflow, i.e. base is power of two */ TESTCASE( strtoumax( "18446744073709551615", NULL, 0 ) == UINTMAX_MAX ); TESTCASE( errno == 0 ); TESTCASE( strtoumax( "18446744073709551616", NULL, 0 ) == UINTMAX_MAX ); TESTCASE( errno == ERANGE ); /* TODO: test "odd" overflow, i.e. base is not power of two */ -#elif UINTMAX_MAX == 0xffffffffffffffffffffffffffffffffLL +/* uintmax_t -> long long -> 128 bit */ +#elif UINTMAX_MAX >> 127 == 1 /* testing "even" overflow, i.e. base is power of two */ TESTCASE( strtoumax( "340282366920938463463374607431768211455", NULL, 0 ) == UINTMAX_MAX ); TESTCASE( errno == 0 );