mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-23 03:10:05 +00:00
More tests for external charater sequences representing NaNs.
This commit is contained in:
parent
a8b792d6bb
commit
ee091edf1a
@ -1,5 +1,11 @@
|
||||
2013-04-05 Thomas Schwinge <thomas@codesourcery.com>
|
||||
|
||||
* stdio-common/tstdiomisc.c (snanval, msnanval, lsnanval)
|
||||
(lmsnanval): New variables.
|
||||
(F): Add conversion tests.
|
||||
* stdlib/tst-strtod6.c (do_test): Add issignaling tests.
|
||||
* stdlib/Makefile ($(objpfx)tst-strtod6): Depend on $(link-libm).
|
||||
|
||||
* stdio-common/tstdiomisc.c (F): Properly collect individual
|
||||
tests' results.
|
||||
|
||||
|
@ -47,8 +47,14 @@ t2 (void)
|
||||
}
|
||||
|
||||
volatile double qnanval;
|
||||
volatile double infval;
|
||||
volatile long double lqnanval;
|
||||
/* A sNaN is only guaranteed to be representable in variables with static (or
|
||||
thread-local) storage duration. */
|
||||
static volatile double snanval = __builtin_nans("");
|
||||
static volatile double msnanval = -__builtin_nans("");
|
||||
static volatile long double lsnanval = __builtin_nansl("");
|
||||
static volatile long double lmsnanval = -__builtin_nansl("");
|
||||
volatile double infval;
|
||||
volatile long double linfval;
|
||||
|
||||
|
||||
@ -74,6 +80,19 @@ F (void)
|
||||
printf ("expected \"-nan -NAN -nan -NAN -nan -NAN -nan -NAN\", got \"%s\"\n",
|
||||
buf);
|
||||
|
||||
snprintf (buf, sizeof buf, "%a %A %e %E %f %F %g %G",
|
||||
snanval, snanval, snanval, snanval,
|
||||
snanval, snanval, snanval, snanval);
|
||||
result |= strcmp (buf, "nan NAN nan NAN nan NAN nan NAN") != 0;
|
||||
printf ("expected \"nan NAN nan NAN nan NAN nan NAN\", got \"%s\"\n", buf);
|
||||
|
||||
snprintf (buf, sizeof buf, "%a %A %e %E %f %F %g %G",
|
||||
msnanval, msnanval, msnanval, msnanval,
|
||||
msnanval, msnanval, msnanval, msnanval);
|
||||
result |= strcmp (buf, "-nan -NAN -nan -NAN -nan -NAN -nan -NAN") != 0;
|
||||
printf ("expected \"-nan -NAN -nan -NAN -nan -NAN -nan -NAN\", got \"%s\"\n",
|
||||
buf);
|
||||
|
||||
infval = DBL_MAX * DBL_MAX;
|
||||
|
||||
snprintf (buf, sizeof buf, "%a %A %e %E %f %F %g %G",
|
||||
@ -101,6 +120,19 @@ F (void)
|
||||
printf ("expected L\"-nan -NAN -nan -NAN -nan -NAN -nan -NAN\", got L\"%S\"\n",
|
||||
wbuf);
|
||||
|
||||
swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), L"%a %A %e %E %f %F %g %G",
|
||||
snanval, snanval, snanval, snanval,
|
||||
snanval, snanval, snanval, snanval);
|
||||
result |= wcscmp (wbuf, L"nan NAN nan NAN nan NAN nan NAN") != 0;
|
||||
printf ("expected L\"nan NAN nan NAN nan NAN nan NAN\", got L\"%S\"\n", wbuf);
|
||||
|
||||
swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), L"%a %A %e %E %f %F %g %G",
|
||||
msnanval, msnanval, msnanval, msnanval,
|
||||
msnanval, msnanval, msnanval, msnanval);
|
||||
result |= wcscmp (wbuf, L"-nan -NAN -nan -NAN -nan -NAN -nan -NAN") != 0;
|
||||
printf ("expected L\"-nan -NAN -nan -NAN -nan -NAN -nan -NAN\", got L\"%S\"\n",
|
||||
wbuf);
|
||||
|
||||
swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), L"%a %A %e %E %f %F %g %G",
|
||||
infval, infval, infval, infval, infval, infval, infval, infval);
|
||||
result |= wcscmp (wbuf, L"inf INF inf INF inf INF inf INF") != 0;
|
||||
@ -128,6 +160,19 @@ F (void)
|
||||
printf ("expected \"-nan -NAN -nan -NAN -nan -NAN -nan -NAN\", got \"%s\"\n",
|
||||
buf);
|
||||
|
||||
snprintf (buf, sizeof buf, "%La %LA %Le %LE %Lf %LF %Lg %LG",
|
||||
lsnanval, lsnanval, lsnanval, lsnanval,
|
||||
lsnanval, lsnanval, lsnanval, lsnanval);
|
||||
result |= strcmp (buf, "nan NAN nan NAN nan NAN nan NAN") != 0;
|
||||
printf ("expected \"nan NAN nan NAN nan NAN nan NAN\", got \"%s\"\n", buf);
|
||||
|
||||
snprintf (buf, sizeof buf, "%La %LA %Le %LE %Lf %LF %Lg %LG",
|
||||
lmsnanval, lmsnanval, lmsnanval, lmsnanval,
|
||||
lmsnanval, lmsnanval, lmsnanval, lmsnanval);
|
||||
result |= strcmp (buf, "-nan -NAN -nan -NAN -nan -NAN -nan -NAN") != 0;
|
||||
printf ("expected \"-nan -NAN -nan -NAN -nan -NAN -nan -NAN\", got \"%s\"\n",
|
||||
buf);
|
||||
|
||||
linfval = LDBL_MAX * LDBL_MAX;
|
||||
|
||||
snprintf (buf, sizeof buf, "%La %LA %Le %LE %Lf %LF %Lg %LG",
|
||||
@ -158,6 +203,21 @@ F (void)
|
||||
printf ("expected L\"-nan -NAN -nan -NAN -nan -NAN -nan -NAN\", got L\"%S\"\n",
|
||||
wbuf);
|
||||
|
||||
swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]),
|
||||
L"%La %LA %Le %LE %Lf %LF %Lg %LG",
|
||||
lsnanval, lsnanval, lsnanval, lsnanval,
|
||||
lsnanval, lsnanval, lsnanval, lsnanval);
|
||||
result |= wcscmp (wbuf, L"nan NAN nan NAN nan NAN nan NAN") != 0;
|
||||
printf ("expected L\"nan NAN nan NAN nan NAN nan NAN\", got L\"%S\"\n", wbuf);
|
||||
|
||||
swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]),
|
||||
L"%La %LA %Le %LE %Lf %LF %Lg %LG",
|
||||
lmsnanval, lmsnanval, lmsnanval, lmsnanval,
|
||||
lmsnanval, lmsnanval, lmsnanval, lmsnanval);
|
||||
result |= wcscmp (wbuf, L"-nan -NAN -nan -NAN -nan -NAN -nan -NAN") != 0;
|
||||
printf ("expected L\"-nan -NAN -nan -NAN -nan -NAN -nan -NAN\", got L\"%S\"\n",
|
||||
wbuf);
|
||||
|
||||
swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]),
|
||||
L"%La %LA %Le %LE %Lf %LF %Lg %LG",
|
||||
linfval, linfval, linfval, linfval,
|
||||
|
@ -157,6 +157,7 @@ $(objpfx)bug-getcontext: $(link-libm)
|
||||
$(objpfx)tst-strtod-round: $(link-libm)
|
||||
$(objpfx)tst-tininess: $(link-libm)
|
||||
$(objpfx)tst-strtod-underflow: $(link-libm)
|
||||
$(objpfx)tst-strtod6: $(link-libm)
|
||||
|
||||
tst-tls-atexit-lib.so-no-z-defs = yes
|
||||
|
||||
|
@ -16,6 +16,11 @@ do_test (void)
|
||||
puts ("strtod did not return NAN");
|
||||
result = 1;
|
||||
}
|
||||
if (issignaling (d))
|
||||
{
|
||||
puts ("strtod returned a sNAN");
|
||||
result = 1;
|
||||
}
|
||||
if (strcmp (endp, "something") != 0)
|
||||
{
|
||||
puts ("strtod set incorrect end pointer");
|
||||
@ -28,6 +33,11 @@ do_test (void)
|
||||
puts ("strtof did not return NAN");
|
||||
result = 1;
|
||||
}
|
||||
if (issignaling (f))
|
||||
{
|
||||
puts ("strtof returned a sNAN");
|
||||
result = 1;
|
||||
}
|
||||
if (strcmp (endp, "something") != 0)
|
||||
{
|
||||
puts ("strtof set incorrect end pointer");
|
||||
@ -40,6 +50,11 @@ do_test (void)
|
||||
puts ("strtold did not return NAN");
|
||||
result = 1;
|
||||
}
|
||||
if (issignaling (ld))
|
||||
{
|
||||
puts ("strtold returned a sNAN");
|
||||
result = 1;
|
||||
}
|
||||
if (strcmp (endp, "something") != 0)
|
||||
{
|
||||
puts ("strtold set incorrect end pointer");
|
||||
|
Loading…
Reference in New Issue
Block a user