11 enum {PASS, FAIL, FAIL_FORCE, ERR, TIMEOUT} status;
21 bool ihct_assert_impl(
bool eval,
ihct_test_result *result,
char *code,
char *file,
24 void ihct_pass_impl(
ihct_test_result *result,
char *file,
unsigned long line);
25 void ihct_fail_impl(
ihct_test_result *result,
char *file,
unsigned long line);
28 void ihct_construct_test_impl(
char *s, ihct_test_proc proc);
31 int ihct_run(
int argc,
char **argv);
35 void ihct_init(
void) __attribute__((constructor(101)));
50 #define IHCT_ASSERT(expr) \
51 if(!ihct_assert_impl(expr, result, #expr, __FILE__, __LINE__)) return
59 #define IHCT_NASSERT(expr) \
60 if(!ihct_assert_impl(!expr, result, "!(" #expr ")", __FILE__, __LINE__)) return
69 #define IHCT_ASSERT_STR(s1, s2) \
70 if(!ihct_assert_impl(!strcmp(s1, s2), result, #s1 " == " #s2, __FILE__, \
79 #define IHCT_NASSERT_STR(s1, s2) \
80 if(!ihct_assert_impl(strcmp(s1, s2), result, #s1 " != " #s2, __FILE__, \
89 do { ihct_pass_impl(result, __FILE__, __LINE__); return; } while(0)
97 do { ihct_fail_impl(result, __FILE__, __LINE__); return; } while(0)
112 #define IHCT_RUN(argc, argv) \
126 #define IHCT_TEST(name) \
127 static void test_##name(ihct_test_result *result); \
128 static void __attribute__((constructor(102))) __construct_test_##name(void) { \
129 ihct_construct_test_impl(#name, &test_##name); \
131 static void test_##name(ihct_test_result *result)
135 #define IHCT_FIXTURE(name) _Static_assert(0, "Fixtures not implemented.")
139 #define IHCT_REQUIRE(...) _Static_assert(0, "Fixture requirements not implemented.")
142 #define TEST(name) IHCT_TEST(name)
143 #define ASSERT(expr) IHCT_ASSERT(expr)
144 #define NASSERT(expr) IHCT_NASSERT(expr)
145 #define ASSERT_STR(s1, s2) IHCT_ASSERT_STR(s1, s2)
146 #define NASSERT_STR(s1, s2) IHCT_NASSERT_STR(s1, s2)
147 #define PASS() IHCT_PASS()
148 #define FAIL() IHCT_FAIL()