2011-01-01 17:33:42 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* _ _ ____ _
|
|
|
|
* Project ___| | | | _ \| |
|
|
|
|
* / __| | | | |_) | |
|
|
|
|
* | (__| |_| | _ <| |___
|
|
|
|
* \___|\___/|_| \_\_____|
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "test.h"
|
|
|
|
|
2011-01-03 23:47:34 +01:00
|
|
|
#define fail_if(expr, msg) \
|
|
|
|
if(expr) { \
|
|
|
|
fprintf(stderr, "%s:%d Assertion '%s' met: %s" , \
|
|
|
|
__FILE__, __LINE__, #expr, msg); \
|
|
|
|
unitfail++; \
|
|
|
|
}
|
|
|
|
|
2011-01-01 17:33:42 +01:00
|
|
|
#define fail_unless(expr, msg) \
|
|
|
|
if(!(expr)) { \
|
|
|
|
fprintf(stderr, "%s:%d Assertion '%s' failed: %s" , \
|
|
|
|
__FILE__, __LINE__, #expr, msg); \
|
|
|
|
unitfail++; \
|
|
|
|
}
|
|
|
|
|
|
|
|
extern int unitfail;
|
|
|
|
|
|
|
|
#define UNITTEST_START \
|
|
|
|
int test(char *unused) \
|
|
|
|
{ \
|
|
|
|
(void)unused; \
|
2011-01-03 23:47:34 +01:00
|
|
|
unit_setup(); \
|
|
|
|
{
|
2011-01-01 17:33:42 +01:00
|
|
|
|
|
|
|
#define UNITTEST_STOP \
|
2011-01-03 23:47:34 +01:00
|
|
|
} \
|
2011-01-01 17:33:42 +01:00
|
|
|
unit_stop(); \
|
|
|
|
return unitfail; \
|
|
|
|
}
|
|
|
|
|