From 76c7151c092e4515dfecd4780dc766dc2f16cb4d Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Sun, 18 Jul 2021 20:54:59 +0300 Subject: [PATCH] More testing --- test/Jamfile.v2 | 2 +- test/sqrt_test.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index eb03ba381..11a025689 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -121,7 +121,7 @@ test-suite special_fun : [ run hypot_test.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework ] [ run pow_test.cpp ../../test/build//boost_unit_test_framework ] - [ run sqrt_test.cpp ../../test/build//boost_unit_test_framework ] + [ run sqrt_test.cpp ../../test/build//boost_unit_test_framework : : : [ requires cxx17_if_constexpr ] ] [ run isinf_test.cpp ../../test/build//boost_unit_test_framework ] [ run isnan_test.cpp ../../test/build//boost_unit_test_framework ] [ run log1p_expm1_test.cpp test_instances//test_instances pch_light ../../test/build//boost_unit_test_framework ] diff --git a/test/sqrt_test.cpp b/test/sqrt_test.cpp index 4e14dcf59..3c175ab36 100644 --- a/test/sqrt_test.cpp +++ b/test/sqrt_test.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -36,6 +37,19 @@ void test_float_sqrt() constexpr Real test_nan = boost::math::ccmath::sqrt(std::numeric_limits::quiet_NaN()); Real known_nan = std::sqrt(std::numeric_limits::quiet_NaN()); BOOST_TEST(std::isnan(test_nan) && std::isnan(known_nan)); + + // 100'000'000 + constexpr Real test_100m = boost::math::ccmath::sqrt(100000000); + BOOST_TEST_EQ(test_100m, Real(10000)); + + // MAX / 2 + // Only tests float since double and long double will exceed maximum template depth + if constexpr (std::is_same_v) + { + constexpr Real test_max = boost::math::ccmath::sqrt(std::numeric_limits::max() / 2); + Real known_max = std::sqrt(std::numeric_limits::max() / 2); + BOOST_TEST(abs(test_max - known_max) < tol); + } } template