aboutsummaryrefslogtreecommitdiff
path: root/math/test-misc.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
committerJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
commit0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (patch)
tree2ea1f8305970753e4a657acb2ccc15ca3eec8e2c /math/test-misc.c
parent7d58530341304d403a6626d7f7a1913165fe2f32 (diff)
downloadglibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.zip
glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.gz
glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.bz2
2.5-18.1
Diffstat (limited to 'math/test-misc.c')
-rw-r--r--math/test-misc.c114
1 files changed, 103 insertions, 11 deletions
diff --git a/math/test-misc.c b/math/test-misc.c
index fa958d4..862e11f 100644
--- a/math/test-misc.c
+++ b/math/test-misc.c
@@ -1,5 +1,5 @@
/* Miscellaneous tests which don't fit anywhere else.
- Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001, 2004, 2005, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -44,7 +44,6 @@ main (void)
}
}
-# if __GNUC__ >= 3 || __GNUC_MINOR__ >= 96
{
long double x;
long double m;
@@ -52,17 +51,17 @@ main (void)
int e;
int i;
-# if LDBL_MANT_DIG == 64
+# if LDBL_MANT_DIG == 64
m = 0xf.fffffffffffffffp-4L;
-# elif LDBL_MANT_DIG == 106
+# elif LDBL_MANT_DIG == 106
/* This has to match the mantissa of LDBL_MAX which actually does have a
missing bit in the middle. */
m = 0x1.fffffffffffff7ffffffffffff8p-1L;
-# elif LDBL_MANT_DIG == 113
+# elif LDBL_MANT_DIG == 113
m = 0x1.ffffffffffffffffffffffffffffp-1L;
-# else
-# error "Please adjust"
-# endif
+# else
+# error "Please adjust"
+# endif
for (i = LDBL_MAX_EXP, x = LDBL_MAX; i >= LDBL_MIN_EXP; --i, x /= 2.0L)
{
@@ -106,9 +105,8 @@ main (void)
}
}
-# endif
-#if 0
+# if 0
{
int e;
long double r = frexpl (LDBL_MIN * LDBL_EPSILON, &e);
@@ -126,7 +124,7 @@ main (void)
result = 1;
}
}
-#endif
+# endif
#endif
{
@@ -1143,5 +1141,99 @@ main (void)
}
#endif
+ /* The tests here are very similar to tests earlier in this file,
+ the important difference is just that there are no intervening
+ union variables that cause some GCC versions to hide possible
+ bugs in nextafter* implementation. */
+ if (nextafterf (nextafterf (FLT_MIN, FLT_MIN / 2.0), FLT_MIN) != FLT_MIN)
+ {
+ puts ("nextafterf FLT_MIN test failed");
+ result = 1;
+ }
+ if (nextafterf (nextafterf (-FLT_MIN, -FLT_MIN / 2.0), -FLT_MIN)
+ != -FLT_MIN)
+ {
+ puts ("nextafterf -FLT_MIN test failed");
+ result = 1;
+ }
+ if (nextafter (nextafter (DBL_MIN, DBL_MIN / 2.0), DBL_MIN) != DBL_MIN)
+ {
+ puts ("nextafter DBL_MIN test failed");
+ result = 1;
+ }
+ if (nextafter (nextafter (-DBL_MIN, -DBL_MIN / 2.0), -DBL_MIN) != -DBL_MIN)
+ {
+ puts ("nextafter -DBL_MIN test failed");
+ result = 1;
+ }
+#ifndef NO_LONG_DOUBLE
+ if (nextafterl (nextafterl (LDBL_MIN, LDBL_MIN / 2.0), LDBL_MIN)
+ != LDBL_MIN)
+ {
+ puts ("nextafterl LDBL_MIN test failed");
+ result = 1;
+ }
+ if (nextafterl (nextafterl (-LDBL_MIN, -LDBL_MIN / 2.0), -LDBL_MIN)
+ != -LDBL_MIN)
+ {
+ puts ("nextafterl -LDBL_MIN test failed");
+ result = 1;
+ }
+#endif
+
+ volatile float f1 = FLT_MAX;
+ volatile float f2 = FLT_MAX / 2;
+ (void) &f1;
+ (void) &f2;
+ feclearexcept (FE_ALL_EXCEPT);
+ f2 += f1;
+ int fe = fetestexcept (FE_ALL_EXCEPT);
+ if (fe != (FE_OVERFLOW | FE_INEXACT))
+ {
+ printf ("float overflow test failed: %x\n", fe);
+ result = 1;
+ }
+
+ volatile double d1 = DBL_MAX;
+ volatile double d2 = DBL_MAX / 2;
+ (void) &d1;
+ (void) &d2;
+ feclearexcept (FE_ALL_EXCEPT);
+ d2 += d1;
+ fe = fetestexcept (FE_ALL_EXCEPT);
+ if (fe != (FE_OVERFLOW | FE_INEXACT))
+ {
+ printf ("double overflow test failed: %x\n", fe);
+ result = 1;
+ }
+
+#ifndef NO_LONG_DOUBLE
+ volatile long double ld1 = LDBL_MAX;
+ volatile long double ld2 = LDBL_MAX / 2;
+ (void) &ld1;
+ (void) &ld2;
+ feclearexcept (FE_ALL_EXCEPT);
+ ld2 += ld1;
+ fe = fetestexcept (FE_ALL_EXCEPT);
+ if (fe != (FE_OVERFLOW | FE_INEXACT))
+ {
+ printf ("long double overflow test failed: %x\n", fe);
+ result = 1;
+ }
+#endif
+
+#if !defined NO_LONG_DOUBLE && LDBL_MANT_DIG == 113
+ volatile long double ld3 = 0x1.0000000000010000000100000001p+1;
+ volatile long double ld4 = 0x1.0000000000000000000000000001p+1;
+ (void) &ld3;
+ (void) &ld4;
+ ld3 -= ld4;
+ if (ld3 != 0x1.0p-47)
+ {
+ printf ("long double subtraction test failed %.28La\n", ld3);
+ result = 1;
+ }
+#endif
+
return result;
}