summaryrefslogtreecommitdiff
path: root/tests/test-sprintf-posix.h
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2008-03-31 20:56:25 -0600
committerEric Blake <ebb9@byu.net>2008-03-31 21:06:57 -0600
commit06945b7c073c0872ec2049c0e0b94f789bf8d77e (patch)
tree6f724a69d7601b1df626fba02e974a3455c68abd /tests/test-sprintf-posix.h
parent4dd6fc750dfb7f21b2b764737c0656694281ed19 (diff)
downloadgnulib-06945b7c073c0872ec2049c0e0b94f789bf8d77e.tar.gz
Guarantee a definition of NAN.
* lib/math.in.h (NAN): Define if missing. * tests/test-math.c (main): Test it. * doc/posix-headers/math.texi (math.h): Document this. * lib/isnan.c (rpl_isnand): Use it. * tests/test-ceilf1.c (NaN): Delete, and use NAN instead. * tests/test-floorf1.c (NaN): Likewise. * tests/test-frexp.c (NaN): Likewise. * tests/test-isnand.c (NaN): Likewise. * tests/test-isnanf.c (NaN): Likewise. * tests/test-round1.c (NaN): Likewise. * tests/test-roundf1.c (NaN): Likewise. * tests/test-snprintf-posix.h (NaN): Likewise. * tests/test-sprintf-posix.h (NaN): Likewise. * tests/test-trunc1.c (NaN): Likewise. * tests/test-truncf1.c (NaN): Likewise. * tests/test-vasnprintf-posix.c (NaN): Likewise. * tests/test-vasprintf-posix.c (NaN): Likewise. * modules/isnand-nolibm (Depends-on): Add math. * modules/isnanf-nolibm (Depends-on): Likewise. * modules/isnanl (Depends-on): Likewise. * modules/isnanl-nolibm (Depends-on): Likewise. * modules/snprintf-posix-tests (Depends-on): Likewise. * modules/sprintf-posix-tests (Depends-on): Likewise. * modules/vsnprintf-posix-tests (Depends-on): Likewise. * modules/vsprintf-posix-tests (Depends-on): Likewise. * modules/vasnprintf-posix-tests (Depends-on): Likewise. * modules/vasprintf-posix-tests (Depends-on): Likewise. Signed-off-by: Eric Blake <ebb9@byu.net>
Diffstat (limited to 'tests/test-sprintf-posix.h')
-rw-r--r--tests/test-sprintf-posix.h30
1 files changed, 10 insertions, 20 deletions
diff --git a/tests/test-sprintf-posix.h b/tests/test-sprintf-posix.h
index 35e9d47bcc..ac2afcf91b 100644
--- a/tests/test-sprintf-posix.h
+++ b/tests/test-sprintf-posix.h
@@ -16,17 +16,7 @@
/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
-/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
-#ifdef __DECC
-static double
-NaN ()
-{
- static double zero = 0.0;
- return zero / zero;
-}
-#else
-# define NaN() (0.0 / 0.0)
-#endif
+#include <math.h>
/* The SGI MIPS floating-point format does not distinguish 0.0 and -0.0. */
static int
@@ -193,7 +183,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
{ /* NaN. */
char result[1000];
int retval =
- my_sprintf (result, "%a %d", NaN (), 33, 44, 55);
+ my_sprintf (result, "%a %d", NAN, 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -390,7 +380,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
{ /* FLAG_ZERO with NaN. */
char result[1000];
int retval =
- my_sprintf (result, "%050a %d", NaN (), 33, 44, 55);
+ my_sprintf (result, "%050a %d", NAN, 33, 44, 55);
/* "0000000nan 33" is not a valid result; see
<http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
ASSERT (strlen (result) == 50 + 3
@@ -904,7 +894,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
{ /* NaN. */
char result[1000];
int retval =
- my_sprintf (result, "%f %d", NaN (), 33, 44, 55);
+ my_sprintf (result, "%f %d", NAN, 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -979,7 +969,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
{ /* FLAG_ZERO with NaN. */
char result[1000];
int retval =
- my_sprintf (result, "%050f %d", NaN (), 33, 44, 55);
+ my_sprintf (result, "%050f %d", NAN, 33, 44, 55);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -1388,7 +1378,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
{ /* NaN. */
char result[1000];
int retval =
- my_sprintf (result, "%F %d", NaN (), 33, 44, 55);
+ my_sprintf (result, "%F %d", NAN, 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 1)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -1682,7 +1672,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
{ /* NaN. */
char result[1000];
int retval =
- my_sprintf (result, "%e %d", NaN (), 33, 44, 55);
+ my_sprintf (result, "%e %d", NAN, 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -1773,7 +1763,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
{ /* FLAG_ZERO with NaN. */
char result[1000];
int retval =
- my_sprintf (result, "%050e %d", NaN (), 33, 44, 55);
+ my_sprintf (result, "%050e %d", NAN, 33, 44, 55);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -2290,7 +2280,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
{ /* NaN. */
char result[1000];
int retval =
- my_sprintf (result, "%g %d", NaN (), 33, 44, 55);
+ my_sprintf (result, "%g %d", NAN, 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
@@ -2374,7 +2364,7 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
{ /* FLAG_ZERO with NaN. */
char result[1000];
int retval =
- my_sprintf (result, "%050g %d", NaN (), 33, 44, 55);
+ my_sprintf (result, "%050g %d", NAN, 33, 44, 55);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);