#include "framework.hpp" #include #include #include #include #include namespace cepis::testing { namespace { std::vector>>& registry() { static std::vector>> tests; return tests; } } // namespace void register_test(const char* name, std::function body) { registry().emplace_back(name, std::move(body)); } int run_all() { int failures = 0; for (const auto& [name, body] : registry()) { try { body(); std::cout << "ok " << name << '\n'; } catch (const std::exception& error) { ++failures; std::cout << "FAIL " << name << "\n " << error.what() << '\n'; } catch (...) { ++failures; std::cout << "FAIL " << name << "\n unknown exception\n"; } } std::cout << '\n' << registry().size() << " test(s), " << failures << " failure(s)" << std::endl; return failures == 0 ? 0 : 1; } } // namespace cepis::testing int main() { return cepis::testing::run_all(); }