Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/tests/SelfTest/IntrospectiveTests/FloatingPoint.tests.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2024-01-14 21:07:43 +0100
committerMartin Hořeňovský2024-01-14 21:15:02 +0100
commit7f931d6df49bc8810707084480b03259f96d6f72 (patch)
treedcd27e4fe8a03dd6c724b7defd05fd98f20af430 /tests/SelfTest/IntrospectiveTests/FloatingPoint.tests.cpp
parenta0ef2115f833ad5a79263d2b3634ffe3497d008c (diff)
downloadcatch3-7f931d6df49bc8810707084480b03259f96d6f72.tar.gz
Add tests for scaled ULP distance between +/- FLT/DBL_MAX
Diffstat (limited to 'tests/SelfTest/IntrospectiveTests/FloatingPoint.tests.cpp')
-rw-r--r--tests/SelfTest/IntrospectiveTests/FloatingPoint.tests.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/SelfTest/IntrospectiveTests/FloatingPoint.tests.cpp b/tests/SelfTest/IntrospectiveTests/FloatingPoint.tests.cpp
index eaf22a44..d2181702 100644
--- a/tests/SelfTest/IntrospectiveTests/FloatingPoint.tests.cpp
+++ b/tests/SelfTest/IntrospectiveTests/FloatingPoint.tests.cpp
@@ -123,6 +123,12 @@ TEST_CASE( "count_equidistant_floats",
CHECK( count_floats_with_scaled_ulp( 1., 1.5 ) == 1ull << 51 );
CHECK( count_floats_with_scaled_ulp( 1.25, 1.5 ) == 1ull << 50 );
CHECK( count_floats_with_scaled_ulp( 1.f, 1.5f ) == 1 << 22 );
+ CHECK( count_floats_with_scaled_ulp( -std::numeric_limits<float>::max(),
+ std::numeric_limits<float>::max() ) ==
+ 33554430 ); // (1 << 25) - 2 due to not including infinities
+ CHECK( count_floats_with_scaled_ulp( -std::numeric_limits<double>::max(),
+ std::numeric_limits<double>::max() ) ==
+ 18014398509481982 ); // (1 << 54) - 2 due to not including infinities
STATIC_REQUIRE( std::is_same<std::uint64_t,
decltype( count_floats_with_scaled_ulp(