~kennylevinsen/seatd

seatd/include/test.h -rw-r--r-- 916 bytes
355cc9c9Kenny Levinsen meson: Support building builtin without seatd 19 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef _TEST_H
#define _TEST_H

char *__curtestname = "<none>";

#define test_run(func)                      \
	do {                                \
		char *orig = __curtestname; \
		__curtestname = #func;      \
		func();                     \
		__curtestname = orig;       \
	} while (0)

#define test_assert(cond)                                                                          \
	do {                                                                                       \
		if (!(cond)) {                                                                     \
			fprintf(stderr, "%s:%d: %s: test_assert failed: %s\n", __FILE__, __LINE__, \
				__curtestname, #cond);                                             \
			abort();                                                                   \
		}                                                                                  \
	} while (0)

#endif