X-Git-Url: https://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-strtoimax.c;h=6a05352e5b917e2122df35498f53e9ccd530134b;hb=5068051817bc09c088f31d3627956bfe5086b130;hp=b250190861d7ce3653b9986d17f58dae50faf73e;hpb=1602f0afed21be664fcf5c42d59db07cc22c56d6;p=gnulib.git diff --git a/tests/test-strtoimax.c b/tests/test-strtoimax.c index b25019086..6a05352e5 100644 --- a/tests/test-strtoimax.c +++ b/tests/test-strtoimax.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011-2012 Free Software Foundation, Inc. + * Copyright (C) 2011-2013 Free Software Foundation, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -144,5 +144,38 @@ main (void) ASSERT (errno == 0); } + /* Large integer values. */ + { + const char input[] = "2147483647"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == 2147483647); + ASSERT (ptr == input + 10); + ASSERT (errno == 0); + } + { + const char input[] = "-2147483648"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == -2147483647 - 1); + ASSERT (ptr == input + 11); + ASSERT (errno == 0); + } + if (sizeof (intmax_t) > sizeof (int)) + { + const char input[] = "4294967295"; + char *ptr; + intmax_t result; + errno = 0; + result = strtoimax (input, &ptr, 10); + ASSERT (result == (intmax_t) 65535 * (intmax_t) 65537); + ASSERT (ptr == input + 10); + ASSERT (errno == 0); + } + return 0; }