1
0
mirror of https://git.savannah.gnu.org/git/gnulib.git synced 2025-08-08 17:22:05 +03:00

*printf tests: Test printing of signalling NaNs.

These tests run without sigfpe_on_invalid(), therefore they won't crash.

* tests/test-vasnprintf-posix.c: Include snan.h.
(test_function): For each test case that uses NaNd or NaNl, add a test
case with SNaNd or SNaNl, respectively.
* tests/test-vasprintf-posix.c: Likewise.
* tests/test-snprintf-posix.h: Likewise.
* tests/test-sprintf-posix.h: Likewise.
* tests/test-vasnwprintf-posix.c: Likewise.
* modules/vasnprintf-posix-tests (Depends-on): Add snan.
* modules/vasprintf-posix-tests (Depends-on): Likewise.
* modules/vsnprintf-posix-tests (Depends-on): Likewise.
* modules/snprintf-posix-tests (Depends-on): Likewise.
* modules/vsprintf-posix-tests (Depends-on): Likewise.
* modules/sprintf-posix-tests (Depends-on): Likewise.
* modules/vasnwprintf-posix-tests (Depends-on): Likewise.
* modules/pipe-filter-gi-tests (Depends-on): Likewise.
* modules/pipe-filter-ii-tests (Depends-on): Likewise.
This commit is contained in:
Bruno Haible
2023-10-13 02:39:05 +02:00
parent e5118e049b
commit 94c7aff8c1
15 changed files with 625 additions and 0 deletions

View File

@@ -1,3 +1,24 @@
2023-10-12 Bruno Haible <bruno@clisp.org>
*printf tests: Test printing of signalling NaNs.
These tests run without sigfpe_on_invalid(), therefore they won't crash.
* tests/test-vasnprintf-posix.c: Include snan.h.
(test_function): For each test case that uses NaNd or NaNl, add a test
case with SNaNd or SNaNl, respectively.
* tests/test-vasprintf-posix.c: Likewise.
* tests/test-snprintf-posix.h: Likewise.
* tests/test-sprintf-posix.h: Likewise.
* tests/test-vasnwprintf-posix.c: Likewise.
* modules/vasnprintf-posix-tests (Depends-on): Add snan.
* modules/vasprintf-posix-tests (Depends-on): Likewise.
* modules/vsnprintf-posix-tests (Depends-on): Likewise.
* modules/snprintf-posix-tests (Depends-on): Likewise.
* modules/vsprintf-posix-tests (Depends-on): Likewise.
* modules/sprintf-posix-tests (Depends-on): Likewise.
* modules/vasnwprintf-posix-tests (Depends-on): Likewise.
* modules/pipe-filter-gi-tests (Depends-on): Likewise.
* modules/pipe-filter-ii-tests (Depends-on): Likewise.
2023-10-12 Bruno Haible <bruno@clisp.org>
nan, snan tests: Avoid test failures.

View File

@@ -10,6 +10,7 @@ tests/macros.h
Depends-on:
binary-io
c-ctype
snan
read-file
full-write
usleep

View File

@@ -10,6 +10,7 @@ tests/macros.h
Depends-on:
binary-io
c-ctype
snan
read-file
full-write

View File

@@ -11,6 +11,7 @@ Depends-on:
stdint
float
nan
snan
configure.ac:
AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])

View File

@@ -10,6 +10,7 @@ Depends-on:
stdint
float
nan
snan
configure.ac:
AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])

View File

@@ -13,6 +13,7 @@ Depends-on:
stdint
float
nan
snan
setlocale
configure.ac:

View File

@@ -14,6 +14,7 @@ Depends-on:
stdint
float
nan
snan
setlocale
wcscmp
wcsspn

View File

@@ -8,6 +8,7 @@ Depends-on:
stdint
float
nan
snan
configure.ac:
AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])

View File

@@ -11,6 +11,7 @@ Depends-on:
stdint
float
nan
snan
configure.ac:
AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])

View File

@@ -10,6 +10,7 @@ Depends-on:
stdint
float
nan
snan
configure.ac:
AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])

View File

@@ -19,6 +19,7 @@
#include "minus-zero.h"
#include "infinity.h"
#include "nan.h"
#include "snan.h"
/* The SGI MIPS floating-point format does not distinguish 0.0 and -0.0. */
static int
@@ -195,6 +196,16 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#if HAVE_SNAND
{ /* Signalling NaN. */
int retval =
my_snprintf (result, sizeof (result), "%a %d", SNaNd (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#endif
{ /* Rounding near the decimal point. */
int retval =
@@ -456,6 +467,16 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#if HAVE_SNANL
{ /* Signalling NaN. */
int retval =
my_snprintf (result, sizeof (result), "%La %d", SNaNl (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#endif
#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
{ /* Quiet NaN. */
static union { unsigned int word[4]; long double value; } x =
@@ -873,6 +894,16 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#if HAVE_SNAND
{ /* Signalling NaN. */
int retval =
my_snprintf (result, sizeof (result), "%f %d", SNaNd (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#endif
{ /* Width. */
int retval =
@@ -1123,6 +1154,16 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#if HAVE_SNANL
{ /* Signalling NaN. */
int retval =
my_snprintf (result, sizeof (result), "%Lf %d", SNaNl (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#endif
#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
{ /* Quiet NaN. */
static union { unsigned int word[4]; long double value; } x =
@@ -1351,6 +1392,16 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#if HAVE_SNAND
{ /* Signalling NaN. */
int retval =
my_snprintf (result, sizeof (result), "%F %d", SNaNd (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 1)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#endif
{ /* FLAG_ZERO. */
int retval =
@@ -1448,6 +1499,16 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#if HAVE_SNANL
{ /* Signalling NaN. */
int retval =
my_snprintf (result, sizeof (result), "%LF %d", SNaNl (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 1)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#endif
{ /* FLAG_ZERO. */
int retval =
@@ -1648,6 +1709,16 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#if HAVE_SNAND
{ /* Signalling NaN. */
int retval =
my_snprintf (result, sizeof (result), "%e %d", SNaNd (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#endif
{ /* Width. */
int retval =
@@ -1931,6 +2002,16 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#if HAVE_SNANL
{ /* Signalling NaN. */
int retval =
my_snprintf (result, sizeof (result), "%Le %d", SNaNl (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#endif
#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
{ /* Quiet NaN. */
static union { unsigned int word[4]; long double value; } x =
@@ -2277,6 +2358,16 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#if HAVE_SNAND
{ /* Signalling NaN. */
int retval =
my_snprintf (result, sizeof (result), "%g %d", SNaNd (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#endif
{ /* Width. */
int retval =
@@ -2546,6 +2637,16 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#if HAVE_SNANL
{ /* Signalling NaN. */
int retval =
my_snprintf (result, sizeof (result), "%Lg %d", SNaNl (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#endif
#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
{ /* Quiet NaN. */
static union { unsigned int word[4]; long double value; } x =

View File

@@ -19,6 +19,7 @@
#include "minus-zero.h"
#include "infinity.h"
#include "nan.h"
#include "snan.h"
/* The SGI MIPS floating-point format does not distinguish 0.0 and -0.0. */
static int
@@ -181,6 +182,16 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#if HAVE_SNAND
{ /* Signalling NaN. */
int retval =
my_sprintf (result, "%a %d", SNaNd (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#endif
{ /* Rounding near the decimal point. */
int retval =
@@ -442,6 +453,16 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#if HAVE_SNANL
{ /* Signalling NaN. */
int retval =
my_sprintf (result, "%La %d", SNaNl (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#endif
#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
{ /* Quiet NaN. */
static union { unsigned int word[4]; long double value; } x =
@@ -859,6 +880,16 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#if HAVE_SNAND
{ /* Signalling NaN. */
int retval =
my_sprintf (result, "%f %d", SNaNd (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#endif
{ /* Width. */
int retval =
@@ -1109,6 +1140,16 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#if HAVE_SNANL
{ /* Signalling NaN. */
int retval =
my_sprintf (result, "%Lf %d", SNaNl (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#endif
#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
{ /* Quiet NaN. */
static union { unsigned int word[4]; long double value; } x =
@@ -1337,6 +1378,16 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#if HAVE_SNAND
{ /* Signalling NaN. */
int retval =
my_sprintf (result, "%F %d", SNaNd (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 1)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#endif
{ /* FLAG_ZERO. */
int retval =
@@ -1434,6 +1485,16 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#if HAVE_SNANL
{ /* Signalling NaN. */
int retval =
my_sprintf (result, "%LF %d", SNaNl (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 1)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#endif
{ /* FLAG_ZERO. */
int retval =
@@ -1634,6 +1695,16 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#if HAVE_SNAND
{ /* Signalling NaN. */
int retval =
my_sprintf (result, "%e %d", SNaNd (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#endif
{ /* Width. */
int retval =
@@ -1917,6 +1988,16 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#if HAVE_SNANL
{ /* Signalling NaN. */
int retval =
my_sprintf (result, "%Le %d", SNaNl (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#endif
#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
{ /* Quiet NaN. */
static union { unsigned int word[4]; long double value; } x =
@@ -2263,6 +2344,16 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#if HAVE_SNAND
{ /* Signalling NaN. */
int retval =
my_sprintf (result, "%g %d", SNaNd (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#endif
{ /* Width. */
int retval =
@@ -2532,6 +2623,16 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#if HAVE_SNANL
{ /* Signalling NaN. */
int retval =
my_sprintf (result, "%Lg %d", SNaNl (), 33, 44, 55);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
}
#endif
#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
{ /* Quiet NaN. */
static union { unsigned int word[4]; long double value; } x =

View File

@@ -33,6 +33,7 @@
#include "minus-zero.h"
#include "infinity.h"
#include "nan.h"
#include "snan.h"
/* The SGI MIPS floating-point format does not distinguish 0.0 and -0.0. */
static int
@@ -247,6 +248,19 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
ASSERT (length == strlen (result));
free (result);
}
#if HAVE_SNAND
{ /* Signalling NaN. */
size_t length;
char *result =
my_asnprintf (NULL, &length, "%a %d", SNaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (length == strlen (result));
free (result);
}
#endif
{ /* Rounding near the decimal point. */
size_t length;
@@ -590,6 +604,19 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
ASSERT (length == strlen (result));
free (result);
}
#if HAVE_SNANL
{ /* Signalling NaN. */
size_t length;
char *result =
my_asnprintf (NULL, &length, "%La %d", SNaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (length == strlen (result));
free (result);
}
#endif
#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
{ /* Quiet NaN. */
static union { unsigned int word[4]; long double value; } x =
@@ -1115,6 +1142,19 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
ASSERT (length == strlen (result));
free (result);
}
#if HAVE_SNAND
{ /* Signalling NaN. */
size_t length;
char *result =
my_asnprintf (NULL, &length, "%f %d", SNaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (length == strlen (result));
free (result);
}
#endif
{ /* Width. */
size_t length;
@@ -1434,6 +1474,19 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
ASSERT (length == strlen (result));
free (result);
}
#if HAVE_SNANL
{ /* Signalling NaN. */
size_t length;
char *result =
my_asnprintf (NULL, &length, "%Lf %d", SNaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (length == strlen (result));
free (result);
}
#endif
#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
{ /* Quiet NaN. */
static union { unsigned int word[4]; long double value; } x =
@@ -1749,6 +1802,19 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
ASSERT (length == strlen (result));
free (result);
}
#if HAVE_SNAND
{ /* Signalling NaN. */
size_t length;
char *result =
my_asnprintf (NULL, &length, "%F %d", SNaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 1)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (length == strlen (result));
free (result);
}
#endif
{ /* FLAG_ZERO. */
size_t length;
@@ -1885,6 +1951,19 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
ASSERT (length == strlen (result));
free (result);
}
#if HAVE_SNANL
{ /* Signalling NaN. */
size_t length;
char *result =
my_asnprintf (NULL, &length, "%LF %d", SNaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 1)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (length == strlen (result));
free (result);
}
#endif
{ /* FLAG_ZERO. */
size_t length;
@@ -2127,6 +2206,19 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
ASSERT (length == strlen (result));
free (result);
}
#if HAVE_SNAND
{ /* Signalling NaN. */
size_t length;
char *result =
my_asnprintf (NULL, &length, "%e %d", SNaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (length == strlen (result));
free (result);
}
#endif
{ /* Width. */
size_t length;
@@ -2482,6 +2574,19 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
ASSERT (length == strlen (result));
free (result);
}
#if HAVE_SNANL
{ /* Signalling NaN. */
size_t length;
char *result =
my_asnprintf (NULL, &length, "%Le %d", SNaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (length == strlen (result));
free (result);
}
#endif
#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
{ /* Quiet NaN. */
static union { unsigned int word[4]; long double value; } x =
@@ -2917,6 +3022,19 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
ASSERT (length == strlen (result));
free (result);
}
#if HAVE_SNAND
{ /* Signalling NaN. */
size_t length;
char *result =
my_asnprintf (NULL, &length, "%g %d", SNaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (length == strlen (result));
free (result);
}
#endif
{ /* Width. */
size_t length;
@@ -3258,6 +3376,19 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
ASSERT (length == strlen (result));
free (result);
}
#if HAVE_SNANL
{ /* Signalling NaN. */
size_t length;
char *result =
my_asnprintf (NULL, &length, "%Lg %d", SNaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (length == strlen (result));
free (result);
}
#endif
#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
{ /* Quiet NaN. */
static union { unsigned int word[4]; long double value; } x =

View File

@@ -33,6 +33,7 @@
#include "minus-zero.h"
#include "infinity.h"
#include "nan.h"
#include "snan.h"
/* The SGI MIPS floating-point format does not distinguish 0.0 and -0.0. */
static int
@@ -247,6 +248,19 @@ test_function (wchar_t * (*my_asnwprintf) (wchar_t *, size_t *, const wchar_t *,
ASSERT (length == wcslen (result));
free (result);
}
#if HAVE_SNAND
{ /* Signalling NaN. */
size_t length;
wchar_t *result =
my_asnwprintf (NULL, &length, L"%a %d", SNaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (wcslen (result) >= 3 + 3
&& wcsisnan (result, 0, wcslen (result) - 3, 0)
&& wcscmp (result + wcslen (result) - 3, L" 33") == 0);
ASSERT (length == wcslen (result));
free (result);
}
#endif
{ /* Rounding near the decimal point. */
size_t length;
@@ -590,6 +604,19 @@ test_function (wchar_t * (*my_asnwprintf) (wchar_t *, size_t *, const wchar_t *,
ASSERT (length == wcslen (result));
free (result);
}
#if HAVE_SNANL
{ /* Signalling NaN. */
size_t length;
wchar_t *result =
my_asnwprintf (NULL, &length, L"%La %d", SNaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (wcslen (result) >= 3 + 3
&& wcsisnan (result, 0, wcslen (result) - 3, 0)
&& wcscmp (result + wcslen (result) - 3, L" 33") == 0);
ASSERT (length == wcslen (result));
free (result);
}
#endif
#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
{ /* Quiet NaN. */
static union { unsigned int word[4]; long double value; } x =
@@ -1115,6 +1142,19 @@ test_function (wchar_t * (*my_asnwprintf) (wchar_t *, size_t *, const wchar_t *,
ASSERT (length == wcslen (result));
free (result);
}
#if HAVE_SNAND
{ /* Signalling NaN. */
size_t length;
wchar_t *result =
my_asnwprintf (NULL, &length, L"%f %d", SNaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (wcslen (result) >= 3 + 3
&& wcsisnan (result, 0, wcslen (result) - 3, 0)
&& wcscmp (result + wcslen (result) - 3, L" 33") == 0);
ASSERT (length == wcslen (result));
free (result);
}
#endif
{ /* Width. */
size_t length;
@@ -1434,6 +1474,19 @@ test_function (wchar_t * (*my_asnwprintf) (wchar_t *, size_t *, const wchar_t *,
ASSERT (length == wcslen (result));
free (result);
}
#if HAVE_SNANL
{ /* Signalling NaN. */
size_t length;
wchar_t *result =
my_asnwprintf (NULL, &length, L"%Lf %d", SNaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (wcslen (result) >= 3 + 3
&& wcsisnan (result, 0, wcslen (result) - 3, 0)
&& wcscmp (result + wcslen (result) - 3, L" 33") == 0);
ASSERT (length == wcslen (result));
free (result);
}
#endif
#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
{ /* Quiet NaN. */
static union { unsigned int word[4]; long double value; } x =
@@ -1749,6 +1802,19 @@ test_function (wchar_t * (*my_asnwprintf) (wchar_t *, size_t *, const wchar_t *,
ASSERT (length == wcslen (result));
free (result);
}
#if HAVE_SNAND
{ /* Signalling NaN. */
size_t length;
wchar_t *result =
my_asnwprintf (NULL, &length, L"%F %d", SNaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (wcslen (result) >= 3 + 3
&& wcsisnan (result, 0, wcslen (result) - 3, 1)
&& wcscmp (result + wcslen (result) - 3, L" 33") == 0);
ASSERT (length == wcslen (result));
free (result);
}
#endif
{ /* FLAG_ZERO. */
size_t length;
@@ -1885,6 +1951,19 @@ test_function (wchar_t * (*my_asnwprintf) (wchar_t *, size_t *, const wchar_t *,
ASSERT (length == wcslen (result));
free (result);
}
#if HAVE_SNANL
{ /* Signalling NaN. */
size_t length;
wchar_t *result =
my_asnwprintf (NULL, &length, L"%LF %d", SNaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (wcslen (result) >= 3 + 3
&& wcsisnan (result, 0, wcslen (result) - 3, 1)
&& wcscmp (result + wcslen (result) - 3, L" 33") == 0);
ASSERT (length == wcslen (result));
free (result);
}
#endif
{ /* FLAG_ZERO. */
size_t length;
@@ -2127,6 +2206,19 @@ test_function (wchar_t * (*my_asnwprintf) (wchar_t *, size_t *, const wchar_t *,
ASSERT (length == wcslen (result));
free (result);
}
#if HAVE_SNAND
{ /* Signalling NaN. */
size_t length;
wchar_t *result =
my_asnwprintf (NULL, &length, L"%e %d", SNaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (wcslen (result) >= 3 + 3
&& wcsisnan (result, 0, wcslen (result) - 3, 0)
&& wcscmp (result + wcslen (result) - 3, L" 33") == 0);
ASSERT (length == wcslen (result));
free (result);
}
#endif
{ /* Width. */
size_t length;
@@ -2482,6 +2574,19 @@ test_function (wchar_t * (*my_asnwprintf) (wchar_t *, size_t *, const wchar_t *,
ASSERT (length == wcslen (result));
free (result);
}
#if HAVE_SNANL
{ /* Signalling NaN. */
size_t length;
wchar_t *result =
my_asnwprintf (NULL, &length, L"%Le %d", SNaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (wcslen (result) >= 3 + 3
&& wcsisnan (result, 0, wcslen (result) - 3, 0)
&& wcscmp (result + wcslen (result) - 3, L" 33") == 0);
ASSERT (length == wcslen (result));
free (result);
}
#endif
#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
{ /* Quiet NaN. */
static union { unsigned int word[4]; long double value; } x =
@@ -2917,6 +3022,19 @@ test_function (wchar_t * (*my_asnwprintf) (wchar_t *, size_t *, const wchar_t *,
ASSERT (length == wcslen (result));
free (result);
}
#if HAVE_SNAND
{ /* Signalling NaN. */
size_t length;
wchar_t *result =
my_asnwprintf (NULL, &length, L"%g %d", SNaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (wcslen (result) >= 3 + 3
&& wcsisnan (result, 0, wcslen (result) - 3, 0)
&& wcscmp (result + wcslen (result) - 3, L" 33") == 0);
ASSERT (length == wcslen (result));
free (result);
}
#endif
{ /* Width. */
size_t length;
@@ -3258,6 +3376,19 @@ test_function (wchar_t * (*my_asnwprintf) (wchar_t *, size_t *, const wchar_t *,
ASSERT (length == wcslen (result));
free (result);
}
#if HAVE_SNANL
{ /* Signalling NaN. */
size_t length;
wchar_t *result =
my_asnwprintf (NULL, &length, L"%Lg %d", SNaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (wcslen (result) >= 3 + 3
&& wcsisnan (result, 0, wcslen (result) - 3, 0)
&& wcscmp (result + wcslen (result) - 3, L" 33") == 0);
ASSERT (length == wcslen (result));
free (result);
}
#endif
#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
{ /* Quiet NaN. */
static union { unsigned int word[4]; long double value; } x =

View File

@@ -32,6 +32,7 @@
#include "minus-zero.h"
#include "infinity.h"
#include "nan.h"
#include "snan.h"
/* The SGI MIPS floating-point format does not distinguish 0.0 and -0.0. */
static int
@@ -227,6 +228,19 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
ASSERT (retval == strlen (result));
free (result);
}
#if HAVE_SNAND
{ /* Signalling NaN. */
char *result;
int retval =
my_asprintf (&result, "%a %d", SNaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
free (result);
}
#endif
{ /* Rounding near the decimal point. */
char *result;
@@ -571,6 +585,19 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
ASSERT (retval == strlen (result));
free (result);
}
#if HAVE_SNANL
{ /* Signalling NaN. */
char *result;
int retval =
my_asprintf (&result, "%La %d", SNaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
free (result);
}
#endif
#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
{ /* Quiet NaN. */
static union { unsigned int word[4]; long double value; } x =
@@ -1096,6 +1123,19 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
ASSERT (retval == strlen (result));
free (result);
}
#if HAVE_SNAND
{ /* Signalling NaN. */
char *result;
int retval =
my_asprintf (&result, "%f %d", SNaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
free (result);
}
#endif
{ /* Width. */
char *result;
@@ -1415,6 +1455,19 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
ASSERT (retval == strlen (result));
free (result);
}
#if HAVE_SNANL
{ /* Signalling NaN. */
char *result;
int retval =
my_asprintf (&result, "%Lf %d", SNaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
free (result);
}
#endif
#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
{ /* Quiet NaN. */
static union { unsigned int word[4]; long double value; } x =
@@ -1730,6 +1783,19 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
ASSERT (retval == strlen (result));
free (result);
}
#if HAVE_SNAND
{ /* Signalling NaN. */
char *result;
int retval =
my_asprintf (&result, "%F %d", SNaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 1)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
free (result);
}
#endif
{ /* FLAG_ZERO. */
char *result;
@@ -1866,6 +1932,19 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
ASSERT (retval == strlen (result));
free (result);
}
#if HAVE_SNANL
{ /* Signalling NaN. */
char *result;
int retval =
my_asprintf (&result, "%LF %d", SNaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 1)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
free (result);
}
#endif
{ /* FLAG_ZERO. */
char *result;
@@ -2108,6 +2187,19 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
ASSERT (retval == strlen (result));
free (result);
}
#if HAVE_SNAND
{ /* Signalling NaN. */
char *result;
int retval =
my_asprintf (&result, "%e %d", SNaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
free (result);
}
#endif
{ /* Width. */
char *result;
@@ -2463,6 +2555,19 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
ASSERT (retval == strlen (result));
free (result);
}
#if HAVE_SNANL
{ /* Signalling NaN. */
char *result;
int retval =
my_asprintf (&result, "%Le %d", SNaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
free (result);
}
#endif
#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
{ /* Quiet NaN. */
static union { unsigned int word[4]; long double value; } x =
@@ -2902,6 +3007,19 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
ASSERT (retval == strlen (result));
free (result);
}
#if HAVE_SNAND
{ /* Signalling NaN. */
char *result;
int retval =
my_asprintf (&result, "%g %d", SNaNd (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
free (result);
}
#endif
{ /* Width. */
char *result;
@@ -3243,6 +3361,19 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
ASSERT (retval == strlen (result));
free (result);
}
#if HAVE_SNANL
{ /* Signalling NaN. */
char *result;
int retval =
my_asprintf (&result, "%Lg %d", SNaNl (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
&& strcmp (result + strlen (result) - 3, " 33") == 0);
ASSERT (retval == strlen (result));
free (result);
}
#endif
#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
{ /* Quiet NaN. */
static union { unsigned int word[4]; long double value; } x =