2023-11-28 00:30:36 +00:00
|
|
|
#include <data_handler.hpp>
|
|
|
|
#include <unity.h>
|
|
|
|
|
|
|
|
void setUp(void) {
|
|
|
|
// set stuff up here
|
|
|
|
}
|
|
|
|
|
|
|
|
void tearDown(void) {
|
|
|
|
// clean stuff up here
|
|
|
|
}
|
|
|
|
|
2023-11-28 01:05:04 +00:00
|
|
|
void test_CorrectSatsPerDollarConversion(void) {
|
2024-03-10 11:35:20 +00:00
|
|
|
std::array<std::string, NUM_SCREENS> output = parseSatsPerCurrency(37253, '$', false);
|
2023-11-28 00:30:36 +00:00
|
|
|
TEST_ASSERT_EQUAL_STRING("MSCW/TIME", output[0].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING("2", output[NUM_SCREENS-4].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING("6", output[NUM_SCREENS-3].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING("8", output[NUM_SCREENS-2].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING("4", output[NUM_SCREENS-1].c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-11-28 01:05:04 +00:00
|
|
|
void test_SixCharacterBlockHeight(void) {
|
2023-11-28 00:30:36 +00:00
|
|
|
std::array<std::string, NUM_SCREENS> output = parseBlockHeight(999999);
|
|
|
|
TEST_ASSERT_EQUAL_STRING("BLOCK/HEIGHT", output[0].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING("9", output[1].c_str());
|
|
|
|
}
|
|
|
|
|
2023-11-28 01:05:04 +00:00
|
|
|
void test_SevenCharacterBlockHeight(void) {
|
2023-11-28 00:30:36 +00:00
|
|
|
std::array<std::string, NUM_SCREENS> output = parseBlockHeight(1000000);
|
|
|
|
TEST_ASSERT_EQUAL_STRING("1", output[0].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING("0", output[1].c_str());
|
|
|
|
}
|
|
|
|
|
2023-11-28 01:05:04 +00:00
|
|
|
void test_PriceOf100kusd(void) {
|
2023-11-28 00:30:36 +00:00
|
|
|
std::array<std::string, NUM_SCREENS> output = parsePriceData(100000, '$');
|
|
|
|
TEST_ASSERT_EQUAL_STRING("$", output[0].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING("1", output[1].c_str());
|
|
|
|
}
|
|
|
|
|
2023-11-28 01:05:04 +00:00
|
|
|
void test_PriceOf1MillionUsd(void) {
|
2023-11-28 00:30:36 +00:00
|
|
|
std::array<std::string, NUM_SCREENS> output = parsePriceData(1000000, '$');
|
2023-11-28 01:05:04 +00:00
|
|
|
TEST_ASSERT_EQUAL_STRING("BTC/USD", output[0].c_str());
|
2024-03-10 11:35:20 +00:00
|
|
|
|
|
|
|
TEST_ASSERT_EQUAL_STRING("1", output[NUM_SCREENS-5].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING(".", output[NUM_SCREENS-4].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING("0", output[NUM_SCREENS-3].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING("0", output[NUM_SCREENS-2].c_str());
|
2023-11-28 01:05:04 +00:00
|
|
|
TEST_ASSERT_EQUAL_STRING("M", output[NUM_SCREENS-1].c_str());
|
2023-11-28 00:30:36 +00:00
|
|
|
}
|
|
|
|
|
2024-03-10 11:35:20 +00:00
|
|
|
void test_McapLowerUsd(void) {
|
|
|
|
std::array<std::string, NUM_SCREENS> output = parseMarketCap(810000, 26000, '$', true);
|
|
|
|
TEST_ASSERT_EQUAL_STRING("USD/MCAP", output[0].c_str());
|
|
|
|
|
|
|
|
// TEST_ASSERT_EQUAL_STRING("$", output[NUM_SCREENS-6].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING("$", output[NUM_SCREENS-5].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING("5", output[NUM_SCREENS-4].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING("0", output[NUM_SCREENS-3].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING("7", output[NUM_SCREENS-2].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING("B", output[NUM_SCREENS-1].c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
void test_Mcap1TrillionUsd(void) {
|
|
|
|
std::array<std::string, NUM_SCREENS> output = parseMarketCap(831000, 52000, '$', true);
|
|
|
|
TEST_ASSERT_EQUAL_STRING("USD/MCAP", output[0].c_str());
|
|
|
|
|
|
|
|
TEST_ASSERT_EQUAL_STRING("$", output[NUM_SCREENS-6].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING("1", output[NUM_SCREENS-5].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING(".", output[NUM_SCREENS-4].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING("0", output[NUM_SCREENS-3].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING("2", output[NUM_SCREENS-2].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING("T", output[NUM_SCREENS-1].c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
void test_Mcap1TrillionEur(void) {
|
|
|
|
std::array<std::string, NUM_SCREENS> output = parseMarketCap(831000, 52000, '[', true);
|
|
|
|
TEST_ASSERT_EQUAL_STRING("EUR/MCAP", output[0].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING("[", output[NUM_SCREENS-6].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING("1", output[NUM_SCREENS-5].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING(".", output[NUM_SCREENS-4].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING("0", output[NUM_SCREENS-3].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING("2", output[NUM_SCREENS-2].c_str());
|
|
|
|
TEST_ASSERT_EQUAL_STRING("T", output[NUM_SCREENS-1].c_str());
|
|
|
|
}
|
|
|
|
|
2023-11-28 00:30:36 +00:00
|
|
|
// not needed when using generate_test_runner.rb
|
|
|
|
int runUnityTests(void) {
|
|
|
|
UNITY_BEGIN();
|
2023-11-28 01:05:04 +00:00
|
|
|
RUN_TEST(test_CorrectSatsPerDollarConversion);
|
|
|
|
RUN_TEST(test_SixCharacterBlockHeight);
|
|
|
|
RUN_TEST(test_SevenCharacterBlockHeight);
|
|
|
|
RUN_TEST(test_PriceOf100kusd);
|
2024-03-10 11:35:20 +00:00
|
|
|
RUN_TEST(test_McapLowerUsd);
|
|
|
|
RUN_TEST(test_Mcap1TrillionUsd);
|
|
|
|
RUN_TEST(test_Mcap1TrillionEur);
|
|
|
|
//RUN_TEST(test_Mcap1MillionEur);
|
2023-11-28 00:30:36 +00:00
|
|
|
|
|
|
|
return UNITY_END();
|
|
|
|
}
|
|
|
|
|
2023-11-28 01:05:04 +00:00
|
|
|
int main(void) {
|
|
|
|
return runUnityTests();
|
|
|
|
}
|
|
|
|
|
2023-11-28 00:30:36 +00:00
|
|
|
extern "C" void app_main() {
|
|
|
|
runUnityTests();
|
|
|
|
}
|