2015-09-14 16:36:39 +08:00
|
|
|
/* 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 <stdio.h>
|
|
|
|
|
|
|
|
#define UTEST_ASSERT(test) \
|
|
|
|
if (!(test)) {\
|
|
|
|
printf(" ERROR : %s (line = %i, file = %s)", #test, __LINE__, __FILE__);\
|
|
|
|
return #test;\
|
|
|
|
}
|
|
|
|
|
2015-11-06 22:29:05 +08:00
|
|
|
#define UTEST_FAIL(message) \
|
2015-11-19 22:31:18 +08:00
|
|
|
{\
|
|
|
|
printf(" FAIL : %s (line = %i, file = %s)", #message, __LINE__, __FILE__);\
|
|
|
|
return "UTEST_FAIL()";\
|
|
|
|
}
|
2015-11-06 22:29:05 +08:00
|
|
|
|
2015-09-14 16:36:39 +08:00
|
|
|
#define UTEST_ASSERT_MSG(test, message) \
|
|
|
|
if (!(test)) {\
|
|
|
|
printf(message);\
|
|
|
|
return message;\
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* UTEST_ASSERT_H */
|