From 67aa0c1444b589ca6d36953cf33e260e2dcd9dbf Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Tue, 30 Mar 2021 17:55:13 +0100 Subject: [PATCH] Deal with inspect issues in test/. --- test/CMakeLists.txt | 4 +++ test/compile_test/CMakeLists.txt | 4 +++ .../sf_jacobi_theta_incl_test.cpp | 7 ++++- test/cubic_hermite_test.cpp | 8 ++--- test/daubechies_scaling_test.cpp | 29 ++++++++++--------- test/daubechies_wavelet_test.cpp | 17 ++++++----- test/engel_expansion_test.cpp | 2 +- test/jacobi_theta_data.ipp | 7 +++++ test/jacobi_theta_small_tau.ipp | 7 +++++ test/ljung_box_test.cpp | 2 +- test/pchip_test.cpp | 5 ++-- test/quintic_hermite_test.cpp | 6 ++-- test/rsqrt_test.cpp | 4 +-- test/septic_hermite_test.cpp | 4 +-- test/tanh_sinh_mpfr.cpp | 2 +- test/test_fibonacci.cpp | 2 +- test/test_jacobi_theta.cpp | 6 ++++ test/test_jacobi_theta.hpp | 14 +++++---- test/tgamma_mp_data.hpp | 6 ++++ tools/jacobi_theta_data.cpp | 6 ++++ 20 files changed, 97 insertions(+), 45 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c18ae51e4..e63471c89 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1 +1,5 @@ +# Copyright 2021 Matt Borland +# Distributed under the Boost Software License, Version 1.0. +# https://www.boost.org/LICENSE_1_0.txt + add_subdirectory(compile_test) diff --git a/test/compile_test/CMakeLists.txt b/test/compile_test/CMakeLists.txt index fa4e8ba7e..0f06d81f1 100644 --- a/test/compile_test/CMakeLists.txt +++ b/test/compile_test/CMakeLists.txt @@ -1,3 +1,7 @@ +# Copyright 2021 Matt Borland +# Distributed under the Boost Software License, Version 1.0. +# https://www.boost.org/LICENSE_1_0.txt + file(GLOB SOURCES "*.cpp") add_library(compile_tests ${SOURCES}) target_compile_features(compile_tests PRIVATE cxx_std_17) diff --git a/test/compile_test/sf_jacobi_theta_incl_test.cpp b/test/compile_test/sf_jacobi_theta_incl_test.cpp index 119b03eaf..063ca1f3a 100644 --- a/test/compile_test/sf_jacobi_theta_incl_test.cpp +++ b/test/compile_test/sf_jacobi_theta_incl_test.cpp @@ -1,4 +1,9 @@ -// Basic sanity check that header +// Copyright Evan Miller 2020. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// Basic sanity check that header // #includes all the files that it needs to. // #include diff --git a/test/cubic_hermite_test.cpp b/test/cubic_hermite_test.cpp index d2ec7c614..a8ded3990 100644 --- a/test/cubic_hermite_test.cpp +++ b/test/cubic_hermite_test.cpp @@ -53,7 +53,7 @@ void test_constant() CHECK_ULP_CLOSE(Real(7), hermite_spline(thi), 2); CHECK_ULP_CLOSE(Real(0), hermite_spline.prime(tlo), 2); CHECK_ULP_CLOSE(Real(0), hermite_spline.prime(thi), 2); - tlo = boost::math::nextafter(tlo, std::numeric_limits::max()); + tlo = boost::math::nextafter(tlo, (std::numeric_limits::max)()); thi = boost::math::nextafter(thi, std::numeric_limits::lowest()); } @@ -262,7 +262,7 @@ void test_cardinal_constant() CHECK_ULP_CLOSE(Real(0), hermite_spline_aos.prime(tlo), 2); CHECK_ULP_CLOSE(Real(0), hermite_spline_aos.prime(thi), 2); - tlo = boost::math::nextafter(tlo, std::numeric_limits::max()); + tlo = boost::math::nextafter(tlo, (std::numeric_limits::max)()); thi = boost::math::nextafter(thi, std::numeric_limits::lowest()); } @@ -329,7 +329,7 @@ void test_cardinal_linear() CHECK_ULP_CLOSE(Real(1), hermite_spline_aos.prime(tlo), 2); CHECK_ULP_CLOSE(Real(1), hermite_spline_aos.prime(thi), 2); - tlo = boost::math::nextafter(tlo, std::numeric_limits::max()); + tlo = boost::math::nextafter(tlo, (std::numeric_limits::max)()); thi = boost::math::nextafter(thi, std::numeric_limits::lowest()); } @@ -387,7 +387,7 @@ void test_cardinal_quadratic() CHECK_ULP_CLOSE(Real(tlo), saos.prime(tlo), 3); CHECK_ULP_CLOSE(Real(thi), saos.prime(thi), 3); - tlo = boost::math::nextafter(tlo, std::numeric_limits::max()); + tlo = boost::math::nextafter(tlo, (std::numeric_limits::max)()); thi = boost::math::nextafter(thi, std::numeric_limits::lowest()); } } diff --git a/test/daubechies_scaling_test.cpp b/test/daubechies_scaling_test.cpp index 534977283..5b7b9922e 100644 --- a/test/daubechies_scaling_test.cpp +++ b/test/daubechies_scaling_test.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -244,7 +245,7 @@ void test_dyadic_grid() { auto phijk = boost::math::daubechies_scaling_dyadic_grid(0); auto phik = boost::math::detail::daubechies_scaling_integer_grid(); - assert(phik.size() == phijk.size()); + BOOST_ASSERT(phik.size() == phijk.size()); for (size_t k = 0; k < phik.size(); ++k) { @@ -353,15 +354,15 @@ void test_quadratures() CHECK_ULP_CLOSE(Real(0), phi(xlo), 0); CHECK_ULP_CLOSE(Real(0), phi(xhi), 0); xlo = std::nextafter(xlo, std::numeric_limits::lowest()); - xhi = std::nextafter(xhi, std::numeric_limits::max()); + xhi = std::nextafter(xhi, (std::numeric_limits::max)()); } xlo = a; xhi = b; for (int i = 0; i < samples; ++i) { - assert(abs(phi(xlo)) <= 5); - assert(abs(phi(xhi)) <= 5); - xlo = std::nextafter(xlo, std::numeric_limits::max()); + BOOST_ASSERT(abs(phi(xlo)) <= 5); + BOOST_ASSERT(abs(phi(xhi)) <= 5); + xlo = std::nextafter(xlo, (std::numeric_limits::max)()); xhi = std::nextafter(xhi, std::numeric_limits::lowest()); } @@ -392,7 +393,7 @@ void test_quadratures() } std::random_device rd; - Real t = static_cast(rd())/static_cast(rd.max()); + Real t = static_cast(rd())/static_cast((rd.max)()); Real S = phi(t); Real dS = phi.prime(t); while (t < b) @@ -425,23 +426,23 @@ void test_quadratures() CHECK_ULP_CLOSE(Real(0), phi(xlo), 0); CHECK_ULP_CLOSE(Real(0), phi(xhi), 0); if constexpr (p > 2) { - assert(abs(phi.prime(xlo)) <= 5); - assert(abs(phi.prime(xhi)) <= 5); + BOOST_ASSERT(abs(phi.prime(xlo)) <= 5); + BOOST_ASSERT(abs(phi.prime(xhi)) <= 5); if constexpr (p > 5) { - assert(abs(phi.double_prime(xlo)) <= 5); - assert(abs(phi.double_prime(xhi)) <= 5); + BOOST_ASSERT(abs(phi.double_prime(xlo)) <= 5); + BOOST_ASSERT(abs(phi.double_prime(xhi)) <= 5); } } xlo = std::nextafter(xlo, std::numeric_limits::lowest()); - xhi = std::nextafter(xhi, std::numeric_limits::max()); + xhi = std::nextafter(xhi, (std::numeric_limits::max)()); } xlo = a; xhi = b; for (int i = 0; i < samples; ++i) { - assert(abs(phi(xlo)) <= 5); - assert(abs(phi(xhi)) <= 5); - xlo = std::nextafter(xlo, std::numeric_limits::max()); + BOOST_ASSERT(abs(phi(xlo)) <= 5); + BOOST_ASSERT(abs(phi(xhi)) <= 5); + xlo = std::nextafter(xlo, (std::numeric_limits::max)()); xhi = std::nextafter(xhi, std::numeric_limits::lowest()); } } diff --git a/test/daubechies_wavelet_test.cpp b/test/daubechies_wavelet_test.cpp index 3059111b2..376b0fef9 100644 --- a/test/daubechies_wavelet_test.cpp +++ b/test/daubechies_wavelet_test.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -93,26 +94,26 @@ void test_quadratures() } } xlo = std::nextafter(xlo, std::numeric_limits::lowest()); - xhi = std::nextafter(xhi, std::numeric_limits::max()); + xhi = std::nextafter(xhi, (std::numeric_limits::max)()); } xlo = a; xhi = b; for (int i = 0; i < samples; ++i) { std::cout << std::setprecision(std::numeric_limits::max_digits10); - assert(abs(psi(xlo)) <= 5); - assert(abs(psi(xhi)) <= 5); + BOOST_ASSERT(abs(psi(xlo)) <= 5); + BOOST_ASSERT(abs(psi(xhi)) <= 5); if constexpr (p > 2) { - assert(abs(psi.prime(xlo)) <= 5); - assert(abs(psi.prime(xhi)) <= 5); + BOOST_ASSERT(abs(psi.prime(xlo)) <= 5); + BOOST_ASSERT(abs(psi.prime(xhi)) <= 5); if constexpr (p >= 6) { - assert(abs(psi.double_prime(xlo)) <= 5); - assert(abs(psi.double_prime(xhi)) <= 5); + BOOST_ASSERT(abs(psi.double_prime(xlo)) <= 5); + BOOST_ASSERT(abs(psi.double_prime(xhi)) <= 5); } } - xlo = std::nextafter(xlo, std::numeric_limits::max()); + xlo = std::nextafter(xlo, (std::numeric_limits::max)()); xhi = std::nextafter(xhi, std::numeric_limits::lowest()); } } diff --git a/test/engel_expansion_test.cpp b/test/engel_expansion_test.cpp index f9dc03c8f..6ad4d3305 100644 --- a/test/engel_expansion_test.cpp +++ b/test/engel_expansion_test.cpp @@ -56,7 +56,7 @@ void test_well_known() 21846713216,27803071890,31804388758,32651669133}; auto a = engel.digits(); // The last digit might be off somewhat, so don't test it: - size_t n = std::min(a.size() - 1, expected.size()); + size_t n = (std::min)(a.size() - 1, expected.size()); for(size_t i = 0; i < n; ++i) { if (!CHECK_EQUAL(expected[i], a[i])) diff --git a/test/jacobi_theta_data.ipp b/test/jacobi_theta_data.ipp index 65ee0b9a4..3f1c871ce 100644 --- a/test/jacobi_theta_data.ipp +++ b/test/jacobi_theta_data.ipp @@ -1,3 +1,10 @@ +/* + * Copyright Evan Miller, 2020 + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + #ifndef SC_ # define SC_(x) static_cast(BOOST_JOIN(x, L)) #endif diff --git a/test/jacobi_theta_small_tau.ipp b/test/jacobi_theta_small_tau.ipp index 2bdb3ffa0..f611e740c 100644 --- a/test/jacobi_theta_small_tau.ipp +++ b/test/jacobi_theta_small_tau.ipp @@ -1,3 +1,10 @@ +/* + * Copyright Evan Miller, 2020 + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + #ifndef SC_ # define SC_(x) static_cast(BOOST_JOIN(x, L)) #endif diff --git a/test/ljung_box_test.cpp b/test/ljung_box_test.cpp index 2c647b95d..59d082703 100644 --- a/test/ljung_box_test.cpp +++ b/test/ljung_box_test.cpp @@ -20,7 +20,7 @@ void test_trivial() // Validate in R: // > v <- c(1,2) // > Box.test(v, lag=1, "Ljung") - // Box-Ljung test + // Box-Ljung test // data: v // X-squared = 2, df = 1, p-value = 0.1573 diff --git a/test/pchip_test.cpp b/test/pchip_test.cpp index cc5a04ce4..17db19a33 100644 --- a/test/pchip_test.cpp +++ b/test/pchip_test.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #ifdef BOOST_HAS_FLOAT128 #include using boost::multiprecision::float128; @@ -192,7 +193,7 @@ void test_monotonicity() CHECK_ULP_CLOSE(y[i], s(x[i]), 2); for (Real t = tmin; t < tmax; t += (tmax-tmin)/16) { Real greater_val = s(t); - assert(val <= greater_val); + BOOST_ASSERT(val <= greater_val); val = greater_val; } } @@ -217,7 +218,7 @@ void test_monotonicity() CHECK_ULP_CLOSE(y[i], s(x[i]), 2); for (Real t = tmin; t < tmax; t += (tmax-tmin)/16) { Real lesser_val = s(t); - assert(val >= lesser_val); + BOOST_ASSERT(val >= lesser_val); val = lesser_val; } } diff --git a/test/quintic_hermite_test.cpp b/test/quintic_hermite_test.cpp index 05299bae3..5dfb1f527 100644 --- a/test/quintic_hermite_test.cpp +++ b/test/quintic_hermite_test.cpp @@ -304,7 +304,7 @@ void test_cardinal_constant() CHECK_ULP_CLOSE(Real(0), qh_aos.prime(tlo), 2); CHECK_ULP_CLOSE(Real(0), qh_aos.prime(thi), 2); - tlo = boost::math::nextafter(tlo, std::numeric_limits::max()); + tlo = boost::math::nextafter(tlo, (std::numeric_limits::max)()); thi = boost::math::nextafter(thi, std::numeric_limits::lowest()); } } @@ -357,7 +357,7 @@ void test_cardinal_linear() CHECK_ULP_CLOSE(Real(1), qh_aos.prime(tlo), 2); CHECK_ULP_CLOSE(Real(1), qh_aos.prime(thi), 128); - tlo = boost::math::nextafter(tlo, std::numeric_limits::max()); + tlo = boost::math::nextafter(tlo, (std::numeric_limits::max)()); thi = boost::math::nextafter(thi, std::numeric_limits::lowest()); } } @@ -420,7 +420,7 @@ void test_cardinal_quadratic() CHECK_ULP_CLOSE(tlo, qh_aos.prime(tlo), 16); CHECK_ULP_CLOSE(thi, qh_aos.prime(thi), 64); - tlo = boost::math::nextafter(tlo, std::numeric_limits::max()); + tlo = boost::math::nextafter(tlo, (std::numeric_limits::max)()); thi = boost::math::nextafter(thi, std::numeric_limits::lowest()); } } diff --git a/test/rsqrt_test.cpp b/test/rsqrt_test.cpp index 9874f17d2..f41402f15 100644 --- a/test/rsqrt_test.cpp +++ b/test/rsqrt_test.cpp @@ -25,7 +25,7 @@ void test_rsqrt() { std::cout << "Testing rsqrt on type " << boost::core::demangle(typeid(Real).name()) << "\n"; using std::sqrt; - Real x = std::numeric_limits::min(); + Real x = (std::numeric_limits::min)(); while (x < 10000*std::numeric_limits::epsilon()) { Real expected = 1/sqrt(x); Real computed = rsqrt(x); @@ -64,7 +64,7 @@ void test_rsqrt() std::cerr << "Reciprocal square root of infinity not correctly computed.\n"; } - x = std::numeric_limits::max(); + x = (std::numeric_limits::max)(); expected = 1/sqrt(x); computed = rsqrt(x); if (!CHECK_EQUAL(expected, computed)) { diff --git a/test/septic_hermite_test.cpp b/test/septic_hermite_test.cpp index cd60acbe2..a7bd81f9d 100644 --- a/test/septic_hermite_test.cpp +++ b/test/septic_hermite_test.cpp @@ -94,7 +94,7 @@ void test_constant() CHECK_ULP_CLOSE(Real(0), csh_aos.double_prime(tlo), 2); CHECK_ULP_CLOSE(Real(0), csh_aos.double_prime(thi), 2); - tlo = boost::math::nextafter(tlo, std::numeric_limits::max()); + tlo = boost::math::nextafter(tlo, (std::numeric_limits::max)()); thi = boost::math::nextafter(thi, std::numeric_limits::lowest()); } @@ -195,7 +195,7 @@ void test_linear() CHECK_MOLLIFIED_CLOSE(Real(0), csh_aos.double_prime(tlo), std::numeric_limits::epsilon()); CHECK_MOLLIFIED_CLOSE(Real(0), csh_aos.double_prime(thi), 1200*std::numeric_limits::epsilon()); - tlo = boost::math::nextafter(tlo, std::numeric_limits::max()); + tlo = boost::math::nextafter(tlo, (std::numeric_limits::max)()); thi = boost::math::nextafter(thi, std::numeric_limits::lowest()); } diff --git a/test/tanh_sinh_mpfr.cpp b/test/tanh_sinh_mpfr.cpp index 2fcb1dfdf..d41963f12 100644 --- a/test/tanh_sinh_mpfr.cpp +++ b/test/tanh_sinh_mpfr.cpp @@ -27,4 +27,4 @@ int main() { Real expected = (7*zeta_three() - pi()*pi()*log(static_cast(4)))/16; CHECK_ULP_CLOSE(expected, Q, 3); return boost::math::test::report_errors(); -} \ No newline at end of file +} diff --git a/test/test_fibonacci.cpp b/test/test_fibonacci.cpp index 4461dd6a7..429819a73 100644 --- a/test/test_fibonacci.cpp +++ b/test/test_fibonacci.cpp @@ -103,4 +103,4 @@ BOOST_AUTO_TEST_CASE(constexpr_check) { // checked fibonacci can't be constexpr because of non-constexpr // dependency in detail::log_2, detail::fib_bits_phi, detail::fib_bits_deno -} \ No newline at end of file +} diff --git a/test/test_jacobi_theta.cpp b/test/test_jacobi_theta.cpp index 1da64533b..86d28efb4 100644 --- a/test/test_jacobi_theta.cpp +++ b/test/test_jacobi_theta.cpp @@ -1,3 +1,9 @@ +/* + * Copyright Evan Miller, 2020 + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ #include #include diff --git a/test/test_jacobi_theta.hpp b/test/test_jacobi_theta.hpp index 339c2291c..5c1963f5f 100644 --- a/test/test_jacobi_theta.hpp +++ b/test/test_jacobi_theta.hpp @@ -1,5 +1,9 @@ -// Copyright John Maddock 2006. -// Copyright Evan Miller 2020 +/* + * Copyright Evan Miller, 2020 + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ #define BOOST_TEST_MAIN #define NOMINMAX #include @@ -589,7 +593,7 @@ inline void test_mellin_transforms(RealType s, RealType integration_eps, RealTyp { if (t*t == 0.f) return RealType(0); - if (t > sqrt(sqrt(std::numeric_limits::max()))) + if (t > sqrt(sqrt((std::numeric_limits::max)()))) return RealType(0); return pow(t, s-1) * jacobi_theta2tau(RealType(0), t*t); @@ -599,7 +603,7 @@ inline void test_mellin_transforms(RealType s, RealType integration_eps, RealTyp { if (t*t == 0.f) return RealType(0); - if (t > sqrt(sqrt(std::numeric_limits::max()))) + if (t > sqrt(sqrt((std::numeric_limits::max)()))) return RealType(0); return pow(t, s-1) * jacobi_theta3m1tau(RealType(0), t*t); @@ -609,7 +613,7 @@ inline void test_mellin_transforms(RealType s, RealType integration_eps, RealTyp { if (t*t == 0.f) return RealType(0); - if (t > sqrt(sqrt(std::numeric_limits::max()))) + if (t > sqrt(sqrt((std::numeric_limits::max)()))) return RealType(0); return -pow(t, s-1) * jacobi_theta4m1tau(RealType(0), t*t); diff --git a/test/tgamma_mp_data.hpp b/test/tgamma_mp_data.hpp index 3ed7dbc8a..f452414b8 100644 --- a/test/tgamma_mp_data.hpp +++ b/test/tgamma_mp_data.hpp @@ -1,3 +1,9 @@ +/* + * Copyright John Maddock, 2020 + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ static const boost::array, 198> factorials = {{ { SC_(1), SC_(1), SC_(0) }, { SC_(2), SC_(1), SC_(0) }, diff --git a/tools/jacobi_theta_data.cpp b/tools/jacobi_theta_data.cpp index 9969e3a80..16c4f7fd8 100644 --- a/tools/jacobi_theta_data.cpp +++ b/tools/jacobi_theta_data.cpp @@ -1,3 +1,9 @@ +/* + * Copyright Evan Miller, 2020 + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ #include "mp_t.hpp" #include