diff options
author | MacroFake <falke.marco@gmail.com> | 2022-05-12 08:57:12 +0200 |
---|---|---|
committer | MacroFake <falke.marco@gmail.com> | 2022-05-12 08:57:22 +0200 |
commit | a2a8e919ee07506083f45426874cd2edf82d9f9f (patch) | |
tree | fb1f82ca4b8660b3366bf80c16d0321ec4f4f07c /src/test/random_tests.cpp | |
parent | 51527ec1ec4264f7e24ef548bb049db07a89fc7f (diff) | |
parent | ab1ea29ba1b8379a21fabd3dc859552c470a6421 (diff) | |
download | bitcoin-a2a8e919ee07506083f45426874cd2edf82d9f9f.tar.xz |
Merge bitcoin/bitcoin#24925: refactor: make GetRand a template, remove GetRandInt
ab1ea29ba1b8379a21fabd3dc859552c470a6421 refactor: make GetRand a template, remove GetRandInt (pasta)
Pull request description:
makes GetRand a template for which any integral type can be used, where the default behavior is to return a random integral up to the max of the integral unless a max is provided.
This simplifies a lot of code from GetRand(std::numeric_limits<uint64_t>::max() -> GetRand<uint64_t>()
ACKs for top commit:
laanwj:
Code review ACK ab1ea29ba1b8379a21fabd3dc859552c470a6421
Tree-SHA512: db5082a0e21783389f1be898ae73e097b31ab48cab1a2c0e29348a4adeb545d4098193aa72a547c6baa6e8205699aafec38d6a27b3d65522fb3246f91b4daae9
Diffstat (limited to 'src/test/random_tests.cpp')
-rw-r--r-- | src/test/random_tests.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/test/random_tests.cpp b/src/test/random_tests.cpp index a3daefa599..9b2760fd1c 100644 --- a/src/test/random_tests.cpp +++ b/src/test/random_tests.cpp @@ -26,8 +26,8 @@ BOOST_AUTO_TEST_CASE(fastrandom_tests) FastRandomContext ctx2(true); for (int i = 10; i > 0; --i) { - BOOST_CHECK_EQUAL(GetRand(std::numeric_limits<uint64_t>::max()), uint64_t{10393729187455219830U}); - BOOST_CHECK_EQUAL(GetRandInt(std::numeric_limits<int>::max()), int{769702006}); + BOOST_CHECK_EQUAL(GetRand<uint64_t>(), uint64_t{10393729187455219830U}); + BOOST_CHECK_EQUAL(GetRand<int>(), int{769702006}); BOOST_CHECK_EQUAL(GetRandMicros(std::chrono::hours{1}).count(), 2917185654); BOOST_CHECK_EQUAL(GetRandMillis(std::chrono::hours{1}).count(), 2144374); } @@ -57,8 +57,8 @@ BOOST_AUTO_TEST_CASE(fastrandom_tests) // Check that a nondeterministic ones are not g_mock_deterministic_tests = false; for (int i = 10; i > 0; --i) { - BOOST_CHECK(GetRand(std::numeric_limits<uint64_t>::max()) != uint64_t{10393729187455219830U}); - BOOST_CHECK(GetRandInt(std::numeric_limits<int>::max()) != int{769702006}); + BOOST_CHECK(GetRand<uint64_t>() != uint64_t{10393729187455219830U}); + BOOST_CHECK(GetRand<int>() != int{769702006}); BOOST_CHECK(GetRandMicros(std::chrono::hours{1}) != std::chrono::microseconds{2917185654}); BOOST_CHECK(GetRandMillis(std::chrono::hours{1}) != std::chrono::milliseconds{2144374}); } |