Mercurial > hg > octave-lyh > gnulib-hg
changeset 8852:df0b5e8ea770
Avoid test failures on platforms where -0.0 and 0.0 are identical.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 19 May 2007 22:57:58 +0000 |
parents | 0863989438fc |
children | 65cd8f6786ed |
files | ChangeLog tests/test-fprintf-posix.h tests/test-printf-posix.h tests/test-printf-posix.output tests/test-snprintf-posix.h tests/test-sprintf-posix.h tests/test-vasnprintf-posix.c tests/test-vasprintf-posix.c |
diffstat | 8 files changed, 145 insertions(+), 79 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2007-05-19 Bruno Haible <bruno@clisp.org> + + * tests/test-vasnprintf-posix.c (have_minus_zero): New function. + (test_function): Skip tests involving -0.0 on platforms where + -0.0 = 0.0. + * tests/test-vasprintf-posix.c (have_minus_zero): New function. + (test_function): Skip tests involving -0.0 on platforms where + -0.0 = 0.0. + * tests/test-snprintf-posix.h (have_minus_zero): New function. + (test_function): Skip tests involving -0.0 on platforms where + -0.0 = 0.0. + * tests/test-sprintf-posix.h (have_minus_zero): New function. + (test_function): Skip tests involving -0.0 on platforms where + -0.0 = 0.0. + * tests/test-fprintf-posix.h (test_function): Remove all -0.0 related + tests. + * tests/test-printf-posix.h (test_function): Likewise. + * tests/test-printf-posix.output: Remove all -0.0 related results. + Needed for IRIX 6.5. + 2007-05-19 Bruno Haible <bruno@clisp.org> * tests/test-vasnprintf-posix.c (test_function): Allow NaN to be @@ -5,6 +25,11 @@ * tests/test-vasprintf-posix.c (test_function): Likewise. * tests/test-snprintf-posix.h (test_function): Likewise. * tests/test-sprintf-posix.h (test_function): Likewise. + * tests/test-fprintf-posix.h (NaN): Remove macro. + (test_function): Remove all NaN related tests. + * tests/test-printf-posix.h (NaN): Remove macro. + (test_function): Remove all NaN related tests. + * tests/test-printf-posix.output: Remove all NaN related results. Needed for IRIX 6.5. 2007-05-19 Bruno Haible <bruno@clisp.org>
--- a/tests/test-fprintf-posix.h +++ b/tests/test-fprintf-posix.h @@ -37,9 +37,6 @@ /* Positive zero. */ my_fprintf (stdout, "%a %d\n", 0.0, 33, 44, 55); - /* Negative zero. */ - my_fprintf (stdout, "%a %d\n", -0.0, 33, 44, 55); - /* Positive infinity. */ my_fprintf (stdout, "%a %d\n", 1.0 / 0.0, 33, 44, 55); @@ -63,9 +60,6 @@ /* Positive zero. */ my_fprintf (stdout, "%f %d\n", 0.0, 33, 44, 55); - /* Negative zero. */ - my_fprintf (stdout, "%f %d\n", -0.0, 33, 44, 55); - /* FLAG_ZERO. */ my_fprintf (stdout, "%015f %d\n", 1234.0, 33, 44, 55); @@ -84,9 +78,6 @@ /* Positive zero. */ my_fprintf (stdout, "%Lf %d\n", 0.0L, 33, 44, 55); - /* Negative zero. */ - my_fprintf (stdout, "%Lf %d\n", -0.0L, 33, 44, 55); - /* FLAG_ZERO. */ my_fprintf (stdout, "%015Lf %d\n", 1234.0L, 33, 44, 55); @@ -107,9 +98,6 @@ /* Positive zero. */ my_fprintf (stdout, "%F %d\n", 0.0, 33, 44, 55); - /* Negative zero. */ - my_fprintf (stdout, "%F %d\n", -0.0, 33, 44, 55); - /* FLAG_ZERO. */ my_fprintf (stdout, "%015F %d\n", 1234.0, 33, 44, 55); @@ -128,9 +116,6 @@ /* Positive zero. */ my_fprintf (stdout, "%LF %d\n", 0.0L, 33, 44, 55); - /* Negative zero. */ - my_fprintf (stdout, "%LF %d\n", -0.0L, 33, 44, 55); - /* FLAG_ZERO. */ my_fprintf (stdout, "%015LF %d\n", 1234.0L, 33, 44, 55);
--- a/tests/test-printf-posix.h +++ b/tests/test-printf-posix.h @@ -37,9 +37,6 @@ /* Positive zero. */ my_printf ("%a %d\n", 0.0, 33, 44, 55); - /* Negative zero. */ - my_printf ("%a %d\n", -0.0, 33, 44, 55); - /* Positive infinity. */ my_printf ("%a %d\n", 1.0 / 0.0, 33, 44, 55); @@ -65,9 +62,6 @@ /* Positive zero. */ my_printf ("%f %d\n", 0.0, 33, 44, 55); - /* Negative zero. */ - my_printf ("%f %d\n", -0.0, 33, 44, 55); - /* FLAG_ZERO. */ my_printf ("%015f %d\n", 1234.0, 33, 44, 55); @@ -86,9 +80,6 @@ /* Positive zero. */ my_printf ("%Lf %d\n", 0.0L, 33, 44, 55); - /* Negative zero. */ - my_printf ("%Lf %d\n", -0.0L, 33, 44, 55); - /* FLAG_ZERO. */ my_printf ("%015Lf %d\n", 1234.0L, 33, 44, 55); @@ -109,9 +100,6 @@ /* Positive zero. */ my_printf ("%F %d\n", 0.0, 33, 44, 55); - /* Negative zero. */ - my_printf ("%F %d\n", -0.0, 33, 44, 55); - /* FLAG_ZERO. */ my_printf ("%015F %d\n", 1234.0, 33, 44, 55); @@ -130,9 +118,6 @@ /* Positive zero. */ my_printf ("%LF %d\n", 0.0L, 33, 44, 55); - /* Negative zero. */ - my_printf ("%LF %d\n", -0.0L, 33, 44, 55); - /* FLAG_ZERO. */ my_printf ("%015LF %d\n", 1234.0L, 33, 44, 55);
--- a/tests/test-printf-posix.output +++ b/tests/test-printf-posix.output @@ -2,7 +2,6 @@ 12345672 33 12345673 33 0x0p+0 33 --0x0p+0 33 inf 33 -inf 33 inf 33 @@ -10,28 +9,24 @@ 1234567.000000 33 -0.031250 33 0.000000 33 --0.000000 33 00001234.000000 33 1234 33 12.750000 33 1234567.000000 33 -0.031250 33 0.000000 33 --0.000000 33 00001234.000000 33 1234 33 12.750000 33 1234567.000000 33 -0.031250 33 0.000000 33 --0.000000 33 00001234.000000 33 1234 33 12.750000 33 1234567.000000 33 -0.031250 33 0.000000 33 --0.000000 33 00001234.000000 33 1234 33 55 33
--- a/tests/test-snprintf-posix.h +++ b/tests/test-snprintf-posix.h @@ -29,6 +29,15 @@ # define NaN() (0.0 / 0.0) #endif +/* The SGI MIPS floating-point format does not distinguish 0.0 and -0.0. */ +static int +have_minus_zero () +{ + static double plus_zero = 0.0; + static double minus_zero = -0.0; + return memcmp (&plus_zero, &minus_zero, sizeof (double)) != 0; +} + static int strmatch (const char *pattern, const char *string) { @@ -141,7 +150,8 @@ char result[100]; int retval = my_snprintf (result, sizeof (result), "%a %d", -0.0, 33, 44, 55); - ASSERT (strcmp (result, "-0x0p+0 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0x0p+0 33") == 0); ASSERT (retval == strlen (result)); } @@ -404,7 +414,8 @@ char result[100]; int retval = my_snprintf (result, sizeof (result), "%La %d", -0.0L, 33, 44, 55); - ASSERT (strcmp (result, "-0x0p+0 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0x0p+0 33") == 0); ASSERT (retval == strlen (result)); } @@ -761,7 +772,8 @@ char result[100]; int retval = my_snprintf (result, sizeof (result), "%f %d", -0.0, 33, 44, 55); - ASSERT (strcmp (result, "-0.000000 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (retval == strlen (result)); } @@ -1007,7 +1019,8 @@ char result[100]; int retval = my_snprintf (result, sizeof (result), "%Lf %d", -0.0L, 33, 44, 55); - ASSERT (strcmp (result, "-0.000000 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (retval == strlen (result)); } @@ -1168,7 +1181,8 @@ char result[100]; int retval = my_snprintf (result, sizeof (result), "%F %d", -0.0, 33, 44, 55); - ASSERT (strcmp (result, "-0.000000 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (retval == strlen (result)); } @@ -1261,7 +1275,8 @@ char result[100]; int retval = my_snprintf (result, sizeof (result), "%LF %d", -0.0L, 33, 44, 55); - ASSERT (strcmp (result, "-0.000000 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (retval == strlen (result)); } @@ -1459,8 +1474,9 @@ char result[100]; int retval = my_snprintf (result, sizeof (result), "%e %d", -0.0, 33, 44, 55); - ASSERT (strcmp (result, "-0.000000e+00 33") == 0 - || strcmp (result, "-0.000000e+000 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000e+00 33") == 0 + || strcmp (result, "-0.000000e+000 33") == 0); ASSERT (retval == strlen (result)); } @@ -1717,7 +1733,8 @@ char result[100]; int retval = my_snprintf (result, sizeof (result), "%Le %d", -0.0L, 33, 44, 55); - ASSERT (strcmp (result, "-0.000000e+00 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000e+00 33") == 0); ASSERT (retval == strlen (result)); } @@ -1979,7 +1996,8 @@ char result[100]; int retval = my_snprintf (result, sizeof (result), "%g %d", -0.0, 33, 44, 55); - ASSERT (strcmp (result, "-0 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0 33") == 0); ASSERT (retval == strlen (result)); } @@ -2229,7 +2247,8 @@ char result[100]; int retval = my_snprintf (result, sizeof (result), "%Lg %d", -0.0L, 33, 44, 55); - ASSERT (strcmp (result, "-0 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0 33") == 0); ASSERT (retval == strlen (result)); }
--- a/tests/test-sprintf-posix.h +++ b/tests/test-sprintf-posix.h @@ -29,6 +29,15 @@ # define NaN() (0.0 / 0.0) #endif +/* The SGI MIPS floating-point format does not distinguish 0.0 and -0.0. */ +static int +have_minus_zero () +{ + static double plus_zero = 0.0; + static double minus_zero = -0.0; + return memcmp (&plus_zero, &minus_zero, sizeof (double)) != 0; +} + static int strmatch (const char *pattern, const char *string) { @@ -127,7 +136,8 @@ char result[1000]; int retval = my_sprintf (result, "%a %d", -0.0, 33, 44, 55); - ASSERT (strcmp (result, "-0x0p+0 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0x0p+0 33") == 0); ASSERT (retval == strlen (result)); } @@ -390,7 +400,8 @@ char result[1000]; int retval = my_sprintf (result, "%La %d", -0.0L, 33, 44, 55); - ASSERT (strcmp (result, "-0x0p+0 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0x0p+0 33") == 0); ASSERT (retval == strlen (result)); } @@ -747,7 +758,8 @@ char result[1000]; int retval = my_sprintf (result, "%f %d", -0.0, 33, 44, 55); - ASSERT (strcmp (result, "-0.000000 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (retval == strlen (result)); } @@ -987,7 +999,8 @@ char result[1000]; int retval = my_sprintf (result, "%Lf %d", -0.0L, 33, 44, 55); - ASSERT (strcmp (result, "-0.000000 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (retval == strlen (result)); } @@ -1142,7 +1155,8 @@ char result[1000]; int retval = my_sprintf (result, "%F %d", -0.0, 33, 44, 55); - ASSERT (strcmp (result, "-0.000000 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (retval == strlen (result)); } @@ -1235,7 +1249,8 @@ char result[1000]; int retval = my_sprintf (result, "%LF %d", -0.0L, 33, 44, 55); - ASSERT (strcmp (result, "-0.000000 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (retval == strlen (result)); } @@ -1433,8 +1448,9 @@ char result[1000]; int retval = my_sprintf (result, "%e %d", -0.0, 33, 44, 55); - ASSERT (strcmp (result, "-0.000000e+00 33") == 0 - || strcmp (result, "-0.000000e+000 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000e+00 33") == 0 + || strcmp (result, "-0.000000e+000 33") == 0); ASSERT (retval == strlen (result)); } @@ -1691,7 +1707,8 @@ char result[1000]; int retval = my_sprintf (result, "%Le %d", -0.0L, 33, 44, 55); - ASSERT (strcmp (result, "-0.000000e+00 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000e+00 33") == 0); ASSERT (retval == strlen (result)); } @@ -1953,7 +1970,8 @@ char result[1000]; int retval = my_sprintf (result, "%g %d", -0.0, 33, 44, 55); - ASSERT (strcmp (result, "-0 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0 33") == 0); ASSERT (retval == strlen (result)); } @@ -2203,7 +2221,8 @@ char result[1000]; int retval = my_sprintf (result, "%Lg %d", -0.0L, 33, 44, 55); - ASSERT (strcmp (result, "-0 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0 33") == 0); ASSERT (retval == strlen (result)); }
--- a/tests/test-vasnprintf-posix.c +++ b/tests/test-vasnprintf-posix.c @@ -54,6 +54,15 @@ # define NaN() (0.0 / 0.0) #endif +/* The SGI MIPS floating-point format does not distinguish 0.0 and -0.0. */ +static int +have_minus_zero () +{ + static double plus_zero = 0.0; + static double minus_zero = -0.0; + return memcmp (&plus_zero, &minus_zero, sizeof (double)) != 0; +} + static int strmatch (const char *pattern, const char *string) { @@ -187,7 +196,8 @@ char *result = my_asnprintf (NULL, &length, "%a %d", -0.0, 33, 44, 55); ASSERT (result != NULL); - ASSERT (strcmp (result, "-0x0p+0 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0x0p+0 33") == 0); ASSERT (length == strlen (result)); free (result); } @@ -500,7 +510,8 @@ char *result = my_asnprintf (NULL, &length, "%La %d", -0.0L, 33, 44, 55); ASSERT (result != NULL); - ASSERT (strcmp (result, "-0x0p+0 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0x0p+0 33") == 0); ASSERT (length == strlen (result)); free (result); } @@ -911,7 +922,8 @@ char *result = my_asnprintf (NULL, &length, "%f %d", -0.0, 33, 44, 55); ASSERT (result != NULL); - ASSERT (strcmp (result, "-0.000000 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (length == strlen (result)); free (result); } @@ -1189,7 +1201,8 @@ char *result = my_asnprintf (NULL, &length, "%Lf %d", -0.0L, 33, 44, 55); ASSERT (result != NULL); - ASSERT (strcmp (result, "-0.000000 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (length == strlen (result)); free (result); } @@ -1380,7 +1393,8 @@ char *result = my_asnprintf (NULL, &length, "%F %d", -0.0, 33, 44, 55); ASSERT (result != NULL); - ASSERT (strcmp (result, "-0.000000 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (length == strlen (result)); free (result); } @@ -1495,7 +1509,8 @@ char *result = my_asnprintf (NULL, &length, "%LF %d", -0.0L, 33, 44, 55); ASSERT (result != NULL); - ASSERT (strcmp (result, "-0.000000 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (length == strlen (result)); free (result); } @@ -1716,8 +1731,9 @@ char *result = my_asnprintf (NULL, &length, "%e %d", -0.0, 33, 44, 55); ASSERT (result != NULL); - ASSERT (strcmp (result, "-0.000000e+00 33") == 0 - || strcmp (result, "-0.000000e+000 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000e+00 33") == 0 + || strcmp (result, "-0.000000e+000 33") == 0); ASSERT (length == strlen (result)); free (result); } @@ -2014,7 +2030,8 @@ char *result = my_asnprintf (NULL, &length, "%Le %d", -0.0L, 33, 44, 55); ASSERT (result != NULL); - ASSERT (strcmp (result, "-0.000000e+00 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000e+00 33") == 0); ASSERT (length == strlen (result)); free (result); } @@ -2316,7 +2333,8 @@ char *result = my_asnprintf (NULL, &length, "%g %d", -0.0, 33, 44, 55); ASSERT (result != NULL); - ASSERT (strcmp (result, "-0 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0 33") == 0); ASSERT (length == strlen (result)); free (result); } @@ -2606,7 +2624,8 @@ char *result = my_asnprintf (NULL, &length, "%Lg %d", -0.0L, 33, 44, 55); ASSERT (result != NULL); - ASSERT (strcmp (result, "-0 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0 33") == 0); ASSERT (length == strlen (result)); free (result); }
--- a/tests/test-vasprintf-posix.c +++ b/tests/test-vasprintf-posix.c @@ -54,6 +54,15 @@ # define NaN() (0.0 / 0.0) #endif +/* The SGI MIPS floating-point format does not distinguish 0.0 and -0.0. */ +static int +have_minus_zero () +{ + static double plus_zero = 0.0; + static double minus_zero = -0.0; + return memcmp (&plus_zero, &minus_zero, sizeof (double)) != 0; +} + static int strmatch (const char *pattern, const char *string) { @@ -168,7 +177,8 @@ int retval = my_asprintf (&result, "%a %d", -0.0, 33, 44, 55); ASSERT (result != NULL); - ASSERT (strcmp (result, "-0x0p+0 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0x0p+0 33") == 0); ASSERT (retval == strlen (result)); free (result); } @@ -481,7 +491,8 @@ int retval = my_asprintf (&result, "%La %d", -0.0L, 33, 44, 55); ASSERT (result != NULL); - ASSERT (strcmp (result, "-0x0p+0 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0x0p+0 33") == 0); ASSERT (retval == strlen (result)); free (result); } @@ -892,7 +903,8 @@ int retval = my_asprintf (&result, "%f %d", -0.0, 33, 44, 55); ASSERT (result != NULL); - ASSERT (strcmp (result, "-0.000000 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (retval == strlen (result)); free (result); } @@ -1170,7 +1182,8 @@ int retval = my_asprintf (&result, "%Lf %d", -0.0L, 33, 44, 55); ASSERT (result != NULL); - ASSERT (strcmp (result, "-0.000000 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (retval == strlen (result)); free (result); } @@ -1361,7 +1374,8 @@ int retval = my_asprintf (&result, "%F %d", -0.0, 33, 44, 55); ASSERT (result != NULL); - ASSERT (strcmp (result, "-0.000000 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (retval == strlen (result)); free (result); } @@ -1476,7 +1490,8 @@ int retval = my_asprintf (&result, "%LF %d", -0.0L, 33, 44, 55); ASSERT (result != NULL); - ASSERT (strcmp (result, "-0.000000 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000 33") == 0); ASSERT (retval == strlen (result)); free (result); } @@ -1697,8 +1712,9 @@ int retval = my_asprintf (&result, "%e %d", -0.0, 33, 44, 55); ASSERT (result != NULL); - ASSERT (strcmp (result, "-0.000000e+00 33") == 0 - || strcmp (result, "-0.000000e+000 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000e+00 33") == 0 + || strcmp (result, "-0.000000e+000 33") == 0); ASSERT (retval == strlen (result)); free (result); } @@ -1995,7 +2011,8 @@ int retval = my_asprintf (&result, "%Le %d", -0.0L, 33, 44, 55); ASSERT (result != NULL); - ASSERT (strcmp (result, "-0.000000e+00 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0.000000e+00 33") == 0); ASSERT (retval == strlen (result)); free (result); } @@ -2297,7 +2314,8 @@ int retval = my_asprintf (&result, "%g %d", -0.0, 33, 44, 55); ASSERT (result != NULL); - ASSERT (strcmp (result, "-0 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0 33") == 0); ASSERT (retval == strlen (result)); free (result); } @@ -2587,7 +2605,8 @@ int retval = my_asprintf (&result, "%Lg %d", -0.0L, 33, 44, 55); ASSERT (result != NULL); - ASSERT (strcmp (result, "-0 33") == 0); + if (have_minus_zero ()) + ASSERT (strcmp (result, "-0 33") == 0); ASSERT (retval == strlen (result)); free (result); }