2
0
mirror of https://github.com/boostorg/math.git synced 2026-02-26 16:52:27 +00:00

Improve erf/expm1/expint coverage.

In the expm1 case, tighten up error handling and testing.
This commit is contained in:
jzmaddock
2024-03-06 18:47:48 +00:00
parent 7fa77fcac6
commit 9ca40b9f01
6 changed files with 129 additions and 135 deletions

View File

@@ -89,5 +89,9 @@ void test(T, const char* type_name)
#endif
#endif
}
if (std::numeric_limits<T>::has_quiet_NaN)
{
BOOST_MATH_CHECK_THROW(boost::math::expm1(std::numeric_limits<T>::quiet_NaN()), std::domain_error);
}
}

View File

@@ -79,7 +79,7 @@ void expected_results()
"float|double|long double", // test type(s)
".*Ei.*", // test data group
".*", 6, 3); // test function
if(std::numeric_limits<long double>::digits > 100)
BOOST_IF_CONSTEXPR (std::numeric_limits<long double>::digits > 100)
{
add_expected_result(
".*", // compiler

View File

@@ -190,5 +190,27 @@ void test_spots(T, const char* t)
BOOST_CHECK_CLOSE(::boost::math::expint(static_cast<T>(-0.5)), static_cast<T>(-0.559773594776160811746795939315085235226846890316353515248293L), tolerance);
BOOST_CHECK_CLOSE(::boost::math::expint(static_cast<T>(-1)), static_cast<T>(-0.219383934395520273677163775460121649031047293406908207577979L), tolerance);
BOOST_CHECK_CLOSE(::boost::math::expint(static_cast<T>(-50.5)), static_cast<T>(-2.27237132932219350440719707268817831250090574830769670186618e-24L), tolerance);
//
// Extra coverage cases:
//
BOOST_CHECK_EQUAL(boost::math::expint(-boost::math::tools::max_value<T>()), T(0));
BOOST_CHECK_THROW(boost::math::expint(1, T(-1)), std::domain_error);
BOOST_CHECK_THROW(boost::math::expint(2, T(-1)), std::domain_error);
BOOST_CHECK_EQUAL(boost::math::expint(2, T(0)), T(1));
BOOST_CHECK_EQUAL(boost::math::expint(3, T(0)), T(0.5));
BOOST_IF_CONSTEXPR(std::numeric_limits<T>::has_infinity)
{
BOOST_CHECK_EQUAL(boost::math::expint(1, T(0)), std::numeric_limits<T>::infinity());
BOOST_CHECK_EQUAL(boost::math::expint(T(0)), -std::numeric_limits<T>::infinity());
BOOST_CHECK_EQUAL(boost::math::expint(boost::math::tools::log_max_value<T>() * 2), std::numeric_limits<T>::infinity());
BOOST_CHECK_EQUAL(boost::math::expint(boost::math::tools::log_max_value<T>() + T(38)), std::numeric_limits<T>::infinity());
}
else
{
BOOST_CHECK_GE(boost::math::expint(1, T(0)), boost::math::tools::max_value<T>());
BOOST_CHECK_LE(boost::math::expint(T(0)), -boost::math::tools::max_value<T>());
BOOST_CHECK_GE(boost::math::expint(boost::math::tools::log_max_value<T>() * 2), boost::math::tools::max_value<T>());
BOOST_CHECK_GE(boost::math::expint(boost::math::tools::log_max_value<T>() + T(38)), boost::math::tools::max_value<T>());
}
}