|
1 | 1 | #include <data_handler.hpp>
|
2 | 2 | #include <unity.h>
|
3 | 3 |
|
4 |
| -void setUp(void) { |
| 4 | +void setUp(void) |
| 5 | +{ |
5 | 6 | // set stuff up here
|
6 | 7 | }
|
7 | 8 |
|
8 |
| -void tearDown(void) { |
| 9 | +void tearDown(void) |
| 10 | +{ |
9 | 11 | // clean stuff up here
|
10 | 12 | }
|
11 | 13 |
|
12 |
| -void test_CorrectSatsPerDollarConversion(void) { |
13 |
| - std::array<std::string, NUM_SCREENS> output = parseSatsPerCurrency(37253, '$', false); |
| 14 | +void test_CorrectSatsPerDollarConversion(void) |
| 15 | +{ |
| 16 | + std::array<std::string, NUM_SCREENS> output = parseSatsPerCurrency(37253, CURRENCY_USD, false); |
14 | 17 | TEST_ASSERT_EQUAL_STRING("MSCW/TIME", output[0].c_str());
|
15 |
| - TEST_ASSERT_EQUAL_STRING("2", output[NUM_SCREENS-4].c_str()); |
16 |
| - TEST_ASSERT_EQUAL_STRING("6", output[NUM_SCREENS-3].c_str()); |
17 |
| - TEST_ASSERT_EQUAL_STRING("8", output[NUM_SCREENS-2].c_str()); |
18 |
| - TEST_ASSERT_EQUAL_STRING("4", output[NUM_SCREENS-1].c_str()); |
| 18 | + TEST_ASSERT_EQUAL_STRING("2", output[NUM_SCREENS - 4].c_str()); |
| 19 | + TEST_ASSERT_EQUAL_STRING("6", output[NUM_SCREENS - 3].c_str()); |
| 20 | + TEST_ASSERT_EQUAL_STRING("8", output[NUM_SCREENS - 2].c_str()); |
| 21 | + TEST_ASSERT_EQUAL_STRING("4", output[NUM_SCREENS - 1].c_str()); |
19 | 22 | }
|
20 | 23 |
|
| 24 | +void test_CorrectSatsPerPoundConversion(void) |
| 25 | +{ |
| 26 | + std::array<std::string, NUM_SCREENS> output = parseSatsPerCurrency(37253, CURRENCY_GBP, false); |
| 27 | + TEST_ASSERT_EQUAL_STRING("SATS/GBP", output[0].c_str()); |
| 28 | + TEST_ASSERT_EQUAL_STRING("2", output[NUM_SCREENS - 4].c_str()); |
| 29 | + TEST_ASSERT_EQUAL_STRING("6", output[NUM_SCREENS - 3].c_str()); |
| 30 | + TEST_ASSERT_EQUAL_STRING("8", output[NUM_SCREENS - 2].c_str()); |
| 31 | + TEST_ASSERT_EQUAL_STRING("4", output[NUM_SCREENS - 1].c_str()); |
| 32 | +} |
21 | 33 |
|
22 |
| -void test_SixCharacterBlockHeight(void) { |
| 34 | +void test_SixCharacterBlockHeight(void) |
| 35 | +{ |
23 | 36 | std::array<std::string, NUM_SCREENS> output = parseBlockHeight(999999);
|
24 | 37 | TEST_ASSERT_EQUAL_STRING("BLOCK/HEIGHT", output[0].c_str());
|
25 | 38 | TEST_ASSERT_EQUAL_STRING("9", output[1].c_str());
|
26 | 39 | }
|
27 | 40 |
|
28 |
| -void test_SevenCharacterBlockHeight(void) { |
| 41 | +void test_SevenCharacterBlockHeight(void) |
| 42 | +{ |
29 | 43 | std::array<std::string, NUM_SCREENS> output = parseBlockHeight(1000000);
|
30 | 44 | TEST_ASSERT_EQUAL_STRING("1", output[0].c_str());
|
31 | 45 | TEST_ASSERT_EQUAL_STRING("0", output[1].c_str());
|
32 | 46 | }
|
33 | 47 |
|
34 |
| -void test_FeeRateDisplay(void) { |
| 48 | +void test_FeeRateDisplay(void) |
| 49 | +{ |
35 | 50 | uint testValue = 21;
|
36 | 51 | std::array<std::string, NUM_SCREENS> output = parseBlockFees(static_cast<std::uint16_t>(testValue));
|
37 | 52 | TEST_ASSERT_EQUAL_STRING("FEE/RATE", output[0].c_str());
|
38 |
| - TEST_ASSERT_EQUAL_STRING("2", output[NUM_SCREENS-3].c_str()); |
39 |
| - TEST_ASSERT_EQUAL_STRING("1", output[NUM_SCREENS-2].c_str()); |
40 |
| - TEST_ASSERT_EQUAL_STRING("sat/vB", output[NUM_SCREENS-1].c_str()); |
| 53 | + TEST_ASSERT_EQUAL_STRING("2", output[NUM_SCREENS - 3].c_str()); |
| 54 | + TEST_ASSERT_EQUAL_STRING("1", output[NUM_SCREENS - 2].c_str()); |
| 55 | + TEST_ASSERT_EQUAL_STRING("sat/vB", output[NUM_SCREENS - 1].c_str()); |
41 | 56 | }
|
42 | 57 |
|
43 |
| - |
44 |
| -void test_PriceOf100kusd(void) { |
| 58 | +void test_PriceOf100kusd(void) |
| 59 | +{ |
45 | 60 | std::array<std::string, NUM_SCREENS> output = parsePriceData(100000, '$');
|
46 | 61 | TEST_ASSERT_EQUAL_STRING("$", output[0].c_str());
|
47 | 62 | TEST_ASSERT_EQUAL_STRING("1", output[1].c_str());
|
48 | 63 | }
|
49 | 64 |
|
50 |
| -void test_PriceOf1MillionUsd(void) { |
| 65 | +void test_PriceOf1MillionUsd(void) |
| 66 | +{ |
51 | 67 | std::array<std::string, NUM_SCREENS> output = parsePriceData(1000000, '$');
|
52 | 68 | TEST_ASSERT_EQUAL_STRING("BTC/USD", output[0].c_str());
|
53 |
| - |
54 |
| - TEST_ASSERT_EQUAL_STRING("1", output[NUM_SCREENS-5].c_str()); |
55 |
| - TEST_ASSERT_EQUAL_STRING(".", output[NUM_SCREENS-4].c_str()); |
56 |
| - TEST_ASSERT_EQUAL_STRING("0", output[NUM_SCREENS-3].c_str()); |
57 |
| - TEST_ASSERT_EQUAL_STRING("0", output[NUM_SCREENS-2].c_str()); |
58 |
| - TEST_ASSERT_EQUAL_STRING("M", output[NUM_SCREENS-1].c_str()); |
| 69 | + |
| 70 | + TEST_ASSERT_EQUAL_STRING("1", output[NUM_SCREENS - 5].c_str()); |
| 71 | + TEST_ASSERT_EQUAL_STRING(".", output[NUM_SCREENS - 4].c_str()); |
| 72 | + TEST_ASSERT_EQUAL_STRING("0", output[NUM_SCREENS - 3].c_str()); |
| 73 | + TEST_ASSERT_EQUAL_STRING("0", output[NUM_SCREENS - 2].c_str()); |
| 74 | + TEST_ASSERT_EQUAL_STRING("M", output[NUM_SCREENS - 1].c_str()); |
59 | 75 | }
|
60 | 76 |
|
61 |
| -void test_McapLowerUsd(void) { |
| 77 | +void test_McapLowerUsd(void) |
| 78 | +{ |
62 | 79 | std::array<std::string, NUM_SCREENS> output = parseMarketCap(810000, 26000, '$', true);
|
63 | 80 | TEST_ASSERT_EQUAL_STRING("USD/MCAP", output[0].c_str());
|
64 | 81 |
|
65 |
| -// TEST_ASSERT_EQUAL_STRING("$", output[NUM_SCREENS-6].c_str()); |
66 |
| - TEST_ASSERT_EQUAL_STRING("$", output[NUM_SCREENS-5].c_str()); |
67 |
| - TEST_ASSERT_EQUAL_STRING("5", output[NUM_SCREENS-4].c_str()); |
68 |
| - TEST_ASSERT_EQUAL_STRING("0", output[NUM_SCREENS-3].c_str()); |
69 |
| - TEST_ASSERT_EQUAL_STRING("7", output[NUM_SCREENS-2].c_str()); |
70 |
| - TEST_ASSERT_EQUAL_STRING("B", output[NUM_SCREENS-1].c_str()); |
| 82 | + // TEST_ASSERT_EQUAL_STRING("$", output[NUM_SCREENS-6].c_str()); |
| 83 | + TEST_ASSERT_EQUAL_STRING("$", output[NUM_SCREENS - 5].c_str()); |
| 84 | + TEST_ASSERT_EQUAL_STRING("5", output[NUM_SCREENS - 4].c_str()); |
| 85 | + TEST_ASSERT_EQUAL_STRING("0", output[NUM_SCREENS - 3].c_str()); |
| 86 | + TEST_ASSERT_EQUAL_STRING("7", output[NUM_SCREENS - 2].c_str()); |
| 87 | + TEST_ASSERT_EQUAL_STRING("B", output[NUM_SCREENS - 1].c_str()); |
71 | 88 | }
|
72 | 89 |
|
73 |
| -void test_Mcap1TrillionUsd(void) { |
| 90 | +void test_Mcap1TrillionUsd(void) |
| 91 | +{ |
74 | 92 | std::array<std::string, NUM_SCREENS> output = parseMarketCap(831000, 52000, '$', true);
|
75 | 93 | TEST_ASSERT_EQUAL_STRING("USD/MCAP", output[0].c_str());
|
76 | 94 |
|
77 |
| - TEST_ASSERT_EQUAL_STRING("$", output[NUM_SCREENS-6].c_str()); |
78 |
| - TEST_ASSERT_EQUAL_STRING("1", output[NUM_SCREENS-5].c_str()); |
79 |
| - TEST_ASSERT_EQUAL_STRING(".", output[NUM_SCREENS-4].c_str()); |
80 |
| - TEST_ASSERT_EQUAL_STRING("0", output[NUM_SCREENS-3].c_str()); |
81 |
| - TEST_ASSERT_EQUAL_STRING("2", output[NUM_SCREENS-2].c_str()); |
82 |
| - TEST_ASSERT_EQUAL_STRING("T", output[NUM_SCREENS-1].c_str()); |
| 95 | + TEST_ASSERT_EQUAL_STRING("$", output[NUM_SCREENS - 6].c_str()); |
| 96 | + TEST_ASSERT_EQUAL_STRING("1", output[NUM_SCREENS - 5].c_str()); |
| 97 | + TEST_ASSERT_EQUAL_STRING(".", output[NUM_SCREENS - 4].c_str()); |
| 98 | + TEST_ASSERT_EQUAL_STRING("0", output[NUM_SCREENS - 3].c_str()); |
| 99 | + TEST_ASSERT_EQUAL_STRING("2", output[NUM_SCREENS - 2].c_str()); |
| 100 | + TEST_ASSERT_EQUAL_STRING("T", output[NUM_SCREENS - 1].c_str()); |
83 | 101 | }
|
84 | 102 |
|
85 |
| -void test_Mcap1TrillionEur(void) { |
86 |
| - std::array<std::string, NUM_SCREENS> output = parseMarketCap(831000, 52000, '[', true); |
| 103 | +void test_Mcap1TrillionEur(void) |
| 104 | +{ |
| 105 | + std::array<std::string, NUM_SCREENS> output = parseMarketCap(831000, 52000, CURRENCY_EUR, true); |
87 | 106 | TEST_ASSERT_EQUAL_STRING("EUR/MCAP", output[0].c_str());
|
88 |
| - TEST_ASSERT_EQUAL_STRING("[", output[NUM_SCREENS-6].c_str()); |
89 |
| - TEST_ASSERT_EQUAL_STRING("1", output[NUM_SCREENS-5].c_str()); |
90 |
| - TEST_ASSERT_EQUAL_STRING(".", output[NUM_SCREENS-4].c_str()); |
91 |
| - TEST_ASSERT_EQUAL_STRING("0", output[NUM_SCREENS-3].c_str()); |
92 |
| - TEST_ASSERT_EQUAL_STRING("2", output[NUM_SCREENS-2].c_str()); |
93 |
| - TEST_ASSERT_EQUAL_STRING("T", output[NUM_SCREENS-1].c_str()); |
| 107 | + TEST_ASSERT_TRUE(CURRENCY_EUR == output[NUM_SCREENS - 6].c_str()[0]); |
| 108 | + TEST_ASSERT_EQUAL_STRING("1", output[NUM_SCREENS - 5].c_str()); |
| 109 | + TEST_ASSERT_EQUAL_STRING(".", output[NUM_SCREENS - 4].c_str()); |
| 110 | + TEST_ASSERT_EQUAL_STRING("0", output[NUM_SCREENS - 3].c_str()); |
| 111 | + TEST_ASSERT_EQUAL_STRING("2", output[NUM_SCREENS - 2].c_str()); |
| 112 | + TEST_ASSERT_EQUAL_STRING("T", output[NUM_SCREENS - 1].c_str()); |
| 113 | +} |
| 114 | + |
| 115 | +void test_Mcap1TrillionJpy(void) |
| 116 | +{ |
| 117 | + std::array<std::string, NUM_SCREENS> output = parseMarketCap(831000, 52000, CURRENCY_JPY, true); |
| 118 | + TEST_ASSERT_EQUAL_STRING("JPY/MCAP", output[0].c_str()); |
| 119 | + TEST_ASSERT_TRUE(CURRENCY_JPY == output[NUM_SCREENS - 6].c_str()[0]); |
| 120 | + TEST_ASSERT_EQUAL_STRING("1", output[NUM_SCREENS - 5].c_str()); |
| 121 | + TEST_ASSERT_EQUAL_STRING(".", output[NUM_SCREENS - 4].c_str()); |
| 122 | + TEST_ASSERT_EQUAL_STRING("0", output[NUM_SCREENS - 3].c_str()); |
| 123 | + TEST_ASSERT_EQUAL_STRING("2", output[NUM_SCREENS - 2].c_str()); |
| 124 | + TEST_ASSERT_EQUAL_STRING("T", output[NUM_SCREENS - 1].c_str()); |
94 | 125 | }
|
95 | 126 |
|
96 | 127 | // not needed when using generate_test_runner.rb
|
97 |
| -int runUnityTests(void) { |
| 128 | +int runUnityTests(void) |
| 129 | +{ |
98 | 130 | UNITY_BEGIN();
|
99 | 131 | RUN_TEST(test_CorrectSatsPerDollarConversion);
|
| 132 | + RUN_TEST(test_CorrectSatsPerPoundConversion); |
100 | 133 | RUN_TEST(test_SixCharacterBlockHeight);
|
101 | 134 | RUN_TEST(test_SevenCharacterBlockHeight);
|
102 | 135 | RUN_TEST(test_FeeRateDisplay);
|
103 | 136 | RUN_TEST(test_PriceOf100kusd);
|
104 | 137 | RUN_TEST(test_McapLowerUsd);
|
105 | 138 | RUN_TEST(test_Mcap1TrillionUsd);
|
106 | 139 | RUN_TEST(test_Mcap1TrillionEur);
|
107 |
| - //RUN_TEST(test_Mcap1MillionEur); |
| 140 | + RUN_TEST(test_Mcap1TrillionJpy); |
108 | 141 |
|
109 | 142 | return UNITY_END();
|
110 | 143 | }
|
111 | 144 |
|
112 |
| -int main(void) { |
113 |
| - return runUnityTests(); |
| 145 | +int main(void) |
| 146 | +{ |
| 147 | + return runUnityTests(); |
114 | 148 | }
|
115 | 149 |
|
116 |
| -extern "C" void app_main() { |
117 |
| - runUnityTests(); |
| 150 | +extern "C" void app_main() |
| 151 | +{ |
| 152 | + runUnityTests(); |
118 | 153 | }
|
0 commit comments