Changeset View
Changeset View
Standalone View
Standalone View
src/test/crypto_tests.cpp
Show First 20 Lines • Show All 657 Lines • ▼ Show 20 Lines | TestChaCha20( | ||||
"32b63fc385245fe054e3dd5a97a5f576fe064025d3ce042c566ab2c507b138db853e3d" | "32b63fc385245fe054e3dd5a97a5f576fe064025d3ce042c566ab2c507b138db853e3d" | ||||
"6959660996546cc9c4a6eafdc777c040d70eaf46f76dad3979e5c5360c3317166a1c89" | "6959660996546cc9c4a6eafdc777c040d70eaf46f76dad3979e5c5360c3317166a1c89" | ||||
"4c94a371876a94df7628fe4eaaf2ccb27d5aaae0ad7ad0f9d4b6ad3b54098746d4524d" | "4c94a371876a94df7628fe4eaaf2ccb27d5aaae0ad7ad0f9d4b6ad3b54098746d4524d" | ||||
"38407a6deb3ab78fab78c9"); | "38407a6deb3ab78fab78c9"); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(countbits_tests) { | BOOST_AUTO_TEST_CASE(countbits_tests) { | ||||
FastRandomContext ctx; | FastRandomContext ctx; | ||||
for (int i = 0; i <= 64; ++i) { | for (unsigned int i = 0; i <= 64; ++i) { | ||||
if (i == 0) { | if (i == 0) { | ||||
// Check handling of zero. | // Check handling of zero. | ||||
BOOST_CHECK_EQUAL(CountBits(0), 0); | BOOST_CHECK_EQUAL(CountBits(0), 0U); | ||||
} else if (i < 10) { | } else if (i < 10) { | ||||
for (uint64_t j = 1 << (i - 1); (j >> i) == 0; ++j) { | for (uint64_t j = 1 << (i - 1); (j >> i) == 0; ++j) { | ||||
// Exhaustively test up to 10 bits | // Exhaustively test up to 10 bits | ||||
BOOST_CHECK_EQUAL(CountBits(j), i); | BOOST_CHECK_EQUAL(CountBits(j), i); | ||||
} | } | ||||
} else { | } else { | ||||
for (int k = 0; k < 1000; k++) { | for (int k = 0; k < 1000; k++) { | ||||
// Randomly test 1000 samples of each length above 10 bits. | // Randomly test 1000 samples of each length above 10 bits. | ||||
Show All 23 Lines |