5 #define _CRT_SECURE_NO_WARNINGS
12 #pragma warning(disable : 4127)
13 #pragma warning(disable : 4820)
15 #if A_PREREQ_GNUC(2, 95) || __has_warning("-Winline")
16 #pragma GCC diagnostic ignored "-Winline"
18 #if A_PREREQ_GNUC(2, 95) || __has_warning("-Wpadded")
19 #pragma GCC diagnostic ignored "-Wpadded"
21 #if A_PREREQ_GNUC(4, 6) || __has_warning("-Wdouble-promotion")
22 #if defined(A_FLOAT_TYPE) && (A_FLOAT_TYPE + 0 == A_FLOAT_SINGLE)
23 #pragma GCC diagnostic ignored "-Wdouble-promotion"
24 #endif /* A_FLOAT_TYPE + 0 == 0x04 */
25 #endif /* -Wdouble-promotion */
26 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ > 199900L) || \
27 defined(__cplusplus) && (__cplusplus > 201100L) || defined(_MSC_VER)
71 #else /* C < 199900 and C++ < 201100 */
101 #define PRItd PRIdPTR
102 #define PRIti PRIiPTR
103 #define PRIto PRIoPTR
104 #define PRItu PRIuPTR
105 #define PRItx PRIxPTR
106 #define PRItX PRIXPTR
108 #define SCNtd PRIdPTR
109 #define SCNti PRIiPTR
110 #define SCNto PRIoPTR
111 #define SCNtu PRIuPTR
112 #define SCNtx PRIxPTR
113 #define SCNtX PRIXPTR
115 #endif /* C > 199900 or C++ > 201100 */
117 #define TEST_IS_TRUE(expression, message) \
121 (void)fprintf(stderr, "%s: file %s, line %i\n", \
122 message, __FILE__, __LINE__); \
126 #define TEST_IS_FASLE(expression, message) \
130 (void)fprintf(stderr, "%s: file %s, line %i\n", \
131 message, __FILE__, __LINE__); \
135 #define TEST_BUG(expression) TEST_IS_TRUE(expression, "bug")
138 #if defined(__cplusplus)
140 #endif /* __cplusplus */
141 int MAIN_(c
)(int argc
, char *argv
[]);
142 int MAIN_(cpp
)(int argc
, char *argv
[]);
143 int test_init(int argc
, char *argv
[], int out
);
144 int debug(char const *fmt
, ...) A_FORMAT(printf
, 1, 2);
145 #if defined(__cplusplus)
147 #define MAIN(argc, argv) MAIN_(cpp)(argc, argv)
148 #else /* !__cplusplus */
149 #define MAIN(argc, argv) MAIN_(c)(argc, argv)
150 #endif /* __cplusplus */
151 #if !defined __cplusplus
152 static void test_exit(void);
153 int debug(char const *fmt
, ...)
157 int test_init(int argc
, char *argv
[], int out
)
159 static FILE *log
= A_NULL
;
160 if (!log
&& argc
> out
)
162 log
= freopen(argv
[out
], "wb", stdout
);
163 if (log
) { out
= atexit(test_exit
); }
167 int main(int argc
, char *argv
[])
170 return MAIN_(cpp
)(argc
, argv
) + MAIN_(c
)(argc
, argv
);
172 return MAIN_(c
)(argc
, argv
);
175 static void test_exit(void)
177 if (fclose(stdout
)) {}
179 #endif /* __cplusplus */
180 #if defined(__cplusplus) == defined(HAS_CXX)
182 #endif /* __cplusplus */
185 #endif /* test/test.h */