Boost logo

Boost-Commit :

From: bruno.lalande_at_[hidden]
Date: 2008-06-06 18:33:40


Author: bruno.lalande
Date: 2008-06-06 18:33:39 EDT (Fri, 06 Jun 2008)
New Revision: 46205
URL: http://svn.boost.org/trac/boost/changeset/46205

Log:
Completed policies and error handling test cases.
Sanitized floating point test values in pow tests.
Text files modified:
   sandbox/math_toolkit/boost/math/policies/policy.hpp | 7 +++++++
   sandbox/math_toolkit/libs/math/test/pow_test.cpp | 8 ++++----
   sandbox/math_toolkit/libs/math/test/test_error_handling.cpp | 28 ++++++++++++++++++++++++++--
   sandbox/math_toolkit/libs/math/test/test_policy_2.cpp | 11 ++++++-----
   4 files changed, 43 insertions(+), 11 deletions(-)

Modified: sandbox/math_toolkit/boost/math/policies/policy.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/policies/policy.hpp (original)
+++ sandbox/math_toolkit/boost/math/policies/policy.hpp 2008-06-06 18:33:39 EDT (Fri, 06 Jun 2008)
@@ -676,6 +676,13 @@
    return result_type();
 }
 
+template <class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11>
+inline typename normalise<policy<>, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>::type make_policy(const A1&, const A2&, const A3&, const A4&, const A5&, const A6&, const A7&, const A8&, const A9&, const A10&, const A11&)
+{
+ typedef typename normalise<policy<>, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11>::type result_type;
+ return result_type();
+}
+
 //
 // Traits class to handle internal promotion:
 //

Modified: sandbox/math_toolkit/libs/math/test/pow_test.cpp
==============================================================================
--- sandbox/math_toolkit/libs/math/test/pow_test.cpp (original)
+++ sandbox/math_toolkit/libs/math/test/pow_test.cpp 2008-06-06 18:33:39 EDT (Fri, 06 Jun 2008)
@@ -115,13 +115,13 @@
 namespace boost { namespace math { namespace policies {
 template <class T>
 T user_overflow_error(const char*, const char*, const T&)
-{ return T(123.456); }
+{ return T(123.45); }
 }}}
 
 namespace boost { namespace math { namespace policies {
 template <class T>
 T user_undeterminate_result_error(const char*, const char*, const T&)
-{ return T(456.789); }
+{ return T(456.78); }
 }}}
 
 
@@ -133,13 +133,13 @@
                     0.0,
                     policy< ::boost::math::policies::overflow_error<user_error> >()
                 )
- == 123.456);
+ == 123.45);
 
     BOOST_CHECK(pow<0>(
                     0.0,
                     policy< ::boost::math::policies::undeterminate_result_error<user_error> >()
                 )
- == 456.789);
+ == 456.78);
 }
 
 int test_main(int, char* [])

Modified: sandbox/math_toolkit/libs/math/test/test_error_handling.cpp
==============================================================================
--- sandbox/math_toolkit/libs/math/test/test_error_handling.cpp (original)
+++ sandbox/math_toolkit/libs/math/test/test_error_handling.cpp 2008-06-06 18:33:39 EDT (Fri, 06 Jun 2008)
@@ -143,12 +143,36 @@
    BOOST_CHECK_THROW(boost::math::policies::raise_undeterminate_result_error(func, msg1, T(0.0), T(0.0), user_policy), user_defined_error);
 
    // Test with ignore_error
- BOOST_CHECK(boost::math::policies::raise_undeterminate_result_error(func, 0, T(0.0), T(12.34), ignore_policy) == T(12.34));
+ //BOOST_CHECK(boost::math::isnan(boost::math::policies::raise_domain_error(func, msg1, T(0.0), ignore_policy)));
+ //BOOST_CHECK(boost::math::isnan(boost::math::policies::raise_pole_error(func, msg1, T(0.0), ignore_policy)));
+ BOOST_CHECK_EQUAL(boost::math::policies::raise_overflow_error<T>(func, msg2, ignore_policy), std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : boost::math::tools::max_value<T>());
+ BOOST_CHECK_EQUAL(boost::math::policies::raise_underflow_error<T>(func, msg2, ignore_policy), T(0));
+ BOOST_CHECK_EQUAL(boost::math::policies::raise_denorm_error<T>(func, msg2, T(1.25), ignore_policy), T(1.25));
+ //BOOST_CHECK_EQUAL(boost::math::policies::raise_evaluation_error(func, msg1, T(0.0), ignore_policy), std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : boost::math::tools::max_value<T>());
+ BOOST_CHECK_EQUAL(boost::math::policies::raise_undeterminate_result_error(func, 0, T(0.0), T(12.34), ignore_policy), T(12.34));
 
    // Test with errno_on_error
+ //errno = 0;
+ //BOOST_CHECK(boost::math::isnan(boost::math::policies::raise_domain_error(func, msg1, T(0.0), errno_policy)));
+ //BOOST_CHECK(errno == EDOM);
+ //errno = 0;
+ //BOOST_CHECK(boost::math::isnan(boost::math::policies::raise_pole_error(func, msg1, T(0.0), errno_policy)));
+ //BOOST_CHECK(errno == EDOM);
+ errno = 0;
+ BOOST_CHECK_EQUAL(boost::math::policies::raise_overflow_error<T>(func, msg2, errno_policy), std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : boost::math::tools::max_value<T>());
+ BOOST_CHECK_EQUAL(errno, ERANGE);
+ errno = 0;
+ BOOST_CHECK_EQUAL(boost::math::policies::raise_underflow_error<T>(func, msg2, errno_policy), T(0));
+ BOOST_CHECK_EQUAL(errno, ERANGE);
+ errno = 0;
+ BOOST_CHECK_EQUAL(boost::math::policies::raise_denorm_error<T>(func, msg2, T(1.25), errno_policy), T(1.25));
+ BOOST_CHECK_EQUAL(errno, ERANGE);
+ //errno = 0;
+ //BOOST_CHECK_EQUAL(boost::math::policies::raise_evaluation_error(func, msg1, T(0.0), errno_policy), std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : boost::math::tools::max_value<T>());
+ //BOOST_CHECK(errno == EDOM);
    errno = 0;
    BOOST_CHECK(boost::math::policies::raise_undeterminate_result_error(func, 0, T(0.0), T(12.34), errno_policy) == T(12.34));
- BOOST_CHECK(errno == EDOM);
+ BOOST_CHECK_EQUAL(errno, EDOM);
 }
 
 int test_main(int, char* [])

Modified: sandbox/math_toolkit/libs/math/test/test_policy_2.cpp
==============================================================================
--- sandbox/math_toolkit/libs/math/test/test_policy_2.cpp (original)
+++ sandbox/math_toolkit/libs/math/test/test_policy_2.cpp 2008-06-06 18:33:39 EDT (Fri, 06 Jun 2008)
@@ -101,12 +101,13 @@
    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>(), 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>, 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>(), 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>, 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>(), 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>, digits2<10>, promote_float<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>(), undeterminate_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>, undeterminate_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>(), undeterminate_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>, undeterminate_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>(), undeterminate_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>, undeterminate_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>(), undeterminate_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>, undeterminate_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>(), 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>, 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>(), 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>, digits2<10>, promote_float<false>, promote_double<false>, discrete_quantile<integer_round_down> >()));
+ 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>(), undeterminate_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>, undeterminate_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>(), undeterminate_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>, undeterminate_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* [])


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