From 64c3a1b528a88b4ae21bf3cbcff2537200477806 Mon Sep 17 00:00:00 2001 From: Onur Gündüz Date: Sun, 13 Sep 2026 20:03:39 +0200 Subject: Init --- tests/test_util.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/test_util.h (limited to 'tests/test_util.h') diff --git a/tests/test_util.h b/tests/test_util.h new file mode 100644 index 0000000..1d8c80e --- /dev/null +++ b/tests/test_util.h @@ -0,0 +1,29 @@ +/* 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 */ -- cgit v1.3.1