3828987b739c2fc6b73f20e8d1bc3f5cc09dbcd8
[projects/chimara/chimara.git] / tests / unit / glkunit.h
1 #ifndef GLKUNIT_H
2 #define GLKUNIT_H
3
4 #include <stdio.h>
5
6 #define _BEGIN do {
7 #define _END } while(0);
8
9 /* msg must be a string literal */
10 #define _ASSERT(expr, msg, ...) _BEGIN \
11     if( !(expr) ) { \
12         fprintf(stderr, "Assertion failed: " msg "\n", __VA_ARGS__); \
13         return 0; \
14     } _END
15
16 #define SUCCEED _BEGIN return 1; _END
17 #define ASSERT(expr) _ASSERT(expr, "%s", #expr)
18 #define ASSERT_EQUAL(expected, actual) _ASSERT((expected) == (actual), "%s == %s", #expected, #actual);
19
20 struct TestDescription {
21     char *name;
22     int (*testfunc)(void);
23 };
24
25 #endif /* GLKUNIT_H */