7bcb24bab0
All checks were successful
BTClock CI / build (push) Successful in 17m35s
BTClock CI / merge (map[name:btclock_v8 version:esp32s3], 213epd) (push) Successful in 27s
BTClock CI / merge (map[name:btclock_rev_b version:esp32s3], 213epd) (push) Successful in 20s
BTClock CI / merge (map[name:lolin_s3_mini version:esp32s3], 213epd) (push) Successful in 25s
BTClock CI / merge (map[name:lolin_s3_mini version:esp32s3], 29epd) (push) Successful in 19s
BTClock CI / release (push) Successful in 36s
75 lines
1.8 KiB
C++
75 lines
1.8 KiB
C++
#include <utils.hpp>
|
|
#include <unity.h>
|
|
|
|
void test_parseMiningPoolStatsHashRate1dot34TH(void)
|
|
{
|
|
std::string hashrate;
|
|
std::string label;
|
|
std::string output;
|
|
|
|
parseHashrateString("1340000000000", label, output, 4);
|
|
|
|
TEST_ASSERT_EQUAL_STRING_MESSAGE("TH/S", label.c_str(), label.c_str());
|
|
TEST_ASSERT_EQUAL_STRING_MESSAGE("1.34", output.c_str(), output.c_str());
|
|
}
|
|
|
|
void test_parseMiningPoolStatsHashRate645GH(void)
|
|
{
|
|
std::string hashrate = "645000000000";
|
|
std::string label;
|
|
std::string output;
|
|
|
|
parseHashrateString(hashrate, label, output, 4);
|
|
|
|
TEST_ASSERT_EQUAL_STRING_MESSAGE("GH/S", label.c_str(), label.c_str());
|
|
TEST_ASSERT_EQUAL_STRING_MESSAGE("645", output.c_str(), output.c_str());
|
|
}
|
|
|
|
void test_parseMiningPoolStatsHashRateEmpty(void)
|
|
{
|
|
std::string hashrate = "";
|
|
std::string label;
|
|
std::string output;
|
|
|
|
parseHashrateString(hashrate, label, output, 4);
|
|
|
|
TEST_ASSERT_EQUAL_STRING_MESSAGE("H/S", label.c_str(), label.c_str());
|
|
TEST_ASSERT_EQUAL_STRING_MESSAGE("0", output.c_str(), output.c_str());
|
|
}
|
|
|
|
void test_parseMiningPoolStatsHashRateZero(void)
|
|
{
|
|
std::string hashrate = "0";
|
|
std::string label;
|
|
std::string output;
|
|
|
|
parseHashrateString(hashrate, label, output, 4);
|
|
|
|
TEST_ASSERT_EQUAL_STRING_MESSAGE("H/S", label.c_str(), label.c_str());
|
|
TEST_ASSERT_EQUAL_STRING_MESSAGE("0", output.c_str(), output.c_str());
|
|
}
|
|
|
|
|
|
|
|
|
|
// not needed when using generate_test_runner.rb
|
|
int runUnityTests(void)
|
|
{
|
|
UNITY_BEGIN();
|
|
RUN_TEST(test_parseMiningPoolStatsHashRate1dot34TH);
|
|
RUN_TEST(test_parseMiningPoolStatsHashRate645GH);
|
|
RUN_TEST(test_parseMiningPoolStatsHashRateZero);
|
|
RUN_TEST(test_parseMiningPoolStatsHashRateEmpty);
|
|
|
|
return UNITY_END();
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
return runUnityTests();
|
|
}
|
|
|
|
extern "C" void app_main()
|
|
{
|
|
runUnityTests();
|
|
}
|