mirror of
https://github.com/curl/curl.git
synced 2025-01-12 13:55:11 +08:00
35e1d6538a
This is the first approach at doing fairly clean and easy to write and debug unit tests.
32 lines
1.0 KiB
C
32 lines
1.0 KiB
C
/*****************************************************************************
|
|
* _ _ ____ _
|
|
* Project ___| | | | _ \| |
|
|
* / __| | | | |_) | |
|
|
* | (__| |_| | _ <| |___
|
|
* \___|\___/|_| \_\_____|
|
|
*
|
|
*/
|
|
|
|
#include "test.h"
|
|
|
|
#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; \
|
|
unit_setup();
|
|
|
|
#define UNITTEST_STOP \
|
|
unit_stop(); \
|
|
return unitfail; \
|
|
}
|
|
|