tap: import some changes
[argpar.git] / tests / tap / tap.h
CommitLineData
a99ee691
SM
1/*
2 * SPDX-License-Identifier: BSD-2-Clause
7ac57709 3 *
a99ee691
SM
4 * Copyright (C) 2004 Nik Clayton
5 * Copyright (C) 2017 Jérémie Galarneau
7ac57709
SM
6 */
7
88d1c8ae
SM
8#ifdef __cplusplus
9extern "C" {
10#endif
11
a99ee691 12/* '## __VA_ARGS__' is a gcc'ism. C99 doesn't allow the token pasting
88d1c8ae 13 and requires the caller to add the final comma if they've omitted
a99ee691
SM
14 the optional arguments */
15#ifdef __GNUC__
16# define ok(e, test, ...) ((e) ? \
17 _gen_result(1, __func__, __FILE__, __LINE__, \
18 test, ## __VA_ARGS__) : \
19 _gen_result(0, __func__, __FILE__, __LINE__, \
20 test, ## __VA_ARGS__))
7ac57709 21
7ac57709
SM
22# define ok1(e) ((e) ? \
23 _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \
24 _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e))
25
a99ee691
SM
26# define pass(test, ...) ok(1, test, ## __VA_ARGS__);
27# define fail(test, ...) ok(0, test, ## __VA_ARGS__);
28
29# define skip_start(test, n, fmt, ...) \
30 do { \
31 if((test)) { \
32 skip(n, fmt, ## __VA_ARGS__); \
33 continue; \
34 }
35#elif __STDC_VERSION__ >= 199901L /* __GNUC__ */
7ac57709
SM
36# define ok(e, ...) ((e) ? \
37 _gen_result(1, __func__, __FILE__, __LINE__, \
38 __VA_ARGS__) : \
39 _gen_result(0, __func__, __FILE__, __LINE__, \
40 __VA_ARGS__))
41
a99ee691
SM
42# define ok1(e) ((e) ? \
43 _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \
44 _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e))
7ac57709 45
a99ee691
SM
46# define pass(...) ok(1, __VA_ARGS__);
47# define fail(...) ok(0, __VA_ARGS__);
7ac57709
SM
48
49# define skip_start(test, n, ...) \
50 do { \
51 if((test)) { \
52 skip(n, __VA_ARGS__); \
53 continue; \
54 }
a99ee691
SM
55#else /* __STDC_VERSION__ */
56# error "Needs gcc or C99 compiler for variadic macros."
57#endif /* __STDC_VERSION__ */
7ac57709 58
a99ee691 59#define skip_end() } while(0);
7ac57709 60
a99ee691
SM
61#ifdef __MINGW_PRINTF_FORMAT
62# define TAP_PRINTF_FORMAT __MINGW_PRINTF_FORMAT
7ac57709 63#else
a99ee691 64# define TAP_PRINTF_FORMAT printf
7ac57709
SM
65#endif
66
a99ee691
SM
67__attribute__((format(TAP_PRINTF_FORMAT, 5, 6)))
68unsigned int _gen_result(int, const char *, const char *, unsigned int, const char *, ...);
7ac57709 69
a99ee691
SM
70int plan_no_plan(void);
71__attribute__((noreturn))
72int plan_skip_all(const char *);
73int plan_tests(unsigned int);
7ac57709 74
a99ee691
SM
75__attribute__((format(TAP_PRINTF_FORMAT, 1, 2)))
76unsigned int diag(const char *, ...);
77void diag_multiline(const char *);
7ac57709 78
a99ee691
SM
79__attribute__((format(TAP_PRINTF_FORMAT, 2, 3)))
80int skip(unsigned int, const char *, ...);
7ac57709 81
a99ee691
SM
82__attribute__((format(TAP_PRINTF_FORMAT, 1, 2)))
83void todo_start(const char *, ...);
7ac57709
SM
84void todo_end(void);
85
7ac57709 86int exit_status(void);
88d1c8ae
SM
87
88#ifdef __cplusplus
89}
90#endif
This page took 0.025418 seconds and 4 git commands to generate.