#pragma once // Minimal test helper. Tests print FAIL lines per broken check and a PASS // line with counts, and return nonzero when any check fails. #include struct TestCtx { int checks = 0; int failures = 0; }; #define CHECK(ctx, cond) \ do { \ ++(ctx).checks; \ if (!(cond)) { \ ++(ctx).failures; \ std::printf("FAIL %s:%d: %s\n", __FILE__, __LINE__, #cond); \ } \ } while (0) inline int test_summary(TestCtx& ctx, const char* name) { if (ctx.failures == 0) { std::printf("PASS %s (%d checks)\n", name, ctx.checks); return 0; } std::printf("FAIL %s (%d of %d checks failed)\n", name, ctx.failures, ctx.checks); return 1; }