X-Git-Url: https://git.stderr.nl/gitweb?p=projects%2Fchimara%2Fchimara.git;a=blobdiff_plain;f=tests%2Funit%2Fglkunit.h;fp=tests%2Funit%2Fglkunit.h;h=3828987b739c2fc6b73f20e8d1bc3f5cc09dbcd8;hp=0000000000000000000000000000000000000000;hb=ad091d02678a632f0f91f26072bbec29eba4c66e;hpb=9b7445bd66c18e85b0d312f0c12a5050fe528073 diff --git a/tests/unit/glkunit.h b/tests/unit/glkunit.h new file mode 100644 index 0000000..3828987 --- /dev/null +++ b/tests/unit/glkunit.h @@ -0,0 +1,25 @@ +#ifndef GLKUNIT_H +#define GLKUNIT_H + +#include + +#define _BEGIN do { +#define _END } while(0); + +/* msg must be a string literal */ +#define _ASSERT(expr, msg, ...) _BEGIN \ + if( !(expr) ) { \ + fprintf(stderr, "Assertion failed: " msg "\n", __VA_ARGS__); \ + return 0; \ + } _END + +#define SUCCEED _BEGIN return 1; _END +#define ASSERT(expr) _ASSERT(expr, "%s", #expr) +#define ASSERT_EQUAL(expected, actual) _ASSERT((expected) == (actual), "%s == %s", #expected, #actual); + +struct TestDescription { + char *name; + int (*testfunc)(void); +}; + +#endif /* GLKUNIT_H */