/* Assertion harness for the C tests: every check reports, nothing aborts, and * the process exit status is the verdict. Keeping going after a failure is * deliberate; when a numeric change breaks several gates at once, the full * list localises it faster than the first failure alone. */ #ifndef PYSEG_TEST_UTIL_H #define PYSEG_TEST_UTIL_H #include static int test_failures; static int test_checks; #define TEST_ASSERT(cond, ...) \ do { \ ++test_checks; \ if (!(cond)) { \ ++test_failures; \ fprintf(stderr, "FAIL %s:%d: ", __FILE__, __LINE__); \ fprintf(stderr, __VA_ARGS__); \ fputc('\n', stderr); \ } \ } while (0) #define TEST_REPORT() \ (fprintf(stderr, "%s: %d checks, %d failed\n", __FILE__, test_checks, test_failures), \ test_failures ? 1 : 0) #endif /* PYSEG_TEST_UTIL_H */