Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52447 - trunk/libs/math/test
From: john_at_[hidden]
Date: 2009-04-17 13:18:32


Author: johnmaddock
Date: 2009-04-17 13:18:31 EDT (Fri, 17 Apr 2009)
New Revision: 52447
URL: http://svn.boost.org/trac/boost/changeset/52447

Log:
Split test/test_policy_7.cpp into two tests.
Add some macro-expansion-suppression code to test_sign.cpp.
Added:
   trunk/libs/math/test/test_policy_8.cpp (contents, props changed)
Text files modified:
   trunk/libs/math/test/Jamfile.v2 | 1
   trunk/libs/math/test/test_policy_7.cpp | 15 --------
   trunk/libs/math/test/test_sign.cpp | 72 ++++++++++++++++++++--------------------
   3 files changed, 37 insertions(+), 51 deletions(-)

Modified: trunk/libs/math/test/Jamfile.v2
==============================================================================
--- trunk/libs/math/test/Jamfile.v2 (original)
+++ trunk/libs/math/test/Jamfile.v2 2009-04-17 13:18:31 EDT (Fri, 17 Apr 2009)
@@ -618,6 +618,7 @@
 run test_policy_5.cpp ../../test/build//boost_test_exec_monitor ;
 run test_policy_6.cpp ../../test/build//boost_test_exec_monitor ;
 run test_policy_7.cpp ../../test/build//boost_test_exec_monitor ;
+run test_policy_8.cpp ../../test/build//boost_test_exec_monitor ;
 run test_policy_sf.cpp ../../test/build//boost_test_exec_monitor ;
 
 run test_tr1.cpp

Modified: trunk/libs/math/test/test_policy_7.cpp
==============================================================================
--- trunk/libs/math/test/test_policy_7.cpp (original)
+++ trunk/libs/math/test/test_policy_7.cpp 2009-04-17 13:18:31 EDT (Fri, 17 Apr 2009)
@@ -36,21 +36,6 @@
    BOOST_CHECK(check_same(make_policy(pole_error<ignore_error>()), normalise<policy<pole_error<ignore_error> > >::type()));
    BOOST_CHECK(check_same(make_policy(indeterminate_result_error<ignore_error>()), normalise<policy<indeterminate_result_error<ignore_error> > >::type()));
 
- BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>()), policy<domain_error<ignore_error> >()));
- BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>()), policy<domain_error<ignore_error>, pole_error<ignore_error> >()));
- BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error> >()));
- BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error> >()));
- BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error> >()));
- BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error> >()));
- BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>(), indeterminate_result_error<throw_on_error>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error>, indeterminate_result_error<throw_on_error> >()));
- BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>(), indeterminate_result_error<throw_on_error>(), digits2<10>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error>, indeterminate_result_error<throw_on_error>, digits2<10> >()));
- BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>(), indeterminate_result_error<throw_on_error>(), digits10<5>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error>, indeterminate_result_error<throw_on_error>, digits2<19> >()));
- BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>(), indeterminate_result_error<throw_on_error>(), digits2<10>(), promote_float<false>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error>, indeterminate_result_error<throw_on_error>, digits2<10>, promote_float<false> >()));
-#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
- BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>(), indeterminate_result_error<throw_on_error>(), digits2<10>(), promote_float<false>(), promote_double<false>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error>, indeterminate_result_error<throw_on_error>, digits2<10>, promote_float<false>, promote_double<false> >()));
- BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>(), indeterminate_result_error<throw_on_error>(), digits2<10>(), promote_float<false>(), promote_double<false>(), discrete_quantile<integer_round_down>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error>, indeterminate_result_error<throw_on_error>, digits2<10>, promote_float<false>, promote_double<false>, discrete_quantile<integer_round_down> >()));
-#endif
-
    return 0;
 } // int test_main(int, char* [])
 

Added: trunk/libs/math/test/test_policy_8.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/math/test/test_policy_8.cpp 2009-04-17 13:18:31 EDT (Fri, 17 Apr 2009)
@@ -0,0 +1,50 @@
+
+// Copyright John Maddock 2007.
+
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt
+// or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#include <boost/math/policies/policy.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/test/test_exec_monitor.hpp> // for test_main
+#include <iostream>
+
+template <class P1, class P2>
+bool check_same(const P1&, const P2&)
+{
+ if(!boost::is_same<P1, P2>::value)
+ {
+ std::cout << "P1 = " << typeid(P1).name() << std::endl;
+ std::cout << "P2 = " << typeid(P2).name() << std::endl;
+ }
+ return boost::is_same<P1, P2>::value;
+}
+
+
+int test_main(int, char* [])
+{
+ using namespace boost::math::policies;
+ using namespace boost;
+
+ BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>()), policy<domain_error<ignore_error> >()));
+ BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>()), policy<domain_error<ignore_error>, pole_error<ignore_error> >()));
+ BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error> >()));
+ BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error> >()));
+ BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error> >()));
+ BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error> >()));
+ BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>(), indeterminate_result_error<throw_on_error>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error>, indeterminate_result_error<throw_on_error> >()));
+ BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>(), indeterminate_result_error<throw_on_error>(), digits2<10>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error>, indeterminate_result_error<throw_on_error>, digits2<10> >()));
+ BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>(), indeterminate_result_error<throw_on_error>(), digits10<5>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error>, indeterminate_result_error<throw_on_error>, digits2<19> >()));
+ BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>(), indeterminate_result_error<throw_on_error>(), digits2<10>(), promote_float<false>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error>, indeterminate_result_error<throw_on_error>, digits2<10>, promote_float<false> >()));
+#ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
+ BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>(), indeterminate_result_error<throw_on_error>(), digits2<10>(), promote_float<false>(), promote_double<false>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error>, indeterminate_result_error<throw_on_error>, digits2<10>, promote_float<false>, promote_double<false> >()));
+ BOOST_CHECK(check_same(make_policy(domain_error<ignore_error>(), pole_error<ignore_error>(), overflow_error<ignore_error>(), underflow_error<throw_on_error>(), denorm_error<throw_on_error>(), evaluation_error<ignore_error>(), indeterminate_result_error<throw_on_error>(), digits2<10>(), promote_float<false>(), promote_double<false>(), discrete_quantile<integer_round_down>()), policy<domain_error<ignore_error>, pole_error<ignore_error>, overflow_error<ignore_error>, underflow_error<throw_on_error>, denorm_error<throw_on_error>, evaluation_error<ignore_error>, indeterminate_result_error<throw_on_error>, digits2<10>, promote_float<false>, promote_double<false>, discrete_quantile<integer_round_down> >()));
+#endif
+
+ return 0;
+} // int test_main(int, char* [])
+
+
+

Modified: trunk/libs/math/test/test_sign.cpp
==============================================================================
--- trunk/libs/math/test/test_sign.cpp (original)
+++ trunk/libs/math/test/test_sign.cpp 2009-04-17 13:18:31 EDT (Fri, 17 Apr 2009)
@@ -25,55 +25,55 @@
    RealType a = 0;
    RealType b = 1;
    RealType c = -1;
- BOOST_CHECK_EQUAL(boost::math::signbit(a), 0);
- BOOST_CHECK_EQUAL(boost::math::sign(a), 0);
- BOOST_CHECK_EQUAL(boost::math::copysign(b, a), RealType(1));
- BOOST_CHECK_EQUAL(boost::math::copysign(c, a), RealType(1));
+ BOOST_CHECK_EQUAL((boost::math::signbit)(a), 0);
+ BOOST_CHECK_EQUAL((boost::math::sign)(a), 0);
+ BOOST_CHECK_EQUAL((boost::math::copysign)(b, a), RealType(1));
+ BOOST_CHECK_EQUAL((boost::math::copysign)(c, a), RealType(1));
    a = 1;
- BOOST_CHECK_EQUAL(boost::math::signbit(a), 0);
- BOOST_CHECK_EQUAL(boost::math::sign(a), 1);
- BOOST_CHECK_EQUAL(boost::math::copysign(b, a), RealType(1));
- BOOST_CHECK_EQUAL(boost::math::copysign(c, a), RealType(1));
+ BOOST_CHECK_EQUAL((boost::math::signbit)(a), 0);
+ BOOST_CHECK_EQUAL((boost::math::sign)(a), 1);
+ BOOST_CHECK_EQUAL((boost::math::copysign)(b, a), RealType(1));
+ BOOST_CHECK_EQUAL((boost::math::copysign)(c, a), RealType(1));
    a = -1;
- BOOST_CHECK(boost::math::signbit(a) != 0);
- BOOST_CHECK_EQUAL(boost::math::sign(a), -1);
- BOOST_CHECK_EQUAL(boost::math::copysign(b, a), RealType(-1));
- BOOST_CHECK_EQUAL(boost::math::copysign(c, a), RealType(-1));
+ BOOST_CHECK((boost::math::signbit)(a) != 0);
+ BOOST_CHECK_EQUAL((boost::math::sign)(a), -1);
+ BOOST_CHECK_EQUAL((boost::math::copysign)(b, a), RealType(-1));
+ BOOST_CHECK_EQUAL((boost::math::copysign)(c, a), RealType(-1));
    a = boost::math::tools::max_value<RealType>();
- BOOST_CHECK_EQUAL(boost::math::signbit(a), 0);
- BOOST_CHECK_EQUAL(boost::math::sign(a), 1);
- BOOST_CHECK_EQUAL(boost::math::copysign(b, a), RealType(1));
- BOOST_CHECK_EQUAL(boost::math::copysign(c, a), RealType(1));
+ BOOST_CHECK_EQUAL((boost::math::signbit)(a), 0);
+ BOOST_CHECK_EQUAL((boost::math::sign)(a), 1);
+ BOOST_CHECK_EQUAL((boost::math::copysign)(b, a), RealType(1));
+ BOOST_CHECK_EQUAL((boost::math::copysign)(c, a), RealType(1));
    a = -boost::math::tools::max_value<RealType>();
- BOOST_CHECK(boost::math::signbit(a) != 0);
- BOOST_CHECK_EQUAL(boost::math::sign(a), -1);
- BOOST_CHECK_EQUAL(boost::math::copysign(b, a), RealType(-1));
- BOOST_CHECK_EQUAL(boost::math::copysign(c, a), RealType(-1));
+ BOOST_CHECK((boost::math::signbit)(a) != 0);
+ BOOST_CHECK_EQUAL((boost::math::sign)(a), -1);
+ BOOST_CHECK_EQUAL((boost::math::copysign)(b, a), RealType(-1));
+ BOOST_CHECK_EQUAL((boost::math::copysign)(c, a), RealType(-1));
    if(std::numeric_limits<RealType>::has_infinity)
    {
       a = std::numeric_limits<RealType>::infinity();
- BOOST_CHECK_EQUAL(boost::math::signbit(a), 0);
- BOOST_CHECK_EQUAL(boost::math::sign(a), 1);
- BOOST_CHECK_EQUAL(boost::math::copysign(b, a), RealType(1));
- BOOST_CHECK_EQUAL(boost::math::copysign(c, a), RealType(1));
+ BOOST_CHECK_EQUAL((boost::math::signbit)(a), 0);
+ BOOST_CHECK_EQUAL((boost::math::sign)(a), 1);
+ BOOST_CHECK_EQUAL((boost::math::copysign)(b, a), RealType(1));
+ BOOST_CHECK_EQUAL((boost::math::copysign)(c, a), RealType(1));
       a = -std::numeric_limits<RealType>::infinity();
- BOOST_CHECK(boost::math::signbit(a) != 0);
- BOOST_CHECK_EQUAL(boost::math::sign(a), -1);
- BOOST_CHECK_EQUAL(boost::math::copysign(b, a), RealType(-1));
- BOOST_CHECK_EQUAL(boost::math::copysign(c, a), RealType(-1));
+ BOOST_CHECK((boost::math::signbit)(a) != 0);
+ BOOST_CHECK_EQUAL((boost::math::sign)(a), -1);
+ BOOST_CHECK_EQUAL((boost::math::copysign)(b, a), RealType(-1));
+ BOOST_CHECK_EQUAL((boost::math::copysign)(c, a), RealType(-1));
    }
    if(std::numeric_limits<RealType>::has_quiet_NaN)
    {
       a = std::numeric_limits<RealType>::quiet_NaN();
- BOOST_CHECK_EQUAL(boost::math::signbit(a), 0);
- BOOST_CHECK_EQUAL(boost::math::sign(a), 1);
- BOOST_CHECK_EQUAL(boost::math::copysign(b, a), RealType(1));
- BOOST_CHECK_EQUAL(boost::math::copysign(c, a), RealType(1));
+ BOOST_CHECK_EQUAL((boost::math::signbit)(a), 0);
+ BOOST_CHECK_EQUAL((boost::math::sign)(a), 1);
+ BOOST_CHECK_EQUAL((boost::math::copysign)(b, a), RealType(1));
+ BOOST_CHECK_EQUAL((boost::math::copysign)(c, a), RealType(1));
       a = -std::numeric_limits<RealType>::quiet_NaN();
- BOOST_CHECK(boost::math::signbit(a) != 0);
- BOOST_CHECK_EQUAL(boost::math::sign(a), -1);
- BOOST_CHECK_EQUAL(boost::math::copysign(b, a), RealType(-1));
- BOOST_CHECK_EQUAL(boost::math::copysign(c, a), RealType(-1));
+ BOOST_CHECK((boost::math::signbit)(a) != 0);
+ BOOST_CHECK_EQUAL((boost::math::sign)(a), -1);
+ BOOST_CHECK_EQUAL((boost::math::copysign)(b, a), RealType(-1));
+ BOOST_CHECK_EQUAL((boost::math::copysign)(c, a), RealType(-1));
    }
 }
 


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