diff options
Diffstat (limited to 'lily-test.h')
-rw-r--r-- | lily-test.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lily-test.h b/lily-test.h new file mode 100644 index 0000000..9f166b1 --- /dev/null +++ b/lily-test.h @@ -0,0 +1,32 @@ +#ifndef LILY_TEST_H +#define LILY_TEST_H + +#define lily_test const char * + +struct lily_test_data_t { + int tests_run; + int tests_failed; +}; + +#define LILY_INIT() \ + struct lily_test_data_t lily_test_data = { 0, 0 }; + + +// helper macros to turn numerical constants into strings +#define STR_IMPL(x) #x +#define STR(X) STR_IMPL(x) + + +// assertion macros +#define lily_indent " " +#define lily_assert_msg(statement, message) \ + do { \ + if (!(statement)) \ + return "" message \ + "\n" lily_indent " [" __FILE__ ":" STR(__LINE__) "]"; \ + } while(0) + +#define lily_assert_equal(a, b) lily_assert_msg((a) == (b), "'" #a "' is not equal to '" #b "'") + + +#endif |