#pragma once // Shared test support for the living example suite. Not a test itself: every // test file owns one main() and uses these helpers for loud assertions. #include #include #include #include "app/App.hpp" #include "google/client.h" #include "fw/TestClient.hpp" namespace molo::example::test { inline int g_failures = 0; inline void check(bool cond, const std::string& what) { if (cond) { std::cout << " ok: " << what << "\n"; } else { ++g_failures; std::cout << " FAIL: " << what << "\n"; } } inline bool contains(const std::string& hay, const std::string& needle) { return hay.find(needle) != std::string::npos; } inline int finish(const std::string& name) { if (g_failures == 0) { std::cout << "PASS: " << name << "\n"; return 0; } std::cout << "FAIL: " << name << " (" << g_failures << " failures)\n"; return 1; } struct Fixture { molo::example::app::Services services; std::shared_ptr app; std::shared_ptr client; Fixture() : Fixture(nullptr) {} // A scripted Google client can be injected (see support/GoogleRig.hpp). // Null builds the client from the environment like production. Scripted // clients default to the classic cloud wire paths; pass a backend to test // the Gemini ones. explicit Fixture(std::shared_ptr google, std::optional backend = std::nullopt) { if (google && !backend) backend = molo::google::VoiceBackend::kCloud; services.voice_backend = backend; services.google = std::move(google); app = molo::example::app::build_application(services); client = std::make_shared(app); } }; } // namespace molo::example::test