Mercurial > hg > octave-lyh > gnulib-hg
changeset 8857:61fd30fa9b3f
Avoid test failures on some versions of HP-UX 11.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 20 May 2007 08:12:26 +0000 |
parents | 784991232215 |
children | 6ddd04703670 |
files | ChangeLog tests/test-snprintf-posix.h tests/test-sprintf-posix.h tests/test-vasnprintf-posix.c tests/test-vasprintf-posix.c |
diffstat | 5 files changed, 153 insertions(+), 72 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-05-20 Bruno Haible <bruno@clisp.org> + + * tests/test-vasnprintf-posix.c (test_function): Allow NaN to be + printed as "-nan" instead of "nan". + * tests/test-vasprintf-posix.c (test_function): Likewise. + * tests/test-snprintf-posix.h (test_function): Likewise. + * tests/test-sprintf-posix.h (test_function): Likewise. + Needed for HP-UX 11. + 2007-05-20 Jim Meyering <jim@meyering.net> Fix buggy test for the fchownat-deref bug.
--- a/tests/test-snprintf-posix.h +++ b/tests/test-snprintf-posix.h @@ -176,7 +176,8 @@ int retval = my_snprintf (result, sizeof (result), "%a %d", NaN (), 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -375,7 +376,8 @@ /* "0000000nan 33" is not a valid result; see <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */ ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -440,7 +442,8 @@ int retval = my_snprintf (result, sizeof (result), "%La %d", 0.0L / 0.0L, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -640,7 +643,8 @@ /* "0000000nan 33" is not a valid result; see <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */ ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -800,7 +804,8 @@ int retval = my_snprintf (result, sizeof (result), "%f %d", NaN (), 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -881,7 +886,8 @@ int retval = my_snprintf (result, sizeof (result), "%020f %d", NaN (), 33, 44, 55); ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -1048,7 +1054,8 @@ int retval = my_snprintf (result, sizeof (result), "%Lf %d", zero / zero, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -1130,7 +1137,8 @@ int retval = my_snprintf (result, sizeof (result), "%020Lf %d", zero / zero, 33, 44, 55); ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -1209,7 +1217,8 @@ int retval = my_snprintf (result, sizeof (result), "%F %d", NaN (), 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "NAN", 3) == 0 + && (memcmp (result, "NAN", 3) == 0 + || memcmp (result, "-NAN", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -1304,7 +1313,8 @@ int retval = my_snprintf (result, sizeof (result), "%LF %d", zero / zero, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "NAN", 3) == 0 + && (memcmp (result, "NAN", 3) == 0 + || memcmp (result, "-NAN", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -1503,7 +1513,8 @@ int retval = my_snprintf (result, sizeof (result), "%e %d", NaN (), 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -1594,7 +1605,8 @@ int retval = my_snprintf (result, sizeof (result), "%020e %d", NaN (), 33, 44, 55); ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -1762,7 +1774,8 @@ int retval = my_snprintf (result, sizeof (result), "%Le %d", zero / zero, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -1846,7 +1859,8 @@ int retval = my_snprintf (result, sizeof (result), "%020Le %d", zero / zero, 33, 44, 55); ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -2024,7 +2038,8 @@ int retval = my_snprintf (result, sizeof (result), "%g %d", NaN (), 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -2108,7 +2123,8 @@ int retval = my_snprintf (result, sizeof (result), "%020g %d", NaN (), 33, 44, 55); ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -2276,7 +2292,8 @@ int retval = my_snprintf (result, sizeof (result), "%Lg %d", zero / zero, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -2360,7 +2377,8 @@ int retval = my_snprintf (result, sizeof (result), "%020Lg %d", zero / zero, 33, 44, 55); ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); }
--- a/tests/test-sprintf-posix.h +++ b/tests/test-sprintf-posix.h @@ -162,7 +162,8 @@ int retval = my_sprintf (result, "%a %d", NaN (), 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -361,7 +362,8 @@ /* "0000000nan 33" is not a valid result; see <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */ ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -426,7 +428,8 @@ int retval = my_sprintf (result, "%La %d", 0.0L / 0.0L, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -626,7 +629,8 @@ /* "0000000nan 33" is not a valid result; see <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */ ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -786,7 +790,8 @@ int retval = my_sprintf (result, "%f %d", NaN (), 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -861,7 +866,8 @@ int retval = my_sprintf (result, "%020f %d", NaN (), 33, 44, 55); ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -1028,7 +1034,8 @@ int retval = my_sprintf (result, "%Lf %d", zero / zero, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -1104,7 +1111,8 @@ int retval = my_sprintf (result, "%020Lf %d", zero / zero, 33, 44, 55); ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -1183,7 +1191,8 @@ int retval = my_sprintf (result, "%F %d", NaN (), 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "NAN", 3) == 0 + && (memcmp (result, "NAN", 3) == 0 + || memcmp (result, "-NAN", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -1278,7 +1287,8 @@ int retval = my_sprintf (result, "%LF %d", zero / zero, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "NAN", 3) == 0 + && (memcmp (result, "NAN", 3) == 0 + || memcmp (result, "-NAN", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -1477,7 +1487,8 @@ int retval = my_sprintf (result, "%e %d", NaN (), 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -1568,7 +1579,8 @@ int retval = my_sprintf (result, "%020e %d", NaN (), 33, 44, 55); ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -1736,7 +1748,8 @@ int retval = my_sprintf (result, "%Le %d", zero / zero, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -1820,7 +1833,8 @@ int retval = my_sprintf (result, "%020Le %d", zero / zero, 33, 44, 55); ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -1998,7 +2012,8 @@ int retval = my_sprintf (result, "%g %d", NaN (), 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -2082,7 +2097,8 @@ int retval = my_sprintf (result, "%020g %d", NaN (), 33, 44, 55); ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -2250,7 +2266,8 @@ int retval = my_sprintf (result, "%Lg %d", zero / zero, 33, 44, 55); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); } @@ -2334,7 +2351,8 @@ int retval = my_sprintf (result, "%020Lg %d", zero / zero, 33, 44, 55); ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); }
--- a/tests/test-vasnprintf-posix.c +++ b/tests/test-vasnprintf-posix.c @@ -228,7 +228,8 @@ my_asnprintf (NULL, &length, "%a %d", NaN (), 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (length == strlen (result)); free (result); @@ -463,7 +464,8 @@ /* "0000000nan 33" is not a valid result; see <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */ ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (length == strlen (result)); free (result); @@ -542,7 +544,8 @@ my_asnprintf (NULL, &length, "%La %d", 0.0L / 0.0L, 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (length == strlen (result)); free (result); @@ -778,7 +781,8 @@ /* "0000000nan 33" is not a valid result; see <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */ ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (length == strlen (result)); free (result); @@ -956,7 +960,8 @@ my_asnprintf (NULL, &length, "%f %d", NaN (), 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (length == strlen (result)); free (result); @@ -1049,7 +1054,8 @@ my_asnprintf (NULL, &length, "%020f %d", NaN (), 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (length == strlen (result)); free (result); @@ -1236,7 +1242,8 @@ my_asnprintf (NULL, &length, "%Lf %d", zero / zero, 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (length == strlen (result)); free (result); @@ -1330,7 +1337,8 @@ my_asnprintf (NULL, &length, "%020Lf %d", zero / zero, 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (length == strlen (result)); free (result); @@ -1427,7 +1435,8 @@ my_asnprintf (NULL, &length, "%F %d", NaN (), 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "NAN", 3) == 0 + && (memcmp (result, "NAN", 3) == 0 + || memcmp (result, "-NAN", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (length == strlen (result)); free (result); @@ -1544,7 +1553,8 @@ my_asnprintf (NULL, &length, "%LF %d", zero / zero, 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "NAN", 3) == 0 + && (memcmp (result, "NAN", 3) == 0 + || memcmp (result, "-NAN", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (length == strlen (result)); free (result); @@ -1766,7 +1776,8 @@ my_asnprintf (NULL, &length, "%e %d", NaN (), 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (length == strlen (result)); free (result); @@ -1877,7 +1888,8 @@ my_asnprintf (NULL, &length, "%020e %d", NaN (), 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (length == strlen (result)); free (result); @@ -2065,7 +2077,8 @@ my_asnprintf (NULL, &length, "%Le %d", zero / zero, 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (length == strlen (result)); free (result); @@ -2169,7 +2182,8 @@ my_asnprintf (NULL, &length, "%020Le %d", zero / zero, 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (length == strlen (result)); free (result); @@ -2367,7 +2381,8 @@ my_asnprintf (NULL, &length, "%g %d", NaN (), 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (length == strlen (result)); free (result); @@ -2471,7 +2486,8 @@ my_asnprintf (NULL, &length, "%020g %d", NaN (), 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (length == strlen (result)); free (result); @@ -2659,7 +2675,8 @@ my_asnprintf (NULL, &length, "%Lg %d", zero / zero, 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (length == strlen (result)); free (result); @@ -2763,7 +2780,8 @@ my_asnprintf (NULL, &length, "%020Lg %d", zero / zero, 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (length == strlen (result)); free (result);
--- a/tests/test-vasprintf-posix.c +++ b/tests/test-vasprintf-posix.c @@ -209,7 +209,8 @@ my_asprintf (&result, "%a %d", NaN (), 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); free (result); @@ -444,7 +445,8 @@ /* "0000000nan 33" is not a valid result; see <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */ ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); free (result); @@ -523,7 +525,8 @@ my_asprintf (&result, "%La %d", 0.0L / 0.0L, 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); free (result); @@ -759,7 +762,8 @@ /* "0000000nan 33" is not a valid result; see <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */ ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); free (result); @@ -937,7 +941,8 @@ my_asprintf (&result, "%f %d", NaN (), 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); free (result); @@ -1030,7 +1035,8 @@ my_asprintf (&result, "%020f %d", NaN (), 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); free (result); @@ -1217,7 +1223,8 @@ my_asprintf (&result, "%Lf %d", zero / zero, 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); free (result); @@ -1311,7 +1318,8 @@ my_asprintf (&result, "%020Lf %d", zero / zero, 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); free (result); @@ -1408,7 +1416,8 @@ my_asprintf (&result, "%F %d", NaN (), 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "NAN", 3) == 0 + && (memcmp (result, "NAN", 3) == 0 + || memcmp (result, "-NAN", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); free (result); @@ -1525,7 +1534,8 @@ my_asprintf (&result, "%LF %d", zero / zero, 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "NAN", 3) == 0 + && (memcmp (result, "NAN", 3) == 0 + || memcmp (result, "-NAN", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); free (result); @@ -1747,7 +1757,8 @@ my_asprintf (&result, "%e %d", NaN (), 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); free (result); @@ -1858,7 +1869,8 @@ my_asprintf (&result, "%020e %d", NaN (), 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); free (result); @@ -2046,7 +2058,8 @@ my_asprintf (&result, "%Le %d", zero / zero, 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); free (result); @@ -2150,7 +2163,8 @@ my_asprintf (&result, "%020Le %d", zero / zero, 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); free (result); @@ -2348,7 +2362,8 @@ my_asprintf (&result, "%g %d", NaN (), 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); free (result); @@ -2452,7 +2467,8 @@ my_asprintf (&result, "%020g %d", NaN (), 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); free (result); @@ -2640,7 +2656,8 @@ my_asprintf (&result, "%Lg %d", zero / zero, 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) >= 3 + 3 - && memcmp (result, "nan", 3) == 0 + && (memcmp (result, "nan", 3) == 0 + || memcmp (result, "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); free (result); @@ -2744,7 +2761,8 @@ my_asprintf (&result, "%020Lg %d", zero / zero, 33, 44, 55); ASSERT (result != NULL); ASSERT (strlen (result) == 20 + 3 - && memcmp (result + strspn (result, " "), "nan", 3) == 0 + && (memcmp (result + strspn (result, " "), "nan", 3) == 0 + || memcmp (result + strspn (result, " "), "-nan", 4) == 0) && strcmp (result + strlen (result) - 3, " 33") == 0); ASSERT (retval == strlen (result)); free (result);