mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-08-16 03:03:44 +08:00
75d590fb90
* replace catch2 tests * lil more * lil more * rm dep!
26 lines
672 B
C++
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;
|
|
}
|
|
}
|