test/sam: add tests for empty matches at the end of a range
[vis-test.git] / core / tap.h
blobb8a72135bead1e81925d4c8ef167f041c04d1761
1 #ifndef TAP_H
2 #define TAP_H
4 #ifdef TIS_INTERPRETER
5 static int failures = 0;
6 static int test_count = 0;
7 static void plan_no_plan(void) { }
9 static int exit_status() {
10 if (failures > 255)
11 failures = 255;
12 return failures;
15 #define ok(e, ...) do { \
16 bool _e = (e); \
17 printf("%sok %d - ", _e ? "" : "not ", ++test_count); \
18 printf(__VA_ARGS__); \
19 printf("\n"); \
20 if (!_e) { \
21 failures++; \
22 printf(" Failed test (%s:%s() at line %d)\n", __FILE__, __func__, __LINE__); \
23 } \
24 } while (0)
26 #define skip_if(cond, n, ...) \
27 if (cond) skip((n), __VA_ARGS__); \
28 else
30 #define skip(n, ...) do { \
31 int _n = (n); \
32 while (_n--) { \
33 printf("ok %d # skip ", ++test_count); \
34 printf(__VA_ARGS__); \
35 printf("\n"); \
36 } \
37 } while (0)
39 #include <time.h>
40 time_t time(time_t *p)
42 static time_t value;
43 value++;
44 if (p) *p = value;
45 return value;
48 long labs(long v)
50 return v > 0 ? v : -v;
53 #else
54 #include <ccan/tap/tap.h>
55 #define TIS_INTERPRETER 0
56 #endif
58 #endif