Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r66451 - trunk/libs/math/test
From: john_at_[hidden]
Date: 2010-11-08 07:55:13


Author: johnmaddock
Date: 2010-11-08 07:55:06 EST (Mon, 08 Nov 2010)
New Revision: 66451
URL: http://svn.boost.org/trac/boost/changeset/66451

Log:
Fix tests that fail with gcc in C++0x mode.
Add some stricter tests for fp-classification routines.
Text files modified:
   trunk/libs/math/test/test_classify.cpp | 8 ++++++++
   trunk/libs/math/test/test_lognormal.cpp | 4 +++-
   trunk/libs/math/test/test_normal.cpp | 4 +++-
   trunk/libs/math/test/test_sign.cpp | 39 +++++++++++++++++++++++++++++++++++++++
   trunk/libs/math/test/test_weibull.cpp | 4 +++-
   5 files changed, 56 insertions(+), 3 deletions(-)

Modified: trunk/libs/math/test/test_classify.cpp
==============================================================================
--- trunk/libs/math/test/test_classify.cpp (original)
+++ trunk/libs/math/test/test_classify.cpp 2010-11-08 07:55:06 EST (Mon, 08 Nov 2010)
@@ -74,6 +74,14 @@
       t = (std::numeric_limits<T>::max)();
       BOOST_CHECK_EQUAL((::boost::math::fpclassify)(t), (int)FP_NORMAL);
       BOOST_CHECK_EQUAL((::boost::math::fpclassify)(-t), (int)FP_NORMAL);
+ BOOST_CHECK_EQUAL((::boost::math::isfinite)(t), true);
+ BOOST_CHECK_EQUAL((::boost::math::isfinite)(-t), true);
+ BOOST_CHECK_EQUAL((::boost::math::isinf)(t), false);
+ BOOST_CHECK_EQUAL((::boost::math::isinf)(-t), false);
+ BOOST_CHECK_EQUAL((::boost::math::isnan)(t), false);
+ BOOST_CHECK_EQUAL((::boost::math::isnan)(-t), false);
+ BOOST_CHECK_EQUAL((::boost::math::isnormal)(t), true);
+ BOOST_CHECK_EQUAL((::boost::math::isnormal)(-t), true);
       t = (std::numeric_limits<T>::min)();
       BOOST_CHECK_EQUAL((::boost::math::fpclassify)(t), (int)FP_NORMAL);
       BOOST_CHECK_EQUAL((::boost::math::fpclassify)(-t), (int)FP_NORMAL);

Modified: trunk/libs/math/test/test_lognormal.cpp
==============================================================================
--- trunk/libs/math/test/test_lognormal.cpp (original)
+++ trunk/libs/math/test/test_lognormal.cpp 2010-11-08 07:55:06 EST (Mon, 08 Nov 2010)
@@ -179,7 +179,9 @@
    cout << "Tolerance for type " << typeid(RealType).name() << " is " << tolerance << " %" << endl;
    lognormal_distribution<RealType> dist(8, 3);
    RealType x = static_cast<RealType>(0.125);
- using namespace std; // ADL of std names.
+
+ BOOST_MATH_STD_USING // ADL of std math lib names.
+
    // mean:
    BOOST_CHECK_CLOSE(
       mean(dist)

Modified: trunk/libs/math/test/test_normal.cpp
==============================================================================
--- trunk/libs/math/test/test_normal.cpp (original)
+++ trunk/libs/math/test/test_normal.cpp 2010-11-08 07:55:06 EST (Mon, 08 Nov 2010)
@@ -214,7 +214,9 @@
     RealType tol2 = boost::math::tools::epsilon<RealType>() * 5;
     normal_distribution<RealType> dist(8, 3);
     RealType x = static_cast<RealType>(0.125);
- using namespace std; // ADL of std names.
+
+ BOOST_MATH_STD_USING // ADL of std math lib names
+
     // mean:
     BOOST_CHECK_CLOSE(
        mean(dist)

Modified: trunk/libs/math/test/test_sign.cpp
==============================================================================
--- trunk/libs/math/test/test_sign.cpp (original)
+++ trunk/libs/math/test/test_sign.cpp 2010-11-08 07:55:06 EST (Mon, 08 Nov 2010)
@@ -77,6 +77,45 @@
       BOOST_CHECK_EQUAL((boost::math::copysign)(c, a), RealType(-1));
    }
 #endif
+ //
+ // Try some extreme values:
+ //
+ a = boost::math::tools::min_value<RealType>();
+ b = -a;
+ c = -1;
+ BOOST_CHECK((boost::math::signbit)(a) == 0);
+ BOOST_CHECK_EQUAL((boost::math::sign)(a), 1);
+ BOOST_CHECK_EQUAL((boost::math::copysign)(c, a), RealType(1));
+ BOOST_CHECK((boost::math::signbit)(b) != 0);
+ BOOST_CHECK_EQUAL((boost::math::sign)(b), -1);
+ c = 1;
+ BOOST_CHECK_EQUAL((boost::math::copysign)(c, b), RealType(-1));
+ //
+ // try denormalised values:
+ //
+ a /= 4;
+ if(a != 0)
+ {
+ b = -a;
+ c = -1;
+ BOOST_CHECK((boost::math::signbit)(a) == 0);
+ BOOST_CHECK_EQUAL((boost::math::sign)(a), 1);
+ BOOST_CHECK_EQUAL((boost::math::copysign)(c, a), RealType(1));
+ BOOST_CHECK((boost::math::signbit)(b) != 0);
+ BOOST_CHECK_EQUAL((boost::math::sign)(b), -1);
+ c = 1;
+ BOOST_CHECK_EQUAL((boost::math::copysign)(c, b), RealType(-1));
+ }
+ a = boost::math::tools::max_value<RealType>() / 2;
+ b = -a;
+ c = -1;
+ BOOST_CHECK((boost::math::signbit)(a) == 0);
+ BOOST_CHECK_EQUAL((boost::math::sign)(a), 1);
+ BOOST_CHECK_EQUAL((boost::math::copysign)(c, a), RealType(1));
+ BOOST_CHECK((boost::math::signbit)(b) != 0);
+ BOOST_CHECK_EQUAL((boost::math::sign)(b), -1);
+ c = 1;
+ BOOST_CHECK_EQUAL((boost::math::copysign)(c, b), RealType(-1));
 }
 
 

Modified: trunk/libs/math/test/test_weibull.cpp
==============================================================================
--- trunk/libs/math/test/test_weibull.cpp (original)
+++ trunk/libs/math/test/test_weibull.cpp 2010-11-08 07:55:06 EST (Mon, 08 Nov 2010)
@@ -254,7 +254,9 @@
    cout << "Tolerance for type " << typeid(RealType).name() << " is " << tolerance << " %" << endl;
    weibull_distribution<RealType> dist(2, 3);
    RealType x = static_cast<RealType>(0.125);
- using namespace std; // ADL of std names.
+
+ BOOST_MATH_STD_USING // ADL of std lib math functions
+
    // mean:
    BOOST_CHECK_CLOSE(
       mean(dist)


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk