diff options
author | das <das@FreeBSD.org> | 2004-01-19 05:30:56 +0000 |
---|---|---|
committer | das <das@FreeBSD.org> | 2004-01-19 05:30:56 +0000 |
commit | ee1fa904fb4b794c8c387cbb3076235a8a0e0bb7 (patch) | |
tree | 98eae325dadc0d4f31a3b67ad757f3ef011b7871 /tools/regression/lib/libc | |
parent | 8fb32b257351c76898deb725a266d5dfb7ba1c14 (diff) | |
download | FreeBSD-src-ee1fa904fb4b794c8c387cbb3076235a8a0e0bb7.zip FreeBSD-src-ee1fa904fb4b794c8c387cbb3076235a8a0e0bb7.tar.gz |
Add regression tests for some of the bugs recently discovered in the
vendor's strtod() implementation.
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/lib/libc')
-rw-r--r-- | tools/regression/lib/libc/stdio/test-scanfloat.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/tools/regression/lib/libc/stdio/test-scanfloat.c b/tools/regression/lib/libc/stdio/test-scanfloat.c index 6666fd2..791a33a 100644 --- a/tools/regression/lib/libc/stdio/test-scanfloat.c +++ b/tools/regression/lib/libc/stdio/test-scanfloat.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include <assert.h> #include <float.h> +#include <ieeefp.h> #include <locale.h> #include <math.h> #include <stdio.h> @@ -62,9 +63,6 @@ main(int argc, char *argv[]) sscanf("3.141592653589793", "%lf", &d); assert(eq(DBL, d, 3.141592653589793)); - sscanf("3.14159265358979323846", "%Lg", &ld); - assert(eq(LDBL, ld, 3.14159265358979323846L)); - sscanf("1.234568e+06", "%E", &f); assert(eq(FLT, f, 1.234568e+06)); @@ -121,7 +119,10 @@ main(int argc, char *argv[]) assert(d == 0x90a.bcdefp+09); assert(strcmp(buf, "a") == 0); -#if LDBL_MANT_DIG > DBL_MANT_DIG +#if (LDBL_MANT_DIG > DBL_MANT_DIG) && !defined(__i386__) + sscanf("3.14159265358979323846", "%Lg", &ld); + assert(eq(LDBL, ld, 3.14159265358979323846L)); + sscanf(" 0X.0123456789abcdefffp-3g", "%Le%s", &ld, buf); assert(ld == 0x0.0123456789abcdefffp-3L); assert(strcmp(buf, "g") == 0); @@ -163,6 +164,16 @@ main(int argc, char *argv[]) sscanf("-nan", "%le", &d); assert(isnan(d)); + fpsetround(FP_RN); + + /* strtod() should round small numbers to 0. */ + sscanf("0x1.23p-5000", "%le", &d); + assert(d == 0.0); + + /* Extra digits in a denormal shouldn't break anything. */ + sscanf("0x1.2345678p-1050", "%le", &d); + assert(d == 0x1.234568p-1050); + printf("PASS scanfloat\n"); return (0); |