#include #include #include #include #include "test_bitaxe_parser.hpp" void setUp(void) { // Setup code } void tearDown(void) { // Cleanup code } void test_bitaxe_api(void) { JsonDocument doc; std::ifstream file("test/test_json/data/bitaxe_2_3_0.json"); std::string json((std::istreambuf_iterator(file)), std::istreambuf_iterator()); DeserializationError error = deserializeJson(doc, json); std::string bitaxeHashrate = std::to_string(static_cast(std::round(doc["hashRate"].as()))); std::string bitaxeBestDiff = doc["bestDiff"].as(); String testInput = "{\"test\":\"data\"}"; bitaxeParseApiResponse(testInput); TEST_ASSERT_EQUAL_STRING(bitaxeHashrate.c_str(), std::string("690").c_str()); } void test_braiins_api(void) { JsonDocument doc; std::ifstream file("test/test_json/data/20241219-test-braiins.json"); std::string json((std::istreambuf_iterator(file)), std::istreambuf_iterator()); DeserializationError error = deserializeJson(doc, json); TEST_ASSERT_EQUAL(DeserializationError::Ok, error.code()); } void test_ocean_api(void) { JsonDocument doc; std::ifstream file("test/test_json/data/20241219-test-ocean-api.json"); std::string json((std::istreambuf_iterator(file)), std::istreambuf_iterator()); DeserializationError error = deserializeJson(doc, json); TEST_ASSERT_EQUAL(DeserializationError::Ok, error.code()); } int main(void) { UNITY_BEGIN(); RUN_TEST(test_bitaxe_api); RUN_TEST(test_braiins_api); RUN_TEST(test_ocean_api); return UNITY_END(); }