blob: b8a72135bead1e81925d4c8ef167f041c04d1761 (
plain) (
blame)
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
|
#ifndef TAP_H
#define TAP_H
#ifdef TIS_INTERPRETER
static int failures = 0;
static int test_count = 0;
static void plan_no_plan(void) { }
static int exit_status() {
if (failures > 255)
failures = 255;
return failures;
}
#define ok(e, ...) do { \
bool _e = (e); \
printf("%sok %d - ", _e ? "" : "not ", ++test_count); \
printf(__VA_ARGS__); \
printf("\n"); \
if (!_e) { \
failures++; \
printf(" Failed test (%s:%s() at line %d)\n", __FILE__, __func__, __LINE__); \
} \
} while (0)
#define skip_if(cond, n, ...) \
if (cond) skip((n), __VA_ARGS__); \
else
#define skip(n, ...) do { \
int _n = (n); \
while (_n--) { \
printf("ok %d # skip ", ++test_count); \
printf(__VA_ARGS__); \
printf("\n"); \
} \
} while (0)
#include <time.h>
time_t time(time_t *p)
{
static time_t value;
value++;
if (p) *p = value;
return value;
}
long labs(long v)
{
return v > 0 ? v : -v;
}
#else
#include <ccan/tap/tap.h>
#define TIS_INTERPRETER 0
#endif
#endif
|