From 585d317947455f06aa951e5d8f8fc626d2fc6b39 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Wed, 18 Feb 2026 16:35:23 +0000 Subject: [PATCH] NC T finders: Improve code coverage. --- include/boost/math/distributions/non_central_t.hpp | 2 +- test/test_nc_t.hpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/boost/math/distributions/non_central_t.hpp b/include/boost/math/distributions/non_central_t.hpp index c0c898387..9bc1cf8cc 100644 --- a/include/boost/math/distributions/non_central_t.hpp +++ b/include/boost/math/distributions/non_central_t.hpp @@ -751,7 +751,7 @@ namespace boost // // Can't find a thing if one of p and q is zero: // - return policies::raise_evaluation_error(function, "Can't find degrees of freedom when the probability is 0 or 1, only possible answer is %1%", // LCOV_EXCL_LINE + return policies::raise_evaluation_error(function, "Can't find degrees of freedom when the probability is 0 or 1, only possible answer is %1%", RealType(std::numeric_limits::quiet_NaN()), Policy()); // LCOV_EXCL_LINE } if (fabs(x) < tools::epsilon()) diff --git a/test/test_nc_t.hpp b/test/test_nc_t.hpp index 58a48511d..83dbf12c9 100644 --- a/test/test_nc_t.hpp +++ b/test/test_nc_t.hpp @@ -541,6 +541,13 @@ void quantile_sanity_check(T& data, const char* type_name, const char* test) { BOOST_ERROR(e.what()); } + // Code coverage: + BOOST_CHECK_THROW(boost::math::non_central_t_distribution::find_degrees_of_freedom(data[i][1], boost::math::tools::epsilon() / 2, data[i][3]), boost::math::evaluation_error); + BOOST_CHECK_THROW(boost::math::non_central_t_distribution::find_degrees_of_freedom(boost::math::complement(data[i][1], boost::math::tools::epsilon() / 2, data[i][3])), boost::math::evaluation_error); + BOOST_CHECK_THROW(boost::math::non_central_t_distribution::find_degrees_of_freedom(data[i][1], data[i][2], value_type(0)), boost::math::evaluation_error); + BOOST_CHECK_THROW(boost::math::non_central_t_distribution::find_degrees_of_freedom(boost::math::complement(data[i][1], data[i][2], value_type(0))), boost::math::evaluation_error); + BOOST_CHECK_THROW(boost::math::non_central_t_distribution::find_degrees_of_freedom(data[i][1], data[i][2], value_type(1)), boost::math::evaluation_error); + BOOST_CHECK_THROW(boost::math::non_central_t_distribution::find_degrees_of_freedom(boost::math::complement(data[i][1], data[i][2], value_type(1))), boost::math::evaluation_error); } } #endif