This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
PATCH: Relax one test in 18_support/numeric_limits.cc for FreeBSD only
- From: Loren James Rittle <rittle at latour dot rsch dot comm dot mot dot com>
- To: libstdc++ at gcc dot gnu dot org
- Date: Thu, 17 Jan 2002 02:12:33 -0600 (CST)
- Subject: PATCH: Relax one test in 18_support/numeric_limits.cc for FreeBSD only
- Reply-to: rittle at labs dot mot dot com
Permission to apply? The code comment explains all (I hope ;-).
Allows entire test to now PASS and is really only relaxed to the point
where user applications should use the C++ header information. I
avoided using fabs, etc on purpose.
* testsuite/18_support/numeric_limits.cc (test_extrema<long double>):
Add specialization for FreeBSD systems only to avoid losing test
only due to extra precision unmentioned in system headers.
Index: testsuite/18_support/numeric_limits.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/18_support/numeric_limits.cc,v
retrieving revision 1.8
diff -c -r1.8 numeric_limits.cc
*** numeric_limits.cc 2001/12/12 20:23:29 1.8
--- numeric_limits.cc 2002/01/17 07:46:13
***************
*** 59,64 ****
--- 59,89 ----
VERIFY( extrema<T>::max == std::numeric_limits<T>::max() );
}
+ #ifdef __FreeBSD__
+ // This specialization allows the extra precision unmentioned
+ // in system headers yet supported by long double on FreeBSD to
+ // not cause a gratuitous FAIL for the entire test. Using this
+ // technique to compare the residual against epsilon ensures that
+ // any major breakage will still be detected (although obviously not
+ // as tight as the exact equality check that would have been generated
+ // by default). This replacement test is allowable by the fact that
+ // C++ limits should match the system provided limits for C even if
+ // they were wrong verses the actual FP hardware.
+ template<>
+ void test_extrema<long double>()
+ {
+ typedef long double T;
+ VERIFY( (extrema<T>::min - std::numeric_limits<T>::min())
+ < std::numeric_limits<T>::epsilon() );
+ VERIFY( (std::numeric_limits<T>::min() - extrema<T>::min)
+ < std::numeric_limits<T>::epsilon() );
+ VERIFY( (extrema<T>::max / std::numeric_limits<T>::max())
+ < (1 + std::numeric_limits<T>::epsilon()) );
+ VERIFY( (std::numeric_limits<T>::max() / extrema<T>::max)
+ < (1 + std::numeric_limits<T>::epsilon()) );
+ }
+ #endif
+
#ifdef __CHAR_UNSIGNED__
#define char_is_signed false
#else