aboutsummaryrefslogtreecommitdiff
path: root/tests/test_util.h
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-09-13 20:03:39 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-09-13 20:13:28 +0200
commit64c3a1b528a88b4ae21bf3cbcff2537200477806 (patch)
tree85da00748d7bbb5036aeb5a7a4b60b5abf75aeea /tests/test_util.h
downloadpyseg-64c3a1b528a88b4ae21bf3cbcff2537200477806.tar.gz
pyseg-64c3a1b528a88b4ae21bf3cbcff2537200477806.zip
Init
Diffstat (limited to 'tests/test_util.h')
-rw-r--r--tests/test_util.h29
1 files changed, 29 insertions, 0 deletions
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 <stdio.h>
+
+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 */