Changeset View
Changeset View
Standalone View
Standalone View
src/test/util_tests.cpp
Show First 20 Lines • Show All 1,380 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(util_IsHexNumber) { | ||||
BOOST_CHECK(!IsHexNumber("0x 0")); // or middle, | BOOST_CHECK(!IsHexNumber("0x 0")); // or middle, | ||||
BOOST_CHECK(!IsHexNumber(" ")); // etc. | BOOST_CHECK(!IsHexNumber(" ")); // etc. | ||||
BOOST_CHECK(!IsHexNumber("0x0ga")); // invalid character | BOOST_CHECK(!IsHexNumber("0x0ga")); // invalid character | ||||
BOOST_CHECK(!IsHexNumber("x0")); // broken prefix | BOOST_CHECK(!IsHexNumber("x0")); // broken prefix | ||||
BOOST_CHECK(!IsHexNumber("0x0x00")); // two prefixes not allowed | BOOST_CHECK(!IsHexNumber("0x0x00")); // two prefixes not allowed | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(util_seed_insecure_rand) { | BOOST_AUTO_TEST_CASE(util_seed_insecure_rand) { | ||||
SeedInsecureRand(true); | SeedInsecureRand(SeedRand::ZEROS); | ||||
for (int mod = 2; mod < 11; mod++) { | for (int mod = 2; mod < 11; mod++) { | ||||
int mask = 1; | int mask = 1; | ||||
// Really rough binomial confidence approximation. | // Really rough binomial confidence approximation. | ||||
int err = | int err = | ||||
30 * 10000. / mod * sqrt((1. / mod * (1 - 1. / mod)) / 10000.); | 30 * 10000. / mod * sqrt((1. / mod * (1 - 1. / mod)) / 10000.); | ||||
// mask is 2^ceil(log2(mod))-1 | // mask is 2^ceil(log2(mod))-1 | ||||
while (mask < mod - 1) { | while (mask < mod - 1) { | ||||
mask = (mask << 1) + 1; | mask = (mask << 1) + 1; | ||||
▲ Show 20 Lines • Show All 894 Lines • Show Last 20 Lines |