From 2384276ae0111aee252dbec5acc18d30607d88cc Mon Sep 17 00:00:00 2001 From: Chip Hogg Date: Fri, 28 Jan 2022 20:44:29 +0000 Subject: [PATCH] Only test pi if float is smaller than long double --- test/unit_test/runtime/magnitude_test.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/test/unit_test/runtime/magnitude_test.cpp b/test/unit_test/runtime/magnitude_test.cpp index f1e73789..00ccd43e 100644 --- a/test/unit_test/runtime/magnitude_test.cpp +++ b/test/unit_test/runtime/magnitude_test.cpp @@ -163,15 +163,17 @@ TEST_CASE("magnitude converts to numerical value") SECTION("pi to arbitrary power performs computations in most accurate type at compile time") { - constexpr auto pi_cubed = pi_to_the<3>(); + if constexpr (sizeof(float) < sizeof(long double)) { + constexpr auto pi_cubed = pi_to_the<3>(); - auto cube = [](auto x) { return x * x * x; }; - constexpr auto via_float = cube(std::numbers::pi_v); - constexpr auto via_long_double = static_cast(cube(std::numbers::pi_v)); + auto cube = [](auto x) { return x * x * x; }; + constexpr auto via_float = cube(std::numbers::pi_v); + constexpr auto via_long_double = static_cast(cube(std::numbers::pi_v)); - constexpr auto pi_cubed_value = pi_cubed.value; - REQUIRE(pi_cubed_value != via_float); - CHECK(pi_cubed_value == via_long_double); + constexpr auto pi_cubed_value = pi_cubed.value; + REQUIRE(pi_cubed_value != via_float); + CHECK(pi_cubed_value == via_long_double); + } } SECTION("Impossible requests are prevented at compile time")