-
Notifications
You must be signed in to change notification settings - Fork 7
/
c-tap-test.h
62 lines (54 loc) · 1.17 KB
/
c-tap-test.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* TAP format macros. */
static int tap_count;
static int tap_todo;
static int tap_fail;
#define ENDLINE { \
if (tap_todo) { \
printf (" # TODO\n"); \
} \
else { \
printf ("\n"); \
} \
}
#define TAP_TEST(x) { \
tap_count++; \
if (! (x)) { \
if (! tap_todo) { \
tap_fail++; \
} \
printf ("not "); \
} \
printf ("ok %d - %s", tap_count, #x); \
ENDLINE; \
}
#define TAP_TEST_EQUAL(x,y) { \
int xval = (int) x; \
int yval = (int) y; \
tap_count++; \
if (! (xval == yval)) { \
if (! tap_todo) { \
tap_fail++; \
} \
printf ("not "); \
} \
printf ("ok %d - %s (%d) == %s (%d)", tap_count, \
#x, xval, #y, yval); \
ENDLINE; \
}
#define TAP_TEST_MSG(x,msg,args...) { \
tap_count++; \
if (! (x)) { \
if (! tap_todo) { \
tap_fail++; \
} \
printf ("not "); \
} \
printf ("ok %d - ", tap_count); \
printf (msg, ## args); \
ENDLINE; \
}
#define TODO tap_todo = 1
#define END_TODO tap_todo = 0
#define TAP_PLAN { \
printf ("1..%d\n", tap_count); \
}