1
0
mirror of https://github.com/moparisthebest/curl synced 2024-08-13 17:03:50 -04:00
curl/tests/unit/curlcheck.h
Daniel Stenberg 83e9fb21aa curlcheck.h: add fail_if() fix code
The UNITTEST_START and UNITTEST_STOP defines needed to do a new brace
level so that test cases can declare variables fine and still remain
fine C89 code.
2011-01-03 23:47:34 +01:00

41 lines
1.4 KiB
C

/*****************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
*/
#include "test.h"
#define fail_if(expr, msg) \
if(expr) { \
fprintf(stderr, "%s:%d Assertion '%s' met: %s" , \
__FILE__, __LINE__, #expr, msg); \
unitfail++; \
}
#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; \
}