Changeset View
Changeset View
Standalone View
Standalone View
src/test/random_tests.cpp
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
BOOST_AUTO_TEST_CASE(fastrandom_randbits) { | BOOST_AUTO_TEST_CASE(fastrandom_randbits) { | ||||
FastRandomContext ctx1; | FastRandomContext ctx1; | ||||
FastRandomContext ctx2; | FastRandomContext ctx2; | ||||
for (int bits = 0; bits < 63; ++bits) { | for (int bits = 0; bits < 63; ++bits) { | ||||
for (int j = 0; j < 1000; ++j) { | for (int j = 0; j < 1000; ++j) { | ||||
uint64_t rangebits = ctx1.randbits(bits); | uint64_t rangebits = ctx1.randbits(bits); | ||||
BOOST_CHECK_EQUAL(rangebits >> bits, uint64_t(0)); | BOOST_CHECK_EQUAL(rangebits >> bits, 0U); | ||||
uint64_t range = uint64_t(1) << bits | rangebits; | uint64_t range = uint64_t(1) << bits | rangebits; | ||||
uint64_t rand = ctx2.randrange(range); | uint64_t rand = ctx2.randrange(range); | ||||
BOOST_CHECK(rand < range); | BOOST_CHECK(rand < range); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
/** Does-it-compile test for compatibility with standard C++11 RNG interface. */ | /** Does-it-compile test for compatibility with standard C++11 RNG interface. */ | ||||
▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines |