/** * @file test_main.cpp * @brief Runner for the fast headless suites: unit + integration. * * The sketch is included as a single translation unit (the same trick the * emulator host uses), which gives the tests direct access to the sketch's * internal statics — no refactor needed to make the game testable. * * Deterministic: no wall-clock waits (tests step the 20 Hz sim tick by tick) * and a fixed RNG seed. Rendering and pixel assertions belong to the E2E * binary (e2e_tests.cpp). */ #include "harness.h" // pull in the whole sketch as a single translation unit (-DAPP_INO) #include APP_INO #include "unit_tests.h" #include "integration_tests.h" int main(int argc, char **argv) { // optional filter: ./NetDeck-tests unit | ./NetDeck-tests int const char *filter = argc > 1 ? argv[1] : nullptr; test::captureSerial(); std::srand(0xC0FFEE); int run = 0; for (const auto &c : test::cases()) { if (filter && std::strncmp(c.name, filter, std::strlen(filter)) != 0) continue; test::g_current = c.name; size_t slash = test::g_current.find('/'); test::g_group = slash == std::string::npos ? "" : test::g_current.substr(0, slash); std::printf("RUN %s\n", c.name); c.fn(); run++; } std::printf("\n%s: %d test%s, %d failure%s\n", run ? "DONE" : "NO TESTS MATCHED FILTER", run, run == 1 ? "" : "s", test::g_failures, test::g_failures == 1 ? "" : "s"); return (run > 0 && test::g_failures == 0) ? 0 : 1; }