karlos/include/test.h

19 lines
600 B
C

#ifndef KARLOS_TEST_H
#define KARLOS_TEST_H
#define TEST_PANIC(msg) test_fail(__FILE__, __LINE__, msg)
#define TEST_ASSERT(cond) do {\
if (!(cond)) {\
test_fail(__FILE__, __LINE__, #cond); \
} else { \
test_success(__FILE__, __LINE__, #cond); \
} \
} while (0)
#define TEST_UNREACHABLE() TEST_PANIC("unreachable")
// don't use this directly, use the macros above
__attribute__ ((noreturn))
void test_fail(const char *file, unsigned int line, const char *msg);
void test_success(const char *file, unsigned int line, const char *msg);
void printf(const char *restrict fmt, ...);
#endif