aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2024-01-05 14:26:52 -0500
committerPieter Wuille <pieter@wuille.net>2024-02-20 10:25:41 +0000
commitb45f1f56582fb3a0d17db5014ac57f1fb40a3611 (patch)
tree3f352dd7b2204faae50d7b0e7f966d55cdf3a7d2 /src/test
parentbdddf364c9a6f80e3bfcf45ab1ae54f9eab5811b (diff)
serfloat: do not test encode(bits)=bits anymore
Diffstat (limited to 'src/test')
-rw-r--r--src/test/serfloat_tests.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/test/serfloat_tests.cpp b/src/test/serfloat_tests.cpp
index b36bdc02ca..d9b29b60ec 100644
--- a/src/test/serfloat_tests.cpp
+++ b/src/test/serfloat_tests.cpp
@@ -47,7 +47,6 @@ BOOST_AUTO_TEST_CASE(double_serfloat_tests) {
BOOST_CHECK_EQUAL(TestDouble(4.0), 0x4010000000000000ULL);
BOOST_CHECK_EQUAL(TestDouble(785.066650390625), 0x4088888880000000ULL);
- // Roundtrip test on IEC559-compatible systems
if (std::numeric_limits<double>::is_iec559) {
BOOST_CHECK_EQUAL(sizeof(double), 8U);
BOOST_CHECK_EQUAL(sizeof(uint64_t), 8U);
@@ -64,8 +63,7 @@ BOOST_AUTO_TEST_CASE(double_serfloat_tests) {
TestDouble(-std::numeric_limits<double>::signaling_NaN());
TestDouble(std::numeric_limits<double>::denorm_min());
TestDouble(-std::numeric_limits<double>::denorm_min());
- // Test exact encoding: on currently supported platforms, EncodeDouble
- // should produce exactly the same as the in-memory representation for non-NaN.
+ // On IEC559-compatible systems, construct doubles to test from the encoding.
for (int j = 0; j < 1000; ++j) {
// Iterate over 9 specific bits exhaustively; the others are chosen randomly.
// These specific bits are the sign bit, and the 2 top and bottom bits of
@@ -92,8 +90,7 @@ BOOST_AUTO_TEST_CASE(double_serfloat_tests) {
if (x & 256) v |= (uint64_t{1} << 63);
double f;
memcpy(&f, &v, 8);
- uint64_t v2 = TestDouble(f);
- if (!std::isnan(f)) BOOST_CHECK_EQUAL(v, v2);
+ TestDouble(f);
}
}
}