0ad/source/lib/self_test.h
janwas ed5041a301 some infrastructure for self-tests: gets rid of boilerplate code.
squelch debug asserts during self-tests to avoid warning about intended
errors (passing invalid data into functions to test their error
reporting)

This was SVN commit r2646.
2005-09-02 02:47:25 +00:00

18 lines
513 B
C

#ifndef SELF_TEST_ENABLED
#define SELF_TEST_ENABLED 1
#endif
// each test case should use this to verify conditions.
// note: could also stringize condition and display that, but it'd require
// macro magic (stringize+prepend L) and we already get file+line.
#define TEST(condition) STMT(\
if(!(condition))\
DISPLAY_ERROR(L"Self-test failed");\
)
extern bool self_test_active;
extern int run_self_test(void(*test_func)());
#define RUN_SELF_TEST static int dummy = run_self_test(self_test)