Changeset View
Changeset View
Standalone View
Standalone View
src/test/compress_tests.cpp
Show All 11 Lines | |||||
// amounts 0.00000001 .. 0.00100000 | // amounts 0.00000001 .. 0.00100000 | ||||
#define NUM_MULTIPLES_UNIT 100000 | #define NUM_MULTIPLES_UNIT 100000 | ||||
// amounts 0.01 .. 100.00 | // amounts 0.01 .. 100.00 | ||||
#define NUM_MULTIPLES_CENT 10000 | #define NUM_MULTIPLES_CENT 10000 | ||||
// amounts 1 .. 10000 | // amounts 1 .. 10000 | ||||
#define NUM_MULTIPLES_1BCC 10000 | #define NUM_MULTIPLES_1BCH 10000 | ||||
// amounts 50 .. 21000000 | // amounts 50 .. 21000000 | ||||
#define NUM_MULTIPLES_50BCC 420000 | #define NUM_MULTIPLES_50BCH 420000 | ||||
BOOST_FIXTURE_TEST_SUITE(compress_tests, BasicTestingSetup) | BOOST_FIXTURE_TEST_SUITE(compress_tests, BasicTestingSetup) | ||||
static bool TestEncode(Amount in) { | static bool TestEncode(Amount in) { | ||||
return in == CTxOutCompressor::DecompressAmount( | return in == CTxOutCompressor::DecompressAmount( | ||||
CTxOutCompressor::CompressAmount(in)); | CTxOutCompressor::CompressAmount(in)); | ||||
} | } | ||||
Show All 18 Lines | BOOST_AUTO_TEST_CASE(compress_amounts) { | ||||
for (int64_t i = 1; i <= NUM_MULTIPLES_UNIT; i++) { | for (int64_t i = 1; i <= NUM_MULTIPLES_UNIT; i++) { | ||||
BOOST_CHECK(TestEncode(i)); | BOOST_CHECK(TestEncode(i)); | ||||
} | } | ||||
for (int64_t i = 1; i <= NUM_MULTIPLES_CENT; i++) { | for (int64_t i = 1; i <= NUM_MULTIPLES_CENT; i++) { | ||||
BOOST_CHECK(TestEncode(i * CENT)); | BOOST_CHECK(TestEncode(i * CENT)); | ||||
} | } | ||||
for (int64_t i = 1; i <= NUM_MULTIPLES_1BCC; i++) { | for (int64_t i = 1; i <= NUM_MULTIPLES_1BCH; i++) { | ||||
BOOST_CHECK(TestEncode(i * COIN)); | BOOST_CHECK(TestEncode(i * COIN)); | ||||
} | } | ||||
for (int64_t i = 1; i <= NUM_MULTIPLES_50BCC; i++) { | for (int64_t i = 1; i <= NUM_MULTIPLES_50BCH; i++) { | ||||
BOOST_CHECK(TestEncode(i * 50 * COIN)); | BOOST_CHECK(TestEncode(i * 50 * COIN)); | ||||
} | } | ||||
for (int64_t i = 0; i < 100000; i++) { | for (int64_t i = 0; i < 100000; i++) { | ||||
BOOST_CHECK(TestDecode(i)); | BOOST_CHECK(TestDecode(i)); | ||||
} | } | ||||
} | } | ||||
BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() |