Changeset View
Changeset View
Standalone View
Standalone View
src/test/serialize_tests.cpp
Show First 20 Lines • Show All 145 Lines • ▼ Show 20 Lines | |||||
== '43d0c82591953c4eafe114590d392676a01585d25b25d433557f0d7878b23f96' | == '43d0c82591953c4eafe114590d392676a01585d25b25d433557f0d7878b23f96' | ||||
*/ | */ | ||||
BOOST_AUTO_TEST_CASE(floats) { | BOOST_AUTO_TEST_CASE(floats) { | ||||
CDataStream ss(SER_DISK, 0); | CDataStream ss(SER_DISK, 0); | ||||
// encode | // encode | ||||
for (int i = 0; i < 1000; i++) { | for (int i = 0; i < 1000; i++) { | ||||
ss << float(i); | ss << float(i); | ||||
} | } | ||||
BOOST_CHECK(Hash(ss.begin(), ss.end()) == | BOOST_CHECK(Hash(ss) == | ||||
uint256S("8e8b4cf3e4df8b332057e3e23af42ebc663b61e0495d5e7e32d85" | uint256S("8e8b4cf3e4df8b332057e3e23af42ebc663b61e0495d5e7e32d85" | ||||
"099d7f3fe0c")); | "099d7f3fe0c")); | ||||
// decode | // decode | ||||
for (int i = 0; i < 1000; i++) { | for (int i = 0; i < 1000; i++) { | ||||
float j; | float j; | ||||
ss >> j; | ss >> j; | ||||
BOOST_CHECK_MESSAGE(i == j, "decoded:" << j << " expected:" << i); | BOOST_CHECK_MESSAGE(i == j, "decoded:" << j << " expected:" << i); | ||||
} | } | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(doubles) { | BOOST_AUTO_TEST_CASE(doubles) { | ||||
CDataStream ss(SER_DISK, 0); | CDataStream ss(SER_DISK, 0); | ||||
// encode | // encode | ||||
for (int i = 0; i < 1000; i++) { | for (int i = 0; i < 1000; i++) { | ||||
ss << double(i); | ss << double(i); | ||||
} | } | ||||
BOOST_CHECK(Hash(ss.begin(), ss.end()) == | BOOST_CHECK(Hash(ss) == | ||||
uint256S("43d0c82591953c4eafe114590d392676a01585d25b25d433557f0" | uint256S("43d0c82591953c4eafe114590d392676a01585d25b25d433557f0" | ||||
"d7878b23f96")); | "d7878b23f96")); | ||||
// decode | // decode | ||||
for (int i = 0; i < 1000; i++) { | for (int i = 0; i < 1000; i++) { | ||||
double j; | double j; | ||||
ss >> j; | ss >> j; | ||||
BOOST_CHECK_MESSAGE(i == j, "decoded:" << j << " expected:" << i); | BOOST_CHECK_MESSAGE(i == j, "decoded:" << j << " expected:" << i); | ||||
▲ Show 20 Lines • Show All 269 Lines • Show Last 20 Lines |