File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import boost.safe_numbers;
2727#endif
2828
2929#include < cmath>
30+ #include < exception>
3031#include < limits>
3132#include < stdexcept>
3233
@@ -50,14 +51,18 @@ void test_finite()
5051 BOOST_TEST (tgamma (T{static_cast <basis_type>(0.5 )}) == T{std::tgamma (static_cast <basis_type>(0.5 ))});
5152}
5253
53- // tgamma at a negative integer produces NAN -> domain_error
54+ // tgamma at a negative integer is a pole. Most standard libraries report it as a
55+ // NAN (so it surfaces as std::domain_error), but newlib/Cygwin returns an infinity
56+ // (so it surfaces as std::overflow_error or std::underflow_error). The portable
57+ // invariant is only that the non-finite result is rejected, so accept any of them
58+ // via their common base std::exception.
5459template <typename T>
5560void test_domain ()
5661{
5762 using basis_type = typename T::basis_type;
5863
59- BOOST_TEST_THROWS (tgamma (T{static_cast <basis_type>(-1.0 )}), std::domain_error );
60- BOOST_TEST_THROWS (tgamma (T{static_cast <basis_type>(-2.0 )}), std::domain_error );
64+ BOOST_TEST_THROWS (tgamma (T{static_cast <basis_type>(-1.0 )}), std::exception );
65+ BOOST_TEST_THROWS (tgamma (T{static_cast <basis_type>(-2.0 )}), std::exception );
6166}
6267
6368// tgamma(0) and lgamma(0) are poles producing +inf -> overflow_error.
You can’t perform that action at this time.
0 commit comments