Lely core libraries  1.9.2
tap.h
Go to the documentation of this file.
1 
21 #ifndef LELY_TAP_TAP_H_
22 #define LELY_TAP_TAP_H_
23 
24 #include <lely/features.h>
25 
26 #ifdef __GNUC__
27 #pragma GCC diagnostic ignored "-Wformat-zero-length"
28 #pragma GCC diagnostic ignored "-Wformat-extra-args"
29 #endif
30 
38 #define tap_plan(...) tap_plan_(__VA_ARGS__, "")
39 #define tap_plan_(n, ...) tap_plan_impl(n, "" __VA_ARGS__)
40 
48 #define tap_test(...) tap_test_(__VA_ARGS__, "")
49 #define tap_test_(expr, ...) \
50  tap_test_impl(!!(expr), #expr, __FILE__, __LINE__, "" __VA_ARGS__)
51 
60 #define tap_pass(...) tap_test_impl(1, "", __FILE__, __LINE__, "" __VA_ARGS__)
61 
70 #define tap_fail(...) tap_test_impl(0, "", __FILE__, __LINE__, "" __VA_ARGS__)
71 
77 #define tap_todo(...) tap_todo_(__VA_ARGS__, "")
78 #define tap_todo_(expr, ...) \
79  tap_test_impl(!!(expr), #expr, __FILE__, __LINE__, \
80  " # TODO " __VA_ARGS__)
81 
86 #define tap_skip(...) tap_skip_(__VA_ARGS__, "")
87 #define tap_skip_(expr, ...) tap_pass(" # SKIP " __VA_ARGS__)
88 
94 #define tap_diag(...) tap_diag_impl("# " __VA_ARGS__)
95 
102 #define tap_abort(...) tap_abort_impl("" __VA_ARGS__)
103 
108 // clang-format off
109 #define tap_assert(expr) \
110  ((expr) ? (void)0 \
111  : tap_abort("%s:%d: Assertion `%s' failed.", __FILE__, \
112  __LINE__, #expr))
113 // clang-format on
114 
115 #ifdef __cplusplus
116 extern "C" {
117 #endif
118 
119 void tap_plan_impl(int n, const char *format, ...) format_printf__(2, 3);
120 int tap_test_impl(int test, const char *expr, const char *file, int line,
121  const char *format, ...) format_printf__(5, 6);
122 void tap_diag_impl(const char *format, ...) format_printf__(1, 2);
123 _Noreturn void tap_abort_impl(const char *format, ...) format_printf__(1, 2);
124 
125 #ifdef __cplusplus
126 }
127 #endif
128 
129 #endif // !LELY_TAP_TAP_H_
This header file is part of the Lely libraries; it contains the compiler feature definitions.
#define _Noreturn
A function declared with a _Noreturn function specifier SHALL not return to its caller.
Definition: features.h:214
A regular file handle.
Definition: file.c:39