From bf1404a2dfd793917446956c1fcf94cfe2134b7f Mon Sep 17 00:00:00 2001 From: John Maddock Date: Fri, 9 Nov 2007 11:01:45 +0000 Subject: [PATCH] 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. [SVN r40963] --- test/test_ibeta_inv.cpp | 13 +++++++++++++ test/test_igamma_inv.cpp | 25 +++++++++++++++++++------ test/test_igamma_inva.cpp | 23 ++++++++++++++++++----- 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/test/test_ibeta_inv.cpp b/test/test_ibeta_inv.cpp index 51b939170..fc6ab19c6 100644 --- a/test/test_ibeta_inv.cpp +++ b/test/test_ibeta_inv.cpp @@ -143,6 +143,19 @@ void expected_results() ".*", // test data group ".*", 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: // diff --git a/test/test_igamma_inv.cpp b/test/test_igamma_inv.cpp index 652fb0743..bafe585a5 100644 --- a/test/test_igamma_inv.cpp +++ b/test/test_igamma_inv.cpp @@ -185,6 +185,19 @@ void expected_results() << 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 void do_test_gamma_2(const T& data, const char* type_name, const char* test_name) { @@ -227,7 +240,7 @@ void do_test_gamma_2(const T& data, const char* type_name, const char* test_name && (fabs(data[i][5]) > 2 * boost::math::tools::min_value())) { 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()); @@ -236,24 +249,24 @@ void do_test_gamma_2(const T& data, const char* type_name, const char* test_name // 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()); - else if((1 - data[i][3] > 0.001) && (fabs(data[i][3]) >= boost::math::tools::min_value())) + else if((1 - data[i][3] > 0.001) && (fabs(data[i][3]) > 2 * boost::math::tools::min_value())) { 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()) { // 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; diff --git a/test/test_igamma_inva.cpp b/test/test_igamma_inva.cpp index 2859bb881..651932f21 100644 --- a/test/test_igamma_inva.cpp +++ b/test/test_igamma_inva.cpp @@ -111,6 +111,19 @@ void expected_results() << 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 void do_test_gamma_2(const T& data, const char* type_name, const char* test_name) { @@ -151,7 +164,7 @@ void do_test_gamma_2(const T& data, const char* type_name, const char* test_name else if((1 - data[i][5] > 0.001) && (fabs(data[i][5]) >= boost::math::tools::min_value())) { 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()); @@ -160,7 +173,7 @@ void do_test_gamma_2(const T& data, const char* type_name, const char* test_name // 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 @@ void do_test_gamma_2(const T& data, const char* type_name, const char* test_name && (fabs(data[i][3]) > 2 * boost::math::tools::min_value())) { 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()); - else + else if(data[i][3] > 2 * boost::math::tools::min_value()) { // 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;