mirror of
https://github.com/curl/curl.git
synced 2026-07-24 07:47:19 +03:00
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.
This commit is contained in:
parent
5c42b2ceae
commit
83e9fb21aa
1 changed files with 10 additions and 1 deletions
|
|
@ -9,6 +9,13 @@
|
||||||
|
|
||||||
#include "test.h"
|
#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) \
|
#define fail_unless(expr, msg) \
|
||||||
if(!(expr)) { \
|
if(!(expr)) { \
|
||||||
fprintf(stderr, "%s:%d Assertion '%s' failed: %s" , \
|
fprintf(stderr, "%s:%d Assertion '%s' failed: %s" , \
|
||||||
|
|
@ -22,9 +29,11 @@ extern int unitfail;
|
||||||
int test(char *unused) \
|
int test(char *unused) \
|
||||||
{ \
|
{ \
|
||||||
(void)unused; \
|
(void)unused; \
|
||||||
unit_setup();
|
unit_setup(); \
|
||||||
|
{
|
||||||
|
|
||||||
#define UNITTEST_STOP \
|
#define UNITTEST_STOP \
|
||||||
|
} \
|
||||||
unit_stop(); \
|
unit_stop(); \
|
||||||
return unitfail; \
|
return unitfail; \
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue