2 libtap - Write tests in C
3 Copyright 2012 Jake Gelbman <gelbman@gmail.com>
4 This file is licensed under the GPLv2
16 #define va_copy __va_copy
18 #define va_copy(d, s) ((d) = (s))
26 int vok_at_loc (const char *file, int line, int test, const char *fmt,
28 int ok_at_loc (const char *file, int line, int test, const char *fmt,
30 int is_at_loc (const char *file, int line, const char *got,
31 const char *expected, const char *fmt, ...);
32 int isnt_at_loc (const char *file, int line, const char *got,
33 const char *expected, const char *fmt, ...);
34 int cmp_ok_at_loc (const char *file, int line, int a, const char *op,
35 int b, const char *fmt, ...);
36 int bail_out (int ignore, const char *fmt, ...);
37 void planf (int tests, const char *fmt, ...);
38 int diag (const char *fmt, ...);
39 int note (const char *fmt, ...);
40 int exit_status (void);
41 void skippy (int n, const char *fmt, ...);
42 void todof (int ignore, const char *fmt, ...);
47 #define ok(...) ok_at_loc(__FILE__, __LINE__, __VA_ARGS__, NULL)
48 #define is(...) is_at_loc(__FILE__, __LINE__, __VA_ARGS__, NULL)
49 #define isnt(...) isnt_at_loc(__FILE__, __LINE__, __VA_ARGS__, NULL)
50 #define cmp_ok(...) cmp_ok_at_loc(__FILE__, __LINE__, __VA_ARGS__, NULL)
51 #define plan(...) planf(__VA_ARGS__, NULL)
52 #define done_testing() return exit_status()
53 #define BAIL_OUT(...) bail_out(0, "" __VA_ARGS__, NULL)
54 #define pass(...) ok(1, "" __VA_ARGS__)
55 #define fail(...) ok(0, "" __VA_ARGS__)
57 #define skip(test, ...) do {if (test) {skippy(__VA_ARGS__, NULL); break;}
58 #define endskip } while (0)
60 #define todo(...) todof(0, "" __VA_ARGS__, NULL)
61 #define endtodo endtodof()
63 #define dies_ok(...) dies_ok_common(1, __VA_ARGS__)
64 #define lives_ok(...) dies_ok_common(0, __VA_ARGS__)
67 #define like(...) skippy(1, "like is not implemented on Windows")
69 #define dies_ok_common(...) \
70 skippy(1, "Death detection is not supported on Windows")
72 #define like(...) like_at_loc(1, __FILE__, __LINE__, __VA_ARGS__, NULL)
73 #define unlike(...) like_at_loc(0, __FILE__, __LINE__, __VA_ARGS__, NULL)
74 int like_at_loc (int for_match, const char *file, int line,
75 const char *got, const char *expected,
76 const char *fmt, ...);
78 #include <sys/types.h>
80 int tap_test_died (int status);
81 #define dies_ok_common(for_death, code, ...) \
89 perror("fork error"); \
98 if (waitpid(cpid, NULL, 0) < 0) { \
99 perror("waitpid error"); \
102 it_died = tap_test_died(0); \
105 ok(for_death ? it_died : !it_died, "" __VA_ARGS__); \