#include #include "fgc/ui/UiSnapshot.h" using namespace fgc; TEST_CASE("axisStateLabel maps every state") { CHECK(std::string(axisStateLabel(AxisState::Boot)) == "BOOT"); CHECK(std::string(axisStateLabel(AxisState::Reset)) == "RESET"); CHECK(std::string(axisStateLabel(AxisState::Homing)) == "HOMING"); CHECK(std::string(axisStateLabel(AxisState::Ready)) == "READY"); CHECK(std::string(axisStateLabel(AxisState::Error)) == "ERROR"); CHECK(std::string(axisStateLabel(AxisState::Unknown)) == "----"); } TEST_CASE("axisStateColor signals health") { CHECK(axisStateColor(AxisState::Ready) == UiColor::Green); CHECK(axisStateColor(AxisState::Homing) == UiColor::Yellow); CHECK(axisStateColor(AxisState::Error) == UiColor::Red); CHECK(axisStateColor(AxisState::Boot) == UiColor::Dim); CHECK(axisStateColor(AxisState::Reset) == UiColor::Dim); CHECK(axisStateColor(AxisState::Unknown) == UiColor::Default); } TEST_CASE("formatDegrees: one decimal, sign preserved, degree sign appended") { CHECK(formatDegrees(12.34) == "12.3\xC2\xB0"); CHECK(formatDegrees(-4.0) == "-4.0\xC2\xB0"); CHECK(formatDegrees(0.0) == "0.0\xC2\xB0"); } TEST_CASE("formatTimeAgo: buckets and the never case") { CHECK(formatTimeAgo(10'000, 0) == "\xE2\x80\x94"); // never CHECK(formatTimeAgo(10'000, 7'000) == "3s ago"); // seconds CHECK(formatTimeAgo(200'000, 10'000) == "3m ago"); // minutes CHECK(formatTimeAgo(10'000'000, 1'000'000) == "2h ago"); // hours CHECK(formatTimeAgo(5'000, 9'000) == "0s ago"); // future clamps to 0 } TEST_CASE("pendingSensorsView: all fields absent until drivers land") { SensorsView v = pendingSensorsView(); CHECK_FALSE(v.dht_present); CHECK_FALSE(v.imu_present); CHECK(v.fields.size() >= 2); for (const auto& f : v.fields) { CHECK_FALSE(f.present); CHECK_FALSE(f.label.empty()); } }