# HG changeset patch # User Bruno Haible # Date 1325785883 -3600 # Node ID e8cde289d52519a362f9b4bb23663fd09a580790 # Parent f9e137049132f61105d13f9740c733ac321848cf strtoumax tests: Enhance tests. * tests/test-strtoumax.c (main): Add tests for large values. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-01-05 Bruno Haible + + strtoumax tests: Enhance tests. + * tests/test-strtoumax.c (main): Add tests for large values. + 2012-01-05 Bruno Haible strtoimax: Work around AIX 5.1 bug. diff --git a/tests/test-strtoumax.c b/tests/test-strtoumax.c --- a/tests/test-strtoumax.c +++ b/tests/test-strtoumax.c @@ -144,5 +144,37 @@ ASSERT (errno == 0); } + /* Large integer values. */ + { + const char input[] = "2147483647"; + char *ptr; + uintmax_t result; + errno = 0; + result = strtoumax (input, &ptr, 10); + ASSERT (result == 2147483647); + ASSERT (ptr == input + 10); + ASSERT (errno == 0); + } + { + const char input[] = "-2147483648"; + char *ptr; + uintmax_t result; + errno = 0; + result = strtoumax (input, &ptr, 10); + ASSERT (result == - (uintmax_t) 2147483648U); + ASSERT (ptr == input + 11); + ASSERT (errno == 0); + } + { + const char input[] = "4294967295"; + char *ptr; + uintmax_t result; + errno = 0; + result = strtoumax (input, &ptr, 10); + ASSERT (result == 4294967295U); + ASSERT (ptr == input + 10); + ASSERT (errno == 0); + } + return 0; }