12#include <boost/test/unit_test.hpp>
21uint64_t TestDouble(
double f) {
43 BOOST_CHECK_EQUAL(TestDouble(std::numeric_limits<double>::infinity()), 0x7ff0000000000000U);
44 BOOST_CHECK_EQUAL(TestDouble(-std::numeric_limits<double>::infinity()), 0xfff0000000000000);
89 BOOST_CHECK_EQUAL(TestDouble(std::numeric_limits<double>::min()), 0x10000000000000);
90 BOOST_CHECK_EQUAL(TestDouble(-std::numeric_limits<double>::min()), 0x8010000000000000);
91 BOOST_CHECK_EQUAL(TestDouble(std::numeric_limits<double>::max()), 0x7fefffffffffffff);
92 BOOST_CHECK_EQUAL(TestDouble(-std::numeric_limits<double>::max()), 0xffefffffffffffff);
93 BOOST_CHECK_EQUAL(TestDouble(std::numeric_limits<double>::lowest()), 0xffefffffffffffff);
94 BOOST_CHECK_EQUAL(TestDouble(-std::numeric_limits<double>::lowest()), 0x7fefffffffffffff);
96 BOOST_CHECK_EQUAL(TestDouble(-std::numeric_limits<double>::denorm_min()), 0x8000000000000001);
98 BOOST_CHECK_EQUAL(TestDouble(std::numeric_limits<double>::quiet_NaN()), 0x7ff8000000000000);
99 BOOST_CHECK_EQUAL(TestDouble(-std::numeric_limits<double>::quiet_NaN()), 0x7ff8000000000000);
100 BOOST_CHECK_EQUAL(TestDouble(std::numeric_limits<double>::signaling_NaN()), 0x7ff8000000000000);
101 BOOST_CHECK_EQUAL(TestDouble(-std::numeric_limits<double>::signaling_NaN()), 0x7ff8000000000000);
104 static_assert(
sizeof(double) == 8);
105 static_assert(
sizeof(uint64_t) == 8);
106 for (
int j = 0; j < 1000; ++j) {
110 for (
int x = 0; x < 512; ++x) {
111 uint64_t v = m_rng.randbits(64);
113 for (
int v_pos : {0, 1, 50, 51, 52, 53, 61, 62, 63}) {
114 v &= ~(uint64_t{1} << v_pos);
115 if ((x >> (x_pos++)) & 1) v |= (uint64_t{1} << v_pos);
139 for (
int i = 0; i < 1000; i++) {
145 for (
int i = 0; i < 1000; i++) {
149 BOOST_CHECK_MESSAGE(i == j,
"decoded:" << j <<
" expected:" << i);
Double ended buffer combining vector and stream-like interfaces.
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
uint256 Hash(const T &in1)
Compute the 256-bit hash of an object.
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
uint64_t EncodeDouble(double f) noexcept
double DecodeDouble(uint64_t v) noexcept
BOOST_AUTO_TEST_CASE(double_serfloat_tests)