1 #include <boost/test/unit_test.hpp>
9 #define NUM_MULTIPLES_UNIT 100000
12 #define NUM_MULTIPLES_CENT 10000
15 #define NUM_MULTIPLES_1BTC 10000
18 #define NUM_MULTIPLES_50BTC 420000
22 BOOST_AUTO_TEST_SUITE(compress_tests)
24 bool static TestEncode(
uint64 in) {
28 bool static TestDecode(
uint64 in) {
39 BOOST_CHECK(TestPair( 0, 0x0));
40 BOOST_CHECK(TestPair( 1, 0x1));
41 BOOST_CHECK(TestPair( CENT, 0x7));
42 BOOST_CHECK(TestPair( COIN, 0x9));
43 BOOST_CHECK(TestPair( 50*COIN, 0x32));
44 BOOST_CHECK(TestPair(21000000*COIN, 0x1406f40));
47 BOOST_CHECK(TestEncode(i));
50 BOOST_CHECK(TestEncode(i * CENT));
53 BOOST_CHECK(TestEncode(i * COIN));
56 BOOST_CHECK(TestEncode(i * 50 * COIN));
58 for (
uint64 i = 0; i < 100000; i++)
59 BOOST_CHECK(TestDecode(i));
62 BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(compress_amounts)
static uint64 CompressAmount(uint64 nAmount)
unsigned long long uint64
#define NUM_MULTIPLES_CENT
#define NUM_MULTIPLES_UNIT
#define NUM_MULTIPLES_1BTC
#define NUM_MULTIPLES_50BTC
static uint64 DecompressAmount(uint64 nAmount)