Files
sunnypilot/openpilot/common/tests/native_test.h
T
Adeeb Shihadeh 75d590fb90 replace catch2 tests for 20% faster builds (#38408)
* replace catch2 tests

* lil more

* lil more

* rm dep!
2026-07-21 22:20:09 -07:00

26 lines
672 B
C++

#pragma once
#include <iostream>
#include <stdexcept>
#include <string>
inline void native_test_check(bool condition, const char *expression, const char *file, int line) {
if (!condition) {
throw std::runtime_error(std::string(file) + ":" + std::to_string(line) + ": check failed: " + expression);
}
}
#define CHECK(condition) native_test_check(static_cast<bool>(condition), #condition, __FILE__, __LINE__)
#define REQUIRE(...) CHECK((__VA_ARGS__))
template <typename Function>
int run_native_test(Function &&function) {
try {
function();
return 0;
} catch (const std::exception &error) {
std::cerr << error.what() << '\n';
return 1;
}
}