diff --git a/tests/utest_assert.h b/tests/utest_assert.h new file mode 100644 index 0000000..cb5ff17 --- /dev/null +++ b/tests/utest_assert.h @@ -0,0 +1,23 @@ +/* Adapted from minunit + * See : http://www.jera.com/techinfo/jtns/jtn002.html + * http://c.learncodethehardway.org/book/ex30.html + */ + +#ifndef UTEST_ASSERT_H +#define UTEST_ASSERT_H + +#include + +#define UTEST_ASSERT(test) \ + if (!(test)) {\ + printf(" ERROR : %s (line = %i, file = %s)", #test, __LINE__, __FILE__);\ + return #test;\ + } + +#define UTEST_ASSERT_MSG(test, message) \ + if (!(test)) {\ + printf(message);\ + return message;\ + } + +#endif /* UTEST_ASSERT_H */ diff --git a/tests/utest_lib.h b/tests/utest_lib.h index 9df4137..10af19a 100644 --- a/tests/utest_lib.h +++ b/tests/utest_lib.h @@ -6,17 +6,11 @@ #ifndef UTEST_LIB_H #define UTEST_LIB_H -#include +#include "utest_assert.h" + #include #define UTEST_SUITE_START() const char* message = NULL - -#define UTEST_ASSERT(test) if (!(test))\ - { printf(" ERROR : %s (line = %i, file = %s)", #test, __LINE__, __FILE__);\ - return #test; } - -#define UTEST_ASSERT_MSG(test, message) if (!(test))\ - { printf(message); return message; } #define UTEST_RUN(test) printf("\n-----%s", " " #test); \ message = test();\