diff options
author | Thomas Schwinge <thomas@codesourcery.com> | 2013-04-05 20:28:47 +0200 |
---|---|---|
committer | Thomas Schwinge <thomas@codesourcery.com> | 2013-04-05 22:41:20 +0200 |
commit | ee091edf1a16312fff0cc3c6ae0116aded7f1dbf (patch) | |
tree | 644d3aebe2270770af04f42a32cd70715967cf1b /stdio-common | |
parent | a8b792d6bb54fda2ff66f8b0c725397d402f367e (diff) | |
download | glibc-ee091edf1a16312fff0cc3c6ae0116aded7f1dbf.tar.gz glibc-ee091edf1a16312fff0cc3c6ae0116aded7f1dbf.tar.xz glibc-ee091edf1a16312fff0cc3c6ae0116aded7f1dbf.zip |
More tests for external charater sequences representing NaNs.
Diffstat (limited to 'stdio-common')
-rw-r--r-- | stdio-common/tstdiomisc.c | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/stdio-common/tstdiomisc.c b/stdio-common/tstdiomisc.c index fa07aa5a89..5c046bbef3 100644 --- a/stdio-common/tstdiomisc.c +++ b/stdio-common/tstdiomisc.c @@ -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", @@ -102,6 +121,19 @@ F (void) 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; printf ("expected L\"inf INF inf INF inf INF inf INF\", got L\"%S\"\n", wbuf); @@ -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", @@ -160,6 +205,21 @@ F (void) 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, linfval, linfval, linfval, linfval); result |= wcscmp (wbuf, L"inf INF inf INF inf INF inf INF") != 0; |