Reformat code.

This commit is contained in:
2026-02-17 13:44:36 -08:00
parent 95a588b0df
commit 337b585ba0
114 changed files with 32253 additions and 16316 deletions

View File

@@ -8,49 +8,61 @@
#include <sstream>
namespace ktet {
struct TestCase {
std::string name;
std::function<void()> fn;
std::string name;
std::function<void()> fn;
};
inline std::vector<TestCase>& registry() {
static std::vector<TestCase> r;
return r;
inline std::vector<TestCase> &
registry()
{
static std::vector<TestCase> r;
return r;
}
struct Registrar {
Registrar(const char* name, std::function<void()> fn) {
registry().push_back(TestCase{std::string(name), std::move(fn)});
}
Registrar(const char *name, std::function<void()> fn)
{
registry().push_back(TestCase{std::string(name), std::move(fn)});
}
};
// Assertions
struct AssertionFailure {
std::string msg;
std::string msg;
};
inline void expect(bool cond, const char* expr, const char* file, int line) {
if (!cond) {
std::cerr << file << ":" << line << ": EXPECT failed: " << expr << "\n";
}
inline void
expect(bool cond, const char *expr, const char *file, int line)
{
if (!cond) {
std::cerr << file << ":" << line << ": EXPECT failed: " << expr << "\n";
}
}
inline void assert_true(bool cond, const char* expr, const char* file, int line) {
if (!cond) {
throw AssertionFailure{std::string(file) + ":" + std::to_string(line) + ": ASSERT failed: " + expr};
}
inline void
assert_true(bool cond, const char *expr, const char *file, int line)
{
if (!cond) {
throw AssertionFailure{std::string(file) + ":" + std::to_string(line) + ": ASSERT failed: " + expr};
}
}
template<typename A, typename B>
inline void assert_eq_impl(const A& a, const B& b, const char* ea, const char* eb, const char* file, int line) {
if (!(a == b)) {
std::ostringstream oss;
oss << file << ":" << line << ": ASSERT_EQ failed: " << ea << " == " << eb;
throw AssertionFailure{oss.str()};
}
inline void
assert_eq_impl(const A &a, const B &b, const char *ea, const char *eb, const char *file, int line)
{
if (!(a == b)) {
std::ostringstream oss;
oss << file << ":" << line << ": ASSERT_EQ failed: " << ea << " == " << eb;
throw AssertionFailure{oss.str()};
}
}
} // namespace ktet
#define TEST(name) \