cbase 1.46.11
C/C++ Static Template
Loading...
Searching...
No Matches
test_harness.h
Go to the documentation of this file.
1
5#ifndef TEST_HARNESS_H
6#define TEST_HARNESS_H
7
8#include <stdio.h>
9#include <stdlib.h>
10
12static int tests_run = 0;
14static int tests_failed = 0;
15
18#define EXPECT(cond) \
19 do { \
20 if (!(cond)) { \
21 printf(" [FAIL] %s:%d: %s\n", __FILE__, __LINE__, #cond); \
22 tests_failed++; \
23 } \
24 } while (0)
25
27#define EXPECT_STR8_EQ(a, b) EXPECT(str8_match((a), (b)))
28
30#define TEST_CASE(name) static void test_##name(void)
31
33#define RUN_TEST(name) \
34 do { \
35 printf("Running " #name "...\n"); \
36 test_##name(); \
37 tests_run++; \
38 } while (0)
39
40#endif // TEST_HARNESS_H
static int tests_run
Global counter tracking the total number of tests executed.
static int tests_failed
Global counter tracking the total number of tests that failed.