Feathercoin  0.5.0
P2P Digital Currency
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
compress_tests.cpp
Go to the documentation of this file.
1 #include <boost/test/unit_test.hpp>
2 
3 #include <string>
4 #include <vector>
5 
6 #include "main.h"
7 
8 // amounts 0.00000001 .. 0.00100000
9 #define NUM_MULTIPLES_UNIT 100000
10 
11 // amounts 0.01 .. 100.00
12 #define NUM_MULTIPLES_CENT 10000
13 
14 // amounts 1 .. 10000
15 #define NUM_MULTIPLES_1BTC 10000
16 
17 // amounts 50 .. 21000000
18 #define NUM_MULTIPLES_50BTC 420000
19 
20 using namespace std;
21 
22 BOOST_AUTO_TEST_SUITE(compress_tests)
23 
24 bool static TestEncode(uint64 in) {
26 }
27 
28 bool static TestDecode(uint64 in) {
30 }
31 
32 bool static TestPair(uint64 dec, uint64 enc) {
33  return CTxOutCompressor::CompressAmount(dec) == enc &&
35 }
36 
37 BOOST_AUTO_TEST_CASE(compress_amounts)
38 {
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));
45 
46  for (uint64 i = 1; i <= NUM_MULTIPLES_UNIT; i++)
47  BOOST_CHECK(TestEncode(i));
48 
49  for (uint64 i = 1; i <= NUM_MULTIPLES_CENT; i++)
50  BOOST_CHECK(TestEncode(i * CENT));
51 
52  for (uint64 i = 1; i <= NUM_MULTIPLES_1BTC; i++)
53  BOOST_CHECK(TestEncode(i * COIN));
54 
55  for (uint64 i = 1; i <= NUM_MULTIPLES_50BTC; i++)
56  BOOST_CHECK(TestEncode(i * 50 * COIN));
57 
58  for (uint64 i = 0; i < 100000; i++)
59  BOOST_CHECK(TestDecode(i));
60 }
61 
62 BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(compress_amounts)
static uint64 CompressAmount(uint64 nAmount)
Definition: main.cpp:4832
unsigned long long uint64
Definition: serialize.h:26
#define NUM_MULTIPLES_CENT
#define NUM_MULTIPLES_UNIT
#define NUM_MULTIPLES_1BTC
#define NUM_MULTIPLES_50BTC
static uint64 DecompressAmount(uint64 nAmount)
Definition: main.cpp:4851