Changeset View
Changeset View
Standalone View
Standalone View
src/test/compress_tests.cpp
Show All 18 Lines | |||||
// amounts 1 .. 10000 | // amounts 1 .. 10000 | ||||
#define NUM_MULTIPLES_1BCC 10000 | #define NUM_MULTIPLES_1BCC 10000 | ||||
// amounts 50 .. 21000000 | // amounts 50 .. 21000000 | ||||
#define NUM_MULTIPLES_50BCC 420000 | #define NUM_MULTIPLES_50BCC 420000 | ||||
BOOST_FIXTURE_TEST_SUITE(compress_tests, BasicTestingSetup) | BOOST_FIXTURE_TEST_SUITE(compress_tests, BasicTestingSetup) | ||||
static bool TestEncode(uint64_t in) { | static bool TestEncode(CAmount in) { | ||||
return in == CTxOutCompressor::DecompressAmount( | return in == CTxOutCompressor::DecompressAmount( | ||||
CTxOutCompressor::CompressAmount(in)); | CTxOutCompressor::CompressAmount(in)); | ||||
} | } | ||||
static bool TestDecode(uint64_t in) { | static bool TestDecode(uint64_t in) { | ||||
return in == CTxOutCompressor::CompressAmount( | return in == CTxOutCompressor::CompressAmount( | ||||
CTxOutCompressor::DecompressAmount(in)); | CTxOutCompressor::DecompressAmount(in)); | ||||
} | } | ||||
static bool TestPair(uint64_t dec, uint64_t enc) { | static bool TestPair(CAmount dec, uint64_t enc) { | ||||
return CTxOutCompressor::CompressAmount(dec) == enc && | return CTxOutCompressor::CompressAmount(dec) == enc && | ||||
CTxOutCompressor::DecompressAmount(enc) == dec; | CTxOutCompressor::DecompressAmount(enc) == dec; | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(compress_amounts) { | BOOST_AUTO_TEST_CASE(compress_amounts) { | ||||
BOOST_CHECK(TestPair(0, 0x0)); | BOOST_CHECK(TestPair(0, 0x0)); | ||||
BOOST_CHECK(TestPair(1, 0x1)); | BOOST_CHECK(TestPair(1, 0x1)); | ||||
BOOST_CHECK(TestPair(CENT, 0x7)); | BOOST_CHECK(TestPair(CENT, 0x7)); | ||||
Show All 26 Lines |