mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-17 05:30:43 +02:00
test: Add test for GetRandMillis and GetRandMicros
This commit is contained in:
parent
fa0e5b89cf
commit
0000ea3265
@ -28,6 +28,8 @@ BOOST_AUTO_TEST_CASE(fastrandom_tests)
|
|||||||
for (int i = 10; i > 0; --i) {
|
for (int i = 10; i > 0; --i) {
|
||||||
BOOST_CHECK_EQUAL(GetRand(std::numeric_limits<uint64_t>::max()), uint64_t{10393729187455219830U});
|
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(GetRandInt(std::numeric_limits<int>::max()), int{769702006});
|
||||||
|
BOOST_CHECK_EQUAL(GetRandMicros(std::chrono::hours{1}).count(), 2917185654);
|
||||||
|
BOOST_CHECK_EQUAL(GetRandMillis(std::chrono::hours{1}).count(), 2144374);
|
||||||
}
|
}
|
||||||
BOOST_CHECK_EQUAL(ctx1.rand32(), ctx2.rand32());
|
BOOST_CHECK_EQUAL(ctx1.rand32(), ctx2.rand32());
|
||||||
BOOST_CHECK_EQUAL(ctx1.rand32(), ctx2.rand32());
|
BOOST_CHECK_EQUAL(ctx1.rand32(), ctx2.rand32());
|
||||||
@ -47,6 +49,8 @@ BOOST_AUTO_TEST_CASE(fastrandom_tests)
|
|||||||
for (int i = 10; i > 0; --i) {
|
for (int i = 10; i > 0; --i) {
|
||||||
BOOST_CHECK(GetRand(std::numeric_limits<uint64_t>::max()) != uint64_t{10393729187455219830U});
|
BOOST_CHECK(GetRand(std::numeric_limits<uint64_t>::max()) != uint64_t{10393729187455219830U});
|
||||||
BOOST_CHECK(GetRandInt(std::numeric_limits<int>::max()) != int{769702006});
|
BOOST_CHECK(GetRandInt(std::numeric_limits<int>::max()) != int{769702006});
|
||||||
|
BOOST_CHECK(GetRandMicros(std::chrono::hours{1}) != std::chrono::microseconds{2917185654});
|
||||||
|
BOOST_CHECK(GetRandMillis(std::chrono::hours{1}) != std::chrono::milliseconds{2144374});
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
FastRandomContext ctx3, ctx4;
|
FastRandomContext ctx3, ctx4;
|
||||||
@ -97,7 +101,6 @@ BOOST_AUTO_TEST_CASE(stdrandom_test)
|
|||||||
BOOST_CHECK(std::find(test.begin(), test.end(), j) != test.end());
|
BOOST_CHECK(std::find(test.begin(), test.end(), j) != test.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Test that Shuffle reaches every permutation with equal probability. */
|
/** Test that Shuffle reaches every permutation with equal probability. */
|
||||||
|
Loading…
Reference in New Issue
Block a user