#ifndef LILY_TEST_H #define LILY_TEST_H #include /* gives a string like 'some/filename:xxx' */ #define STR_IMP(x) #x #define STR(x) STR_IMP(x) /* define SOURCE_PATH_SIZE to strip away the leading parts of the full compilation path */ #ifndef SOURCE_PATH_SIZE #define LILY_LOCATION "" __FILE__ ":" STR(__LINE__) #else #define LILY_LOCATION (("" __FILE__ ":" STR(__LINE__)) + SOURCE_PATH_SIZE) #endif struct lily_test_result_t { int error; const char *message; const char *location; }; typedef struct lily_test_result_t lily_test; #define LILY_SUCCESS (struct lily_test_result_t){ 0, NULL, NULL } // assertions #define lily_assert_msg(statement, message) do { \ if(!(statement)) { \ return (struct lily_test_result_t){1, (message), LILY_LOCATION}; \ } \ } while(0) #endif