Boost logo

Boost-Commit :

From: john_at_[hidden]
Date: 2007-11-09 06:01:47


Author: johnmaddock
Date: 2007-11-09 06:01:45 EST (Fri, 09 Nov 2007)
New Revision: 40963
URL: http://svn.boost.org/trac/boost/changeset/40963

Log:
Improved error messages and added tentative fixes for HP Tru64: the compiler appears to store constants that should underflow to zero as a small non-zero values which messes up the logic used in the test cases.
Text files modified:
   trunk/libs/math/test/test_ibeta_inv.cpp | 13 +++++++++++++
   trunk/libs/math/test/test_igamma_inv.cpp | 25 +++++++++++++++++++------
   trunk/libs/math/test/test_igamma_inva.cpp | 23 ++++++++++++++++++-----
   3 files changed, 50 insertions(+), 11 deletions(-)

Modified: trunk/libs/math/test/test_ibeta_inv.cpp
==============================================================================
--- trunk/libs/math/test/test_ibeta_inv.cpp (original)
+++ trunk/libs/math/test/test_ibeta_inv.cpp 2007-11-09 06:01:45 EST (Fri, 09 Nov 2007)
@@ -144,6 +144,19 @@
       ".*", 200000, 100000); // test function
 
    //
+ // HP Tru64:
+ // Extended exponent range of long double
+ // causes more extreme test cases to be executed:
+ //
+ add_expected_result(
+ "HP Tru64.*", // compiler
+ ".*", // stdlib
+ ".*", // platform
+ "long double", // test type(s)
+ ".*", // test data group
+ ".*", 200000, 100000); // test function
+
+ //
    // Catch all cases come last:
    //
    add_expected_result(

Modified: trunk/libs/math/test/test_igamma_inv.cpp
==============================================================================
--- trunk/libs/math/test/test_igamma_inv.cpp (original)
+++ trunk/libs/math/test/test_igamma_inv.cpp 2007-11-09 06:01:45 EST (Fri, 09 Nov 2007)
@@ -185,6 +185,19 @@
       << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
 }
 
+#define BOOST_CHECK_CLOSE_EX(a, b, prec, i) \
+ {\
+ unsigned int failures = boost::unit_test::results_collector.results( boost::unit_test::framework::current_test_case().p_id ).p_assertions_failed;\
+ BOOST_CHECK_CLOSE(a, b, prec); \
+ if(failures != boost::unit_test::results_collector.results( boost::unit_test::framework::current_test_case().p_id ).p_assertions_failed)\
+ {\
+ std::cerr << "Failure was at row " << i << std::endl;\
+ std::cerr << std::setprecision(35); \
+ std::cerr << "{ " << data[i][0] << " , " << data[i][1] << " , " << data[i][2];\
+ std::cerr << " , " << data[i][3] << " , " << data[i][4] << " , " << data[i][5] << " } " << std::endl;\
+ }\
+ }
+
 template <class T>
 void do_test_gamma_2(const T& data, const char* type_name, const char* test_name)
 {
@@ -227,7 +240,7 @@
          && (fabs(data[i][5]) > 2 * boost::math::tools::min_value<double>()))
       {
          value_type inv = boost::math::gamma_p_inv(data[i][0], data[i][5]);
- BOOST_CHECK_CLOSE(data[i][1], inv, precision);
+ BOOST_CHECK_CLOSE_EX(data[i][1], inv, precision, i);
       }
       else if(1 == data[i][5])
          BOOST_CHECK_EQUAL(boost::math::gamma_p_inv(data[i][0], data[i][5]), boost::math::tools::max_value<value_type>());
@@ -236,24 +249,24 @@
          // not enough bits in our input to get back to x, but we should be in
          // the same ball park:
          value_type inv = boost::math::gamma_p_inv(data[i][0], data[i][5]);
- BOOST_CHECK_CLOSE(data[i][1], inv, 100000);
+ BOOST_CHECK_CLOSE_EX(data[i][1], inv, 100000, i);
       }
 
       if(data[i][3] == 0)
          BOOST_CHECK_EQUAL(boost::math::gamma_q_inv(data[i][0], data[i][3]), boost::math::tools::max_value<value_type>());
- else if((1 - data[i][3] > 0.001) && (fabs(data[i][3]) >= boost::math::tools::min_value<value_type>()))
+ else if((1 - data[i][3] > 0.001) && (fabs(data[i][3]) > 2 * boost::math::tools::min_value<value_type>()))
       {
          value_type inv = boost::math::gamma_q_inv(data[i][0], data[i][3]);
- BOOST_CHECK_CLOSE(data[i][1], inv, precision);
+ BOOST_CHECK_CLOSE_EX(data[i][1], inv, precision, i);
       }
       else if(1 == data[i][3])
          BOOST_CHECK_EQUAL(boost::math::gamma_q_inv(data[i][0], data[i][3]), value_type(0));
- else
+ else if(fabs(data[i][3]) > 2 * boost::math::tools::min_value<value_type>())
       {
          // not enough bits in our input to get back to x, but we should be in
          // the same ball park:
          value_type inv = boost::math::gamma_q_inv(data[i][0], data[i][3]);
- BOOST_CHECK_CLOSE(data[i][1], inv, 100);
+ BOOST_CHECK_CLOSE_EX(data[i][1], inv, 100, i);
       }
    }
    std::cout << std::endl;

Modified: trunk/libs/math/test/test_igamma_inva.cpp
==============================================================================
--- trunk/libs/math/test/test_igamma_inva.cpp (original)
+++ trunk/libs/math/test/test_igamma_inva.cpp 2007-11-09 06:01:45 EST (Fri, 09 Nov 2007)
@@ -111,6 +111,19 @@
       << BOOST_STDLIB << ", " << BOOST_PLATFORM << std::endl;
 }
 
+#define BOOST_CHECK_CLOSE_EX(a, b, prec, i) \
+ {\
+ unsigned int failures = boost::unit_test::results_collector.results( boost::unit_test::framework::current_test_case().p_id ).p_assertions_failed;\
+ BOOST_CHECK_CLOSE(a, b, prec); \
+ if(failures != boost::unit_test::results_collector.results( boost::unit_test::framework::current_test_case().p_id ).p_assertions_failed)\
+ {\
+ std::cerr << "Failure was at row " << i << std::endl;\
+ std::cerr << std::setprecision(35); \
+ std::cerr << "{ " << data[i][0] << " , " << data[i][1] << " , " << data[i][2];\
+ std::cerr << " , " << data[i][3] << " , " << data[i][4] << " , " << data[i][5] << " } " << std::endl;\
+ }\
+ }
+
 template <class T>
 void do_test_gamma_2(const T& data, const char* type_name, const char* test_name)
 {
@@ -151,7 +164,7 @@
       else if((1 - data[i][5] > 0.001) && (fabs(data[i][5]) >= boost::math::tools::min_value<value_type>()))
       {
          value_type inv = boost::math::gamma_p_inva(data[i][1], data[i][5]);
- BOOST_CHECK_CLOSE(data[i][0], inv, precision);
+ BOOST_CHECK_CLOSE_EX(data[i][0], inv, precision, i);
       }
       else if(1 == data[i][5])
          BOOST_CHECK_EQUAL(boost::math::gamma_p_inva(data[i][1], data[i][5]), boost::math::tools::min_value<value_type>());
@@ -160,7 +173,7 @@
          // not enough bits in our input to get back to x, but we should be in
          // the same ball park:
          value_type inv = boost::math::gamma_p_inva(data[i][1], data[i][5]);
- BOOST_CHECK_CLOSE(data[i][0], inv, 100);
+ BOOST_CHECK_CLOSE_EX(data[i][0], inv, 100, i);
       }
 
       if(data[i][3] == 0)
@@ -170,16 +183,16 @@
          && (fabs(data[i][3]) > 2 * boost::math::tools::min_value<double>()))
       {
          value_type inv = boost::math::gamma_q_inva(data[i][1], data[i][3]);
- BOOST_CHECK_CLOSE(data[i][0], inv, precision);
+ BOOST_CHECK_CLOSE_EX(data[i][0], inv, precision, i);
       }
       else if(1 == data[i][3])
          BOOST_CHECK_EQUAL(boost::math::gamma_q_inva(data[i][1], data[i][3]), boost::math::tools::max_value<value_type>());
- else
+ else if(data[i][3] > 2 * boost::math::tools::min_value<value_type>())
       {
          // not enough bits in our input to get back to x, but we should be in
          // the same ball park:
          value_type inv = boost::math::gamma_q_inva(data[i][1], data[i][3]);
- BOOST_CHECK_CLOSE(data[i][0], inv, 100);
+ BOOST_CHECK_CLOSE_EX(data[i][0], inv, 100, i);
       }
    }
    std::cout << std::endl;


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