From ca990cd130aac89239b435c9548e31fb8db93a29 Mon Sep 17 00:00:00 2001 From: Shen-Ta Hsieh Date: Thu, 1 Oct 2026 12:19:39 +0800 Subject: [PATCH] Lower the cos test tolerance and fix the asin test seed The random cos test now uses 16 float eps, the same as the sin test in #1479. Over 200000 random points the largest cos error is 5 eps. The asin edge test now seeds its generator with a fixed value instead of the clock, so a failure is reproducible. --- test/test_asin.cpp | 28 +--------------------------- test/test_sin_cos.cpp | 2 +- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/test/test_asin.cpp b/test/test_asin.cpp index 9d4fe0cc5..d5d372029 100644 --- a/test/test_asin.cpp +++ b/test/test_asin.cpp @@ -32,7 +32,6 @@ #include #include -#include #include #include @@ -49,28 +48,6 @@ using namespace boost::decimal; template auto my_zero() -> T; template auto my_one () -> T; -namespace local -{ - template - auto time_point() noexcept -> IntegralTimePointType - { - using local_integral_time_point_type = IntegralTimePointType; - using local_clock_type = ClockType; - - const auto current_now = - static_cast - ( - std::chrono::duration_cast - ( - local_clock_type::now().time_since_epoch() - ).count() - ); - - return static_cast(current_now); - } -} // namespace local - template void test_asin() { @@ -203,10 +180,7 @@ auto test_asin_edge() -> void using namespace boost::decimal::literals; const T half_pi { static_cast(1.570796326794896619231321691639751_DL) }; - std::random_device rd; - std::mt19937_64 gen(rd()); - - gen.seed(local::time_point()); + std::mt19937_64 gen(42); auto dis = std::uniform_real_distribution diff --git a/test/test_sin_cos.cpp b/test/test_sin_cos.cpp index 2e56f65fa..fc70281c9 100644 --- a/test/test_sin_cos.cpp +++ b/test/test_sin_cos.cpp @@ -107,7 +107,7 @@ auto test_cos() -> void auto ret_val {std::cos(val1)}; auto ret_dec {static_cast(cos(d1))}; - if (!BOOST_TEST(std::fabs(ret_val - ret_dec) < 35*std::numeric_limits::epsilon())) + if (!BOOST_TEST(std::fabs(ret_val - ret_dec) < 16*std::numeric_limits::epsilon())) { // LCOV_EXCL_START std::cerr << "Val 1: " << val1