diff options
author | das <das@FreeBSD.org> | 2004-01-19 05:59:07 +0000 |
---|---|---|
committer | das <das@FreeBSD.org> | 2004-01-19 05:59:07 +0000 |
commit | 5a0431f630ef41b4c8dfbf0aa35c96e9104ea4c3 (patch) | |
tree | 48047fb3fbaf585d8bf9f463b38049b813fdaa53 /tools/regression | |
parent | ee1fa904fb4b794c8c387cbb3076235a8a0e0bb7 (diff) | |
download | FreeBSD-src-5a0431f630ef41b4c8dfbf0aa35c96e9104ea4c3.zip FreeBSD-src-5a0431f630ef41b4c8dfbf0aa35c96e9104ea4c3.tar.gz |
Add regression tests for printf's %a/%A formats.
While here, disable some of the long double tests on i386, since
FreeBSD/i386 is the only port that doesn't evaluate long doubles in
their full precision (due to constant folding bugs in gcc).
Diffstat (limited to 'tools/regression')
-rw-r--r-- | tools/regression/lib/libc/stdio/test-printfloat.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/tools/regression/lib/libc/stdio/test-printfloat.c b/tools/regression/lib/libc/stdio/test-printfloat.c index bc1e533..ab4d502 100644 --- a/tools/regression/lib/libc/stdio/test-printfloat.c +++ b/tools/regression/lib/libc/stdio/test-printfloat.c @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include <assert.h> #include <err.h> #include <float.h> +#include <ieeefp.h> #include <locale.h> #include <math.h> #include <stdio.h> @@ -69,7 +70,7 @@ main(int argc, char *argv[]) testfmt("1234567.800000", "%Lf", 1234567.8L); testfmt("1.23457E+06", "%LG", 1234567.8L); -#if LDBL_MANT_DIG > DBL_MANT_DIG +#if (LDBL_MANT_DIG > DBL_MANT_DIG) && !defined(__i386__) testfmt("123456789.864210", "%Lf", 123456789.8642097531L); testfmt("-1.23457E+08", "%LG", -123456789.8642097531L); testfmt("123456789.8642097531", "%.10Lf", 123456789.8642097531L); @@ -159,6 +160,42 @@ main(int argc, char *argv[]) testfmt("9.0e+01", "%4.1e", 90.0); testfmt("1e+02", "%4.0e", 100.0); + /* + * Hexadecimal floating point (%a, %A) tests. Some of these + * are only valid if the implementation converts to hex digits + * on nibble boundaries. + */ + + testfmt("0x0p+0", "%a", 0x0.0p0); + testfmt("0X0.P+0", "%#LA", 0x0.0p0L); + testfmt("inf", "%La", (long double)INFINITY); + testfmt("+INF", "%+A", INFINITY); + testfmt("nan", "%La", (long double)NAN); + testfmt("NAN", "%A", NAN); + + testfmt(" 0x1.23p+0", "%10a", 0x1.23p0); + testfmt(" 0x1.23p-500", "%12a", 0x1.23p-500); + testfmt(" 0x1.2p+40", "%10.1a", 0x1.23p40); + testfmt(" 0X1.230000000000000000000000P-4", "%32.24A", 0x1.23p-4); + +#if (LDBL_MANT_DIG == 64) && !defined(__i386__) + testfmt("0xc.90fdaa22168c234p-2", "%La", 0x3.243f6a8885a308dp0L); +#elif (LDBL_MANT_DIG == 113) + testfmt("0x1.921fb54442d18469898cc51701b8p+1", "%La", + 0x3.243f6a8885a308d313198a2e037p0L); +#else + testfmt("0xc.90fdaa22168cp-2", "%La", 0x3.243f6a8885a31p0L); +#endif + + fpsetround(FP_RN); + testfmt("0x1.23456789abcdep+4", "%a", 0x1.23456789abcdep4); + testfmt("0X1.23456789ABDP+0", "%.11A", 0x1.23456789abcdep0); + testfmt("-0x1.23456p+0", "%.5a", -0x1.23456789abcdep0); + testfmt("0x1.234568p+0", "%.6a", 0x1.23456789abcdep0); + testfmt("-0x1.234566p+0", "%.6a", -0x1.23456689abcdep0); + testfmt("0x2.00p-1030", "%.2a", 0x1.fffp-1030); + testfmt("0x1.00p-1026", "%.2a", 0xf.fffp-1030); + printf("PASS printfloat\n"); return (0); |