X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdlib%2Fstrtoull.c;h=e207110bddea8b962ac039f1c7271a53fcebb295;hb=d865c4403fc91d1f1ac95ba76febcee9f429bb97;hp=ca9dd1936ee2fb46c11dddfaf5f424aa5147e3bb;hpb=45f394553721285e7bc6187419613c33915cce21;p=pdclib diff --git a/functions/stdlib/strtoull.c b/functions/stdlib/strtoull.c index ca9dd19..e207110 100644 --- a/functions/stdlib/strtoull.c +++ b/functions/stdlib/strtoull.c @@ -1,5 +1,3 @@ -/* $Id$ */ - /* strtoull( const char *, char * *, int ) This file is part of the Public Domain C Library (PDCLib). @@ -27,7 +25,9 @@ unsigned long long int strtoull( const char * s, char ** endptr, int base ) #endif #ifdef TEST -#include <_PDCLIB_test.h> + +#include "_PDCLIB_test.h" + #include int main( void ) @@ -76,14 +76,16 @@ int main( void ) TESTCASE( strtoull( overflow, &endptr, 0 ) == 0 ); TESTCASE( endptr == overflow ); errno = 0; -#if ULLONG_MAX == 0xffffffffffffffffLL +/* long long -> 64 bit */ +#if ULLONG_MAX >> 63 == 1 /* testing "even" overflow, i.e. base is power of two */ TESTCASE( strtoull( "18446744073709551615", NULL, 0 ) == ULLONG_MAX ); TESTCASE( errno == 0 ); TESTCASE( strtoull( "18446744073709551616", NULL, 0 ) == ULLONG_MAX ); TESTCASE( errno == ERANGE ); /* TODO: test "odd" overflow, i.e. base is not power of two */ -#elif ULLONG_MAX == 0xffffffffffffffffffffffffffffffffLL +/* long long -> 128 bit */ +#elif ULLONG_MAX >> 127 == 1 /* testing "even" overflow, i.e. base is power of two */ TESTCASE( strtoull( "340282366920938463463374607431768211455", NULL, 0 ) == ULLONG_MAX ); TESTCASE( errno == 0 );