random: get rid of GetRand by inlining

This commit is contained in:
Pieter Wuille
2024-06-27 11:40:00 -04:00
parent e2d1f84858
commit ddc184d999
14 changed files with 40 additions and 49 deletions

View File

@@ -28,18 +28,18 @@ BOOST_AUTO_TEST_CASE(fastrandom_tests_deterministic)
FastRandomContext ctx2{true};
{
BOOST_CHECK_EQUAL(GetRand<uint64_t>(), uint64_t{9330418229102544152u});
BOOST_CHECK_EQUAL(GetRand<int>(), int{618925161});
BOOST_CHECK_EQUAL(FastRandomContext().rand<uint64_t>(), uint64_t{9330418229102544152u});
BOOST_CHECK_EQUAL(FastRandomContext().rand<int>(), int{618925161});
BOOST_CHECK_EQUAL(GetRandMicros(std::chrono::hours{1}).count(), 1271170921);
BOOST_CHECK_EQUAL(GetRandMillis(std::chrono::hours{1}).count(), 2803534);
BOOST_CHECK_EQUAL(GetRand<uint64_t>(), uint64_t{10170981140880778086u});
BOOST_CHECK_EQUAL(GetRand<int>(), int{1689082725});
BOOST_CHECK_EQUAL(FastRandomContext().rand<uint64_t>(), uint64_t{10170981140880778086u});
BOOST_CHECK_EQUAL(FastRandomContext().rand<int>(), int{1689082725});
BOOST_CHECK_EQUAL(GetRandMicros(std::chrono::hours{1}).count(), 2464643716);
BOOST_CHECK_EQUAL(GetRandMillis(std::chrono::hours{1}).count(), 2312205);
BOOST_CHECK_EQUAL(GetRand<uint64_t>(), uint64_t{5689404004456455543u});
BOOST_CHECK_EQUAL(GetRand<int>(), int{785839937});
BOOST_CHECK_EQUAL(FastRandomContext().rand<uint64_t>(), uint64_t{5689404004456455543u});
BOOST_CHECK_EQUAL(FastRandomContext().rand<int>(), int{785839937});
BOOST_CHECK_EQUAL(GetRandMicros(std::chrono::hours{1}).count(), 93558804);
BOOST_CHECK_EQUAL(GetRandMillis(std::chrono::hours{1}).count(), 507022);
}
@@ -82,18 +82,18 @@ BOOST_AUTO_TEST_CASE(fastrandom_tests_nondeterministic)
{
// Check that a nondeterministic ones are not
{
BOOST_CHECK(GetRand<uint64_t>() != uint64_t{9330418229102544152u});
BOOST_CHECK(GetRand<int>() != int{618925161});
BOOST_CHECK(FastRandomContext().rand<uint64_t>() != uint64_t{9330418229102544152u});
BOOST_CHECK(FastRandomContext().rand<int>() != int{618925161});
BOOST_CHECK(GetRandMicros(std::chrono::hours{1}).count() != 1271170921);
BOOST_CHECK(GetRandMillis(std::chrono::hours{1}).count() != 2803534);
BOOST_CHECK(GetRand<uint64_t>() != uint64_t{10170981140880778086u});
BOOST_CHECK(GetRand<int>() != int{1689082725});
BOOST_CHECK(FastRandomContext().rand<uint64_t>() != uint64_t{10170981140880778086u});
BOOST_CHECK(FastRandomContext().rand<int>() != int{1689082725});
BOOST_CHECK(GetRandMicros(std::chrono::hours{1}).count() != 2464643716);
BOOST_CHECK(GetRandMillis(std::chrono::hours{1}).count() != 2312205);
BOOST_CHECK(GetRand<uint64_t>() != uint64_t{5689404004456455543u});
BOOST_CHECK(GetRand<int>() != int{785839937});
BOOST_CHECK(FastRandomContext().rand<uint64_t>() != uint64_t{5689404004456455543u});
BOOST_CHECK(FastRandomContext().rand<int>() != int{785839937});
BOOST_CHECK(GetRandMicros(std::chrono::hours{1}).count() != 93558804);
BOOST_CHECK(GetRandMillis(std::chrono::hours{1}).count() != 507022);
}