line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
/* |
2
|
|
|
|
|
|
|
* Catch v2.12.1 |
3
|
|
|
|
|
|
|
* Generated: 2020-04-21 19:29:20.964532 |
4
|
|
|
|
|
|
|
* ---------------------------------------------------------- |
5
|
|
|
|
|
|
|
* This file has been merged from multiple headers. Please don't edit it directly |
6
|
|
|
|
|
|
|
* Copyright (c) 2020 Two Blue Cubes Ltd. All rights reserved. |
7
|
|
|
|
|
|
|
* |
8
|
|
|
|
|
|
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying |
9
|
|
|
|
|
|
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
10
|
|
|
|
|
|
|
*/ |
11
|
|
|
|
|
|
|
#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED |
12
|
|
|
|
|
|
|
#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED |
13
|
|
|
|
|
|
|
// start catch.hpp |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#define CATCH_VERSION_MAJOR 2 |
17
|
|
|
|
|
|
|
#define CATCH_VERSION_MINOR 12 |
18
|
|
|
|
|
|
|
#define CATCH_VERSION_PATCH 1 |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
#ifdef __clang__ |
21
|
|
|
|
|
|
|
# pragma clang system_header |
22
|
|
|
|
|
|
|
#elif defined __GNUC__ |
23
|
|
|
|
|
|
|
# pragma GCC system_header |
24
|
|
|
|
|
|
|
#endif |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
// start catch_suppress_warnings.h |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#ifdef __clang__ |
29
|
|
|
|
|
|
|
# ifdef __ICC // icpc defines the __clang__ macro |
30
|
|
|
|
|
|
|
# pragma warning(push) |
31
|
|
|
|
|
|
|
# pragma warning(disable: 161 1682) |
32
|
|
|
|
|
|
|
# else // __ICC |
33
|
|
|
|
|
|
|
# pragma clang diagnostic push |
34
|
|
|
|
|
|
|
# pragma clang diagnostic ignored "-Wpadded" |
35
|
|
|
|
|
|
|
# pragma clang diagnostic ignored "-Wswitch-enum" |
36
|
|
|
|
|
|
|
# pragma clang diagnostic ignored "-Wcovered-switch-default" |
37
|
|
|
|
|
|
|
# endif |
38
|
|
|
|
|
|
|
#elif defined __GNUC__ |
39
|
|
|
|
|
|
|
// Because REQUIREs trigger GCC's -Wparentheses, and because still |
40
|
|
|
|
|
|
|
// supported version of g++ have only buggy support for _Pragmas, |
41
|
|
|
|
|
|
|
// Wparentheses have to be suppressed globally. |
42
|
|
|
|
|
|
|
# pragma GCC diagnostic ignored "-Wparentheses" // See #674 for details |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# pragma GCC diagnostic push |
45
|
|
|
|
|
|
|
# pragma GCC diagnostic ignored "-Wunused-variable" |
46
|
|
|
|
|
|
|
# pragma GCC diagnostic ignored "-Wpadded" |
47
|
|
|
|
|
|
|
#endif |
48
|
|
|
|
|
|
|
// end catch_suppress_warnings.h |
49
|
|
|
|
|
|
|
#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER) |
50
|
|
|
|
|
|
|
# define CATCH_IMPL |
51
|
|
|
|
|
|
|
# define CATCH_CONFIG_ALL_PARTS |
52
|
|
|
|
|
|
|
#endif |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
// In the impl file, we want to have access to all parts of the headers |
55
|
|
|
|
|
|
|
// Can also be used to sanely support PCHs |
56
|
|
|
|
|
|
|
#if defined(CATCH_CONFIG_ALL_PARTS) |
57
|
|
|
|
|
|
|
# define CATCH_CONFIG_EXTERNAL_INTERFACES |
58
|
|
|
|
|
|
|
# if defined(CATCH_CONFIG_DISABLE_MATCHERS) |
59
|
|
|
|
|
|
|
# undef CATCH_CONFIG_DISABLE_MATCHERS |
60
|
|
|
|
|
|
|
# endif |
61
|
|
|
|
|
|
|
# if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) |
62
|
|
|
|
|
|
|
# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER |
63
|
|
|
|
|
|
|
# endif |
64
|
|
|
|
|
|
|
#endif |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
#if !defined(CATCH_CONFIG_IMPL_ONLY) |
67
|
|
|
|
|
|
|
// start catch_platform.h |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
#ifdef __APPLE__ |
70
|
|
|
|
|
|
|
# include |
71
|
|
|
|
|
|
|
# if TARGET_OS_OSX == 1 |
72
|
|
|
|
|
|
|
# define CATCH_PLATFORM_MAC |
73
|
|
|
|
|
|
|
# elif TARGET_OS_IPHONE == 1 |
74
|
|
|
|
|
|
|
# define CATCH_PLATFORM_IPHONE |
75
|
|
|
|
|
|
|
# endif |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
#elif defined(linux) || defined(__linux) || defined(__linux__) |
78
|
|
|
|
|
|
|
# define CATCH_PLATFORM_LINUX |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__) |
81
|
|
|
|
|
|
|
# define CATCH_PLATFORM_WINDOWS |
82
|
|
|
|
|
|
|
#endif |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
// end catch_platform.h |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
#ifdef CATCH_IMPL |
87
|
|
|
|
|
|
|
# ifndef CLARA_CONFIG_MAIN |
88
|
|
|
|
|
|
|
# define CLARA_CONFIG_MAIN_NOT_DEFINED |
89
|
|
|
|
|
|
|
# define CLARA_CONFIG_MAIN |
90
|
|
|
|
|
|
|
# endif |
91
|
|
|
|
|
|
|
#endif |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
// start catch_user_interfaces.h |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
namespace Catch { |
96
|
|
|
|
|
|
|
unsigned int rngSeed(); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
// end catch_user_interfaces.h |
100
|
|
|
|
|
|
|
// start catch_tag_alias_autoregistrar.h |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
// start catch_common.h |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
// start catch_compiler_capabilities.h |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
// Detect a number of compiler features - by compiler |
107
|
|
|
|
|
|
|
// The following features are defined: |
108
|
|
|
|
|
|
|
// |
109
|
|
|
|
|
|
|
// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported? |
110
|
|
|
|
|
|
|
// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported? |
111
|
|
|
|
|
|
|
// CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported? |
112
|
|
|
|
|
|
|
// CATCH_CONFIG_DISABLE_EXCEPTIONS : Are exceptions enabled? |
113
|
|
|
|
|
|
|
// **************** |
114
|
|
|
|
|
|
|
// Note to maintainers: if new toggles are added please document them |
115
|
|
|
|
|
|
|
// in configuration.md, too |
116
|
|
|
|
|
|
|
// **************** |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
// In general each macro has a _NO_ form |
119
|
|
|
|
|
|
|
// (e.g. CATCH_CONFIG_NO_POSIX_SIGNALS) which disables the feature. |
120
|
|
|
|
|
|
|
// Many features, at point of detection, define an _INTERNAL_ macro, so they |
121
|
|
|
|
|
|
|
// can be combined, en-mass, with the _NO_ forms later. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
#ifdef __cplusplus |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) |
126
|
|
|
|
|
|
|
# define CATCH_CPP14_OR_GREATER |
127
|
|
|
|
|
|
|
# endif |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) |
130
|
|
|
|
|
|
|
# define CATCH_CPP17_OR_GREATER |
131
|
|
|
|
|
|
|
# endif |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
#endif |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
#if defined(__cpp_lib_uncaught_exceptions) |
136
|
|
|
|
|
|
|
# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS |
137
|
|
|
|
|
|
|
#endif |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
// We have to avoid both ICC and Clang, because they try to mask themselves |
140
|
|
|
|
|
|
|
// as gcc, and we want only GCC in this block |
141
|
|
|
|
|
|
|
#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) |
142
|
|
|
|
|
|
|
# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic push" ) |
143
|
|
|
|
|
|
|
# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic pop" ) |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
#endif |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
#if defined(__clang__) |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" ) |
152
|
|
|
|
|
|
|
# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic pop" ) |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
// As of this writing, IBM XL's implementation of __builtin_constant_p has a bug |
155
|
|
|
|
|
|
|
// which results in calls to destructors being emitted for each temporary, |
156
|
|
|
|
|
|
|
// without a matching initialization. In practice, this can result in something |
157
|
|
|
|
|
|
|
// like `std::string::~string` being called on an uninitialized value. |
158
|
|
|
|
|
|
|
// |
159
|
|
|
|
|
|
|
// For example, this code will likely segfault under IBM XL: |
160
|
|
|
|
|
|
|
// ``` |
161
|
|
|
|
|
|
|
// REQUIRE(std::string("12") + "34" == "1234") |
162
|
|
|
|
|
|
|
// ``` |
163
|
|
|
|
|
|
|
// |
164
|
|
|
|
|
|
|
// Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented. |
165
|
|
|
|
|
|
|
# if !defined(__ibmxl__) |
166
|
|
|
|
|
|
|
# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) /* NOLINT(cppcoreguidelines-pro-type-vararg) */ |
167
|
|
|
|
|
|
|
# endif |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
170
|
|
|
|
|
|
|
_Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \ |
171
|
|
|
|
|
|
|
_Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"") |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ |
174
|
|
|
|
|
|
|
_Pragma( "clang diagnostic ignored \"-Wparentheses\"" ) |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ |
177
|
|
|
|
|
|
|
_Pragma( "clang diagnostic ignored \"-Wunused-variable\"" ) |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ |
180
|
|
|
|
|
|
|
_Pragma( "clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"" ) |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ |
183
|
|
|
|
|
|
|
_Pragma( "clang diagnostic ignored \"-Wunused-template\"" ) |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
#endif // __clang__ |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
188
|
|
|
|
|
|
|
// Assume that non-Windows platforms support posix signals by default |
189
|
|
|
|
|
|
|
#if !defined(CATCH_PLATFORM_WINDOWS) |
190
|
|
|
|
|
|
|
#define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS |
191
|
|
|
|
|
|
|
#endif |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
194
|
|
|
|
|
|
|
// We know some environments not to support full POSIX signals |
195
|
|
|
|
|
|
|
#if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__) |
196
|
|
|
|
|
|
|
#define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS |
197
|
|
|
|
|
|
|
#endif |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
#ifdef __OS400__ |
200
|
|
|
|
|
|
|
# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS |
201
|
|
|
|
|
|
|
# define CATCH_CONFIG_COLOUR_NONE |
202
|
|
|
|
|
|
|
#endif |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
205
|
|
|
|
|
|
|
// Android somehow still does not support std::to_string |
206
|
|
|
|
|
|
|
#if defined(__ANDROID__) |
207
|
|
|
|
|
|
|
# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING |
208
|
|
|
|
|
|
|
# define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE |
209
|
|
|
|
|
|
|
#endif |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
212
|
|
|
|
|
|
|
// Not all Windows environments support SEH properly |
213
|
|
|
|
|
|
|
#if defined(__MINGW32__) |
214
|
|
|
|
|
|
|
# define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH |
215
|
|
|
|
|
|
|
#endif |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
218
|
|
|
|
|
|
|
// PS4 |
219
|
|
|
|
|
|
|
#if defined(__ORBIS__) |
220
|
|
|
|
|
|
|
# define CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE |
221
|
|
|
|
|
|
|
#endif |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
224
|
|
|
|
|
|
|
// Cygwin |
225
|
|
|
|
|
|
|
#ifdef __CYGWIN__ |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
// Required for some versions of Cygwin to declare gettimeofday |
228
|
|
|
|
|
|
|
// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin |
229
|
|
|
|
|
|
|
# define _BSD_SOURCE |
230
|
|
|
|
|
|
|
// some versions of cygwin (most) do not support std::to_string. Use the libstd check. |
231
|
|
|
|
|
|
|
// https://gcc.gnu.org/onlinedocs/gcc-4.8.2/libstdc++/api/a01053_source.html line 2812-2813 |
232
|
|
|
|
|
|
|
# if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \ |
233
|
|
|
|
|
|
|
&& !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)) |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
# endif |
238
|
|
|
|
|
|
|
#endif // __CYGWIN__ |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
241
|
|
|
|
|
|
|
// Visual C++ |
242
|
|
|
|
|
|
|
#if defined(_MSC_VER) |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) ) |
245
|
|
|
|
|
|
|
# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma( warning(pop) ) |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
# if _MSC_VER >= 1900 // Visual Studio 2015 or newer |
248
|
|
|
|
|
|
|
# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS |
249
|
|
|
|
|
|
|
# endif |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
// Universal Windows platform does not support SEH |
252
|
|
|
|
|
|
|
// Or console colours (or console at all...) |
253
|
|
|
|
|
|
|
# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) |
254
|
|
|
|
|
|
|
# define CATCH_CONFIG_COLOUR_NONE |
255
|
|
|
|
|
|
|
# else |
256
|
|
|
|
|
|
|
# define CATCH_INTERNAL_CONFIG_WINDOWS_SEH |
257
|
|
|
|
|
|
|
# endif |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
// MSVC traditional preprocessor needs some workaround for __VA_ARGS__ |
260
|
|
|
|
|
|
|
// _MSVC_TRADITIONAL == 0 means new conformant preprocessor |
261
|
|
|
|
|
|
|
// _MSVC_TRADITIONAL == 1 means old traditional non-conformant preprocessor |
262
|
|
|
|
|
|
|
# if !defined(__clang__) // Handle Clang masquerading for msvc |
263
|
|
|
|
|
|
|
# if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL) |
264
|
|
|
|
|
|
|
# define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR |
265
|
|
|
|
|
|
|
# endif // MSVC_TRADITIONAL |
266
|
|
|
|
|
|
|
# endif // __clang__ |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
#endif // _MSC_VER |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
#if defined(_REENTRANT) || defined(_MSC_VER) |
271
|
|
|
|
|
|
|
// Enable async processing, as -pthread is specified or no additional linking is required |
272
|
|
|
|
|
|
|
# define CATCH_INTERNAL_CONFIG_USE_ASYNC |
273
|
|
|
|
|
|
|
#endif // _MSC_VER |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
276
|
|
|
|
|
|
|
// Check if we are compiled with -fno-exceptions or equivalent |
277
|
|
|
|
|
|
|
#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) |
278
|
|
|
|
|
|
|
# define CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED |
279
|
|
|
|
|
|
|
#endif |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
282
|
|
|
|
|
|
|
// DJGPP |
283
|
|
|
|
|
|
|
#ifdef __DJGPP__ |
284
|
|
|
|
|
|
|
# define CATCH_INTERNAL_CONFIG_NO_WCHAR |
285
|
|
|
|
|
|
|
#endif // __DJGPP__ |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
288
|
|
|
|
|
|
|
// Embarcadero C++Build |
289
|
|
|
|
|
|
|
#if defined(__BORLANDC__) |
290
|
|
|
|
|
|
|
#define CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN |
291
|
|
|
|
|
|
|
#endif |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
// Use of __COUNTER__ is suppressed during code analysis in |
296
|
|
|
|
|
|
|
// CLion/AppCode 2017.2.x and former, because __COUNTER__ is not properly |
297
|
|
|
|
|
|
|
// handled by it. |
298
|
|
|
|
|
|
|
// Otherwise all supported compilers support COUNTER macro, |
299
|
|
|
|
|
|
|
// but user still might want to turn it off |
300
|
|
|
|
|
|
|
#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L ) |
301
|
|
|
|
|
|
|
#define CATCH_INTERNAL_CONFIG_COUNTER |
302
|
|
|
|
|
|
|
#endif |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
// RTX is a special version of Windows that is real time. |
307
|
|
|
|
|
|
|
// This means that it is detected as Windows, but does not provide |
308
|
|
|
|
|
|
|
// the same set of capabilities as real Windows does. |
309
|
|
|
|
|
|
|
#if defined(UNDER_RTSS) || defined(RTX64_BUILD) |
310
|
|
|
|
|
|
|
#define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH |
311
|
|
|
|
|
|
|
#define CATCH_INTERNAL_CONFIG_NO_ASYNC |
312
|
|
|
|
|
|
|
#define CATCH_CONFIG_COLOUR_NONE |
313
|
|
|
|
|
|
|
#endif |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
#if !defined(_GLIBCXX_USE_C99_MATH_TR1) |
316
|
|
|
|
|
|
|
#define CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER |
317
|
|
|
|
|
|
|
#endif |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
// Various stdlib support checks that require __has_include |
320
|
|
|
|
|
|
|
#if defined(__has_include) |
321
|
|
|
|
|
|
|
// Check if string_view is available and usable |
322
|
|
|
|
|
|
|
#if __has_include() && defined(CATCH_CPP17_OR_GREATER) |
323
|
|
|
|
|
|
|
# define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW |
324
|
|
|
|
|
|
|
#endif |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
// Check if optional is available and usable |
327
|
|
|
|
|
|
|
# if __has_include() && defined(CATCH_CPP17_OR_GREATER) |
328
|
|
|
|
|
|
|
# define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL |
329
|
|
|
|
|
|
|
# endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
// Check if byte is available and usable |
332
|
|
|
|
|
|
|
# if __has_include() && defined(CATCH_CPP17_OR_GREATER) |
333
|
|
|
|
|
|
|
# define CATCH_INTERNAL_CONFIG_CPP17_BYTE |
334
|
|
|
|
|
|
|
# endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) |
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
// Check if variant is available and usable |
337
|
|
|
|
|
|
|
# if __has_include() && defined(CATCH_CPP17_OR_GREATER) |
338
|
|
|
|
|
|
|
# if defined(__clang__) && (__clang_major__ < 8) |
339
|
|
|
|
|
|
|
// work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852 |
340
|
|
|
|
|
|
|
// fix should be in clang 8, workaround in libstdc++ 8.2 |
341
|
|
|
|
|
|
|
# include |
342
|
|
|
|
|
|
|
# if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) |
343
|
|
|
|
|
|
|
# define CATCH_CONFIG_NO_CPP17_VARIANT |
344
|
|
|
|
|
|
|
# else |
345
|
|
|
|
|
|
|
# define CATCH_INTERNAL_CONFIG_CPP17_VARIANT |
346
|
|
|
|
|
|
|
# endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) |
347
|
|
|
|
|
|
|
# else |
348
|
|
|
|
|
|
|
# define CATCH_INTERNAL_CONFIG_CPP17_VARIANT |
349
|
|
|
|
|
|
|
# endif // defined(__clang__) && (__clang_major__ < 8) |
350
|
|
|
|
|
|
|
# endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) |
351
|
|
|
|
|
|
|
#endif // defined(__has_include) |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) |
354
|
|
|
|
|
|
|
# define CATCH_CONFIG_COUNTER |
355
|
|
|
|
|
|
|
#endif |
356
|
|
|
|
|
|
|
#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) && !defined(CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH) |
357
|
|
|
|
|
|
|
# define CATCH_CONFIG_WINDOWS_SEH |
358
|
|
|
|
|
|
|
#endif |
359
|
|
|
|
|
|
|
// This is set by default, because we assume that unix compilers are posix-signal-compatible by default. |
360
|
|
|
|
|
|
|
#if defined(CATCH_INTERNAL_CONFIG_POSIX_SIGNALS) && !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS) |
361
|
|
|
|
|
|
|
# define CATCH_CONFIG_POSIX_SIGNALS |
362
|
|
|
|
|
|
|
#endif |
363
|
|
|
|
|
|
|
// This is set by default, because we assume that compilers with no wchar_t support are just rare exceptions. |
364
|
|
|
|
|
|
|
#if !defined(CATCH_INTERNAL_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_WCHAR) |
365
|
|
|
|
|
|
|
# define CATCH_CONFIG_WCHAR |
366
|
|
|
|
|
|
|
#endif |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
#if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING) |
369
|
|
|
|
|
|
|
# define CATCH_CONFIG_CPP11_TO_STRING |
370
|
|
|
|
|
|
|
#endif |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
#if defined(CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_NO_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_CPP17_OPTIONAL) |
373
|
|
|
|
|
|
|
# define CATCH_CONFIG_CPP17_OPTIONAL |
374
|
|
|
|
|
|
|
#endif |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
#if defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) |
377
|
|
|
|
|
|
|
# define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS |
378
|
|
|
|
|
|
|
#endif |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
#if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW) |
381
|
|
|
|
|
|
|
# define CATCH_CONFIG_CPP17_STRING_VIEW |
382
|
|
|
|
|
|
|
#endif |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
#if defined(CATCH_INTERNAL_CONFIG_CPP17_VARIANT) && !defined(CATCH_CONFIG_NO_CPP17_VARIANT) && !defined(CATCH_CONFIG_CPP17_VARIANT) |
385
|
|
|
|
|
|
|
# define CATCH_CONFIG_CPP17_VARIANT |
386
|
|
|
|
|
|
|
#endif |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
#if defined(CATCH_INTERNAL_CONFIG_CPP17_BYTE) && !defined(CATCH_CONFIG_NO_CPP17_BYTE) && !defined(CATCH_CONFIG_CPP17_BYTE) |
389
|
|
|
|
|
|
|
# define CATCH_CONFIG_CPP17_BYTE |
390
|
|
|
|
|
|
|
#endif |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
#if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT) |
393
|
|
|
|
|
|
|
# define CATCH_INTERNAL_CONFIG_NEW_CAPTURE |
394
|
|
|
|
|
|
|
#endif |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
#if defined(CATCH_INTERNAL_CONFIG_NEW_CAPTURE) && !defined(CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NEW_CAPTURE) |
397
|
|
|
|
|
|
|
# define CATCH_CONFIG_NEW_CAPTURE |
398
|
|
|
|
|
|
|
#endif |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
#if !defined(CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) |
401
|
|
|
|
|
|
|
# define CATCH_CONFIG_DISABLE_EXCEPTIONS |
402
|
|
|
|
|
|
|
#endif |
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
#if defined(CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_NO_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_POLYFILL_ISNAN) |
405
|
|
|
|
|
|
|
# define CATCH_CONFIG_POLYFILL_ISNAN |
406
|
|
|
|
|
|
|
#endif |
407
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
#if defined(CATCH_INTERNAL_CONFIG_USE_ASYNC) && !defined(CATCH_INTERNAL_CONFIG_NO_ASYNC) && !defined(CATCH_CONFIG_NO_USE_ASYNC) && !defined(CATCH_CONFIG_USE_ASYNC) |
409
|
|
|
|
|
|
|
# define CATCH_CONFIG_USE_ASYNC |
410
|
|
|
|
|
|
|
#endif |
411
|
|
|
|
|
|
|
|
412
|
|
|
|
|
|
|
#if defined(CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_NO_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_ANDROID_LOGWRITE) |
413
|
|
|
|
|
|
|
# define CATCH_CONFIG_ANDROID_LOGWRITE |
414
|
|
|
|
|
|
|
#endif |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
#if defined(CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_NO_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) |
417
|
|
|
|
|
|
|
# define CATCH_CONFIG_GLOBAL_NEXTAFTER |
418
|
|
|
|
|
|
|
#endif |
419
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
// Even if we do not think the compiler has that warning, we still have |
421
|
|
|
|
|
|
|
// to provide a macro that can be used by the code. |
422
|
|
|
|
|
|
|
#if !defined(CATCH_INTERNAL_START_WARNINGS_SUPPRESSION) |
423
|
|
|
|
|
|
|
# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION |
424
|
|
|
|
|
|
|
#endif |
425
|
|
|
|
|
|
|
#if !defined(CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION) |
426
|
|
|
|
|
|
|
# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION |
427
|
|
|
|
|
|
|
#endif |
428
|
|
|
|
|
|
|
#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) |
429
|
|
|
|
|
|
|
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS |
430
|
|
|
|
|
|
|
#endif |
431
|
|
|
|
|
|
|
#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS) |
432
|
|
|
|
|
|
|
# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS |
433
|
|
|
|
|
|
|
#endif |
434
|
|
|
|
|
|
|
#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS) |
435
|
|
|
|
|
|
|
# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS |
436
|
|
|
|
|
|
|
#endif |
437
|
|
|
|
|
|
|
#if !defined(CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS) |
438
|
|
|
|
|
|
|
# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS |
439
|
|
|
|
|
|
|
#endif |
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
// The goal of this macro is to avoid evaluation of the arguments, but |
442
|
|
|
|
|
|
|
// still have the compiler warn on problems inside... |
443
|
|
|
|
|
|
|
#if !defined(CATCH_INTERNAL_IGNORE_BUT_WARN) |
444
|
|
|
|
|
|
|
# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) |
445
|
|
|
|
|
|
|
#endif |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
#if defined(__APPLE__) && defined(__apple_build_version__) && (__clang_major__ < 10) |
448
|
|
|
|
|
|
|
# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS |
449
|
|
|
|
|
|
|
#elif defined(__clang__) && (__clang_major__ < 5) |
450
|
|
|
|
|
|
|
# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS |
451
|
|
|
|
|
|
|
#endif |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS) |
454
|
|
|
|
|
|
|
# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS |
455
|
|
|
|
|
|
|
#endif |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) |
458
|
|
|
|
|
|
|
#define CATCH_TRY if ((true)) |
459
|
|
|
|
|
|
|
#define CATCH_CATCH_ALL if ((false)) |
460
|
|
|
|
|
|
|
#define CATCH_CATCH_ANON(type) if ((false)) |
461
|
|
|
|
|
|
|
#else |
462
|
|
|
|
|
|
|
#define CATCH_TRY try |
463
|
|
|
|
|
|
|
#define CATCH_CATCH_ALL catch (...) |
464
|
|
|
|
|
|
|
#define CATCH_CATCH_ANON(type) catch (type) |
465
|
|
|
|
|
|
|
#endif |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
#if defined(CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_NO_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) |
468
|
|
|
|
|
|
|
#define CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR |
469
|
|
|
|
|
|
|
#endif |
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
// end catch_compiler_capabilities.h |
472
|
|
|
|
|
|
|
#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line |
473
|
|
|
|
|
|
|
#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) |
474
|
|
|
|
|
|
|
#ifdef CATCH_CONFIG_COUNTER |
475
|
|
|
|
|
|
|
# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) |
476
|
|
|
|
|
|
|
#else |
477
|
|
|
|
|
|
|
# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) |
478
|
|
|
|
|
|
|
#endif |
479
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
#include |
481
|
|
|
|
|
|
|
#include |
482
|
|
|
|
|
|
|
#include |
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
// We need a dummy global operator<< so we can bring it into Catch namespace later |
485
|
|
|
|
|
|
|
struct Catch_global_namespace_dummy {}; |
486
|
|
|
|
|
|
|
std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy); |
487
|
|
|
|
|
|
|
|
488
|
|
|
|
|
|
|
namespace Catch { |
489
|
|
|
|
|
|
|
|
490
|
|
|
|
|
|
|
struct CaseSensitive { enum Choice { |
491
|
|
|
|
|
|
|
Yes, |
492
|
|
|
|
|
|
|
No |
493
|
|
|
|
|
|
|
}; }; |
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
class NonCopyable { |
496
|
|
|
|
|
|
|
NonCopyable( NonCopyable const& ) = delete; |
497
|
|
|
|
|
|
|
NonCopyable( NonCopyable && ) = delete; |
498
|
|
|
|
|
|
|
NonCopyable& operator = ( NonCopyable const& ) = delete; |
499
|
|
|
|
|
|
|
NonCopyable& operator = ( NonCopyable && ) = delete; |
500
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
protected: |
502
|
|
|
|
|
|
|
NonCopyable(); |
503
|
|
|
|
|
|
|
virtual ~NonCopyable(); |
504
|
|
|
|
|
|
|
}; |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
struct SourceLineInfo { |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
SourceLineInfo() = delete; |
509
|
0
|
|
|
|
|
|
SourceLineInfo( char const* _file, std::size_t _line ) noexcept |
510
|
|
|
|
|
|
|
: file( _file ), |
511
|
0
|
|
|
|
|
|
line( _line ) |
512
|
0
|
|
|
|
|
|
{} |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
SourceLineInfo( SourceLineInfo const& other ) = default; |
515
|
|
|
|
|
|
|
SourceLineInfo& operator = ( SourceLineInfo const& ) = default; |
516
|
|
|
|
|
|
|
SourceLineInfo( SourceLineInfo&& ) noexcept = default; |
517
|
|
|
|
|
|
|
SourceLineInfo& operator = ( SourceLineInfo&& ) noexcept = default; |
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
bool empty() const noexcept { return file[0] == '\0'; } |
520
|
|
|
|
|
|
|
bool operator == ( SourceLineInfo const& other ) const noexcept; |
521
|
|
|
|
|
|
|
bool operator < ( SourceLineInfo const& other ) const noexcept; |
522
|
|
|
|
|
|
|
|
523
|
|
|
|
|
|
|
char const* file; |
524
|
|
|
|
|
|
|
std::size_t line; |
525
|
|
|
|
|
|
|
}; |
526
|
|
|
|
|
|
|
|
527
|
|
|
|
|
|
|
std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); |
528
|
|
|
|
|
|
|
|
529
|
|
|
|
|
|
|
// Bring in operator<< from global namespace into Catch namespace |
530
|
|
|
|
|
|
|
// This is necessary because the overload of operator<< above makes |
531
|
|
|
|
|
|
|
// lookup stop at namespace Catch |
532
|
|
|
|
|
|
|
using ::operator<<; |
533
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
// Use this in variadic streaming macros to allow |
535
|
|
|
|
|
|
|
// >> +StreamEndStop |
536
|
|
|
|
|
|
|
// as well as |
537
|
|
|
|
|
|
|
// >> stuff +StreamEndStop |
538
|
|
|
|
|
|
|
struct StreamEndStop { |
539
|
|
|
|
|
|
|
std::string operator+() const; |
540
|
|
|
|
|
|
|
}; |
541
|
|
|
|
|
|
|
template |
542
|
|
|
|
|
|
|
T const& operator + ( T const& value, StreamEndStop ) { |
543
|
|
|
|
|
|
|
return value; |
544
|
|
|
|
|
|
|
} |
545
|
|
|
|
|
|
|
} |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
#define CATCH_INTERNAL_LINEINFO \ |
548
|
|
|
|
|
|
|
::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) ) |
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
// end catch_common.h |
551
|
|
|
|
|
|
|
namespace Catch { |
552
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
struct RegistrarForTagAliases { |
554
|
|
|
|
|
|
|
RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ); |
555
|
|
|
|
|
|
|
}; |
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
} // end namespace Catch |
558
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
#define CATCH_REGISTER_TAG_ALIAS( alias, spec ) \ |
560
|
|
|
|
|
|
|
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ |
561
|
|
|
|
|
|
|
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ |
562
|
|
|
|
|
|
|
namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } \ |
563
|
|
|
|
|
|
|
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION |
564
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
// end catch_tag_alias_autoregistrar.h |
566
|
|
|
|
|
|
|
// start catch_test_registry.h |
567
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
// start catch_interfaces_testcase.h |
569
|
|
|
|
|
|
|
|
570
|
|
|
|
|
|
|
#include |
571
|
|
|
|
|
|
|
|
572
|
|
|
|
|
|
|
namespace Catch { |
573
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
class TestSpec; |
575
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
struct ITestInvoker { |
577
|
|
|
|
|
|
|
virtual void invoke () const = 0; |
578
|
|
|
|
|
|
|
virtual ~ITestInvoker(); |
579
|
|
|
|
|
|
|
}; |
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
class TestCase; |
582
|
|
|
|
|
|
|
struct IConfig; |
583
|
|
|
|
|
|
|
|
584
|
|
|
|
|
|
|
struct ITestCaseRegistry { |
585
|
|
|
|
|
|
|
virtual ~ITestCaseRegistry(); |
586
|
|
|
|
|
|
|
virtual std::vector const& getAllTests() const = 0; |
587
|
|
|
|
|
|
|
virtual std::vector const& getAllTestsSorted( IConfig const& config ) const = 0; |
588
|
|
|
|
|
|
|
}; |
589
|
|
|
|
|
|
|
|
590
|
|
|
|
|
|
|
bool isThrowSafe( TestCase const& testCase, IConfig const& config ); |
591
|
|
|
|
|
|
|
bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ); |
592
|
|
|
|
|
|
|
std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); |
593
|
|
|
|
|
|
|
std::vector const& getAllTestCasesSorted( IConfig const& config ); |
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
} |
596
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
// end catch_interfaces_testcase.h |
598
|
|
|
|
|
|
|
// start catch_stringref.h |
599
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
#include |
601
|
|
|
|
|
|
|
#include |
602
|
|
|
|
|
|
|
#include |
603
|
|
|
|
|
|
|
#include |
604
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
namespace Catch { |
606
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
/// A non-owning string class (similar to the forthcoming std::string_view) |
608
|
|
|
|
|
|
|
/// Note that, because a StringRef may be a substring of another string, |
609
|
|
|
|
|
|
|
/// it may not be null terminated. |
610
|
|
|
|
|
|
|
class StringRef { |
611
|
|
|
|
|
|
|
public: |
612
|
|
|
|
|
|
|
using size_type = std::size_t; |
613
|
|
|
|
|
|
|
using const_iterator = const char*; |
614
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
private: |
616
|
|
|
|
|
|
|
static constexpr char const* const s_empty = ""; |
617
|
|
|
|
|
|
|
|
618
|
|
|
|
|
|
|
char const* m_start = s_empty; |
619
|
|
|
|
|
|
|
size_type m_size = 0; |
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
public: // construction |
622
|
0
|
|
|
|
|
|
constexpr StringRef() noexcept = default; |
623
|
|
|
|
|
|
|
|
624
|
|
|
|
|
|
|
StringRef( char const* rawChars ) noexcept; |
625
|
|
|
|
|
|
|
|
626
|
0
|
|
|
|
|
|
constexpr StringRef( char const* rawChars, size_type size ) noexcept |
627
|
|
|
|
|
|
|
: m_start( rawChars ), |
628
|
0
|
|
|
|
|
|
m_size( size ) |
629
|
0
|
|
|
|
|
|
{} |
630
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
StringRef( std::string const& stdString ) noexcept |
632
|
|
|
|
|
|
|
: m_start( stdString.c_str() ), |
633
|
|
|
|
|
|
|
m_size( stdString.size() ) |
634
|
|
|
|
|
|
|
{} |
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
explicit operator std::string() const { |
637
|
|
|
|
|
|
|
return std::string(m_start, m_size); |
638
|
|
|
|
|
|
|
} |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
public: // operators |
641
|
|
|
|
|
|
|
auto operator == ( StringRef const& other ) const noexcept -> bool; |
642
|
|
|
|
|
|
|
auto operator != (StringRef const& other) const noexcept -> bool { |
643
|
|
|
|
|
|
|
return !(*this == other); |
644
|
|
|
|
|
|
|
} |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
auto operator[] ( size_type index ) const noexcept -> char { |
647
|
|
|
|
|
|
|
assert(index < m_size); |
648
|
|
|
|
|
|
|
return m_start[index]; |
649
|
|
|
|
|
|
|
} |
650
|
|
|
|
|
|
|
|
651
|
|
|
|
|
|
|
public: // named queries |
652
|
|
|
|
|
|
|
constexpr auto empty() const noexcept -> bool { |
653
|
|
|
|
|
|
|
return m_size == 0; |
654
|
|
|
|
|
|
|
} |
655
|
|
|
|
|
|
|
constexpr auto size() const noexcept -> size_type { |
656
|
|
|
|
|
|
|
return m_size; |
657
|
|
|
|
|
|
|
} |
658
|
|
|
|
|
|
|
|
659
|
|
|
|
|
|
|
// Returns the current start pointer. If the StringRef is not |
660
|
|
|
|
|
|
|
// null-terminated, throws std::domain_exception |
661
|
|
|
|
|
|
|
auto c_str() const -> char const*; |
662
|
|
|
|
|
|
|
|
663
|
|
|
|
|
|
|
public: // substrings and searches |
664
|
|
|
|
|
|
|
// Returns a substring of [start, start + length). |
665
|
|
|
|
|
|
|
// If start + length > size(), then the substring is [start, size()). |
666
|
|
|
|
|
|
|
// If start > size(), then the substring is empty. |
667
|
|
|
|
|
|
|
auto substr( size_type start, size_type length ) const noexcept -> StringRef; |
668
|
|
|
|
|
|
|
|
669
|
|
|
|
|
|
|
// Returns the current start pointer. May not be null-terminated. |
670
|
|
|
|
|
|
|
auto data() const noexcept -> char const*; |
671
|
|
|
|
|
|
|
|
672
|
|
|
|
|
|
|
constexpr auto isNullTerminated() const noexcept -> bool { |
673
|
|
|
|
|
|
|
return m_start[m_size] == '\0'; |
674
|
|
|
|
|
|
|
} |
675
|
|
|
|
|
|
|
|
676
|
|
|
|
|
|
|
public: // iterators |
677
|
|
|
|
|
|
|
constexpr const_iterator begin() const { return m_start; } |
678
|
|
|
|
|
|
|
constexpr const_iterator end() const { return m_start + m_size; } |
679
|
|
|
|
|
|
|
}; |
680
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
auto operator += ( std::string& lhs, StringRef const& sr ) -> std::string&; |
682
|
|
|
|
|
|
|
auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&; |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
constexpr auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef { |
685
|
|
|
|
|
|
|
return StringRef( rawChars, size ); |
686
|
|
|
|
|
|
|
} |
687
|
|
|
|
|
|
|
} // namespace Catch |
688
|
|
|
|
|
|
|
|
689
|
198
|
|
|
|
|
|
constexpr auto operator "" _catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef { |
690
|
198
|
|
|
|
|
|
return Catch::StringRef( rawChars, size ); |
691
|
|
|
|
|
|
|
} |
692
|
|
|
|
|
|
|
|
693
|
|
|
|
|
|
|
// end catch_stringref.h |
694
|
|
|
|
|
|
|
// start catch_preprocessor.hpp |
695
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
|
697
|
|
|
|
|
|
|
#define CATCH_RECURSION_LEVEL0(...) __VA_ARGS__ |
698
|
|
|
|
|
|
|
#define CATCH_RECURSION_LEVEL1(...) CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(__VA_ARGS__))) |
699
|
|
|
|
|
|
|
#define CATCH_RECURSION_LEVEL2(...) CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(__VA_ARGS__))) |
700
|
|
|
|
|
|
|
#define CATCH_RECURSION_LEVEL3(...) CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(__VA_ARGS__))) |
701
|
|
|
|
|
|
|
#define CATCH_RECURSION_LEVEL4(...) CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(__VA_ARGS__))) |
702
|
|
|
|
|
|
|
#define CATCH_RECURSION_LEVEL5(...) CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(__VA_ARGS__))) |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
#ifdef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR |
705
|
|
|
|
|
|
|
#define INTERNAL_CATCH_EXPAND_VARGS(...) __VA_ARGS__ |
706
|
|
|
|
|
|
|
// MSVC needs more evaluations |
707
|
|
|
|
|
|
|
#define CATCH_RECURSION_LEVEL6(...) CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(__VA_ARGS__))) |
708
|
|
|
|
|
|
|
#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL6(CATCH_RECURSION_LEVEL6(__VA_ARGS__)) |
709
|
|
|
|
|
|
|
#else |
710
|
|
|
|
|
|
|
#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL5(__VA_ARGS__) |
711
|
|
|
|
|
|
|
#endif |
712
|
|
|
|
|
|
|
|
713
|
|
|
|
|
|
|
#define CATCH_REC_END(...) |
714
|
|
|
|
|
|
|
#define CATCH_REC_OUT |
715
|
|
|
|
|
|
|
|
716
|
|
|
|
|
|
|
#define CATCH_EMPTY() |
717
|
|
|
|
|
|
|
#define CATCH_DEFER(id) id CATCH_EMPTY() |
718
|
|
|
|
|
|
|
|
719
|
|
|
|
|
|
|
#define CATCH_REC_GET_END2() 0, CATCH_REC_END |
720
|
|
|
|
|
|
|
#define CATCH_REC_GET_END1(...) CATCH_REC_GET_END2 |
721
|
|
|
|
|
|
|
#define CATCH_REC_GET_END(...) CATCH_REC_GET_END1 |
722
|
|
|
|
|
|
|
#define CATCH_REC_NEXT0(test, next, ...) next CATCH_REC_OUT |
723
|
|
|
|
|
|
|
#define CATCH_REC_NEXT1(test, next) CATCH_DEFER ( CATCH_REC_NEXT0 ) ( test, next, 0) |
724
|
|
|
|
|
|
|
#define CATCH_REC_NEXT(test, next) CATCH_REC_NEXT1(CATCH_REC_GET_END test, next) |
725
|
|
|
|
|
|
|
|
726
|
|
|
|
|
|
|
#define CATCH_REC_LIST0(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) |
727
|
|
|
|
|
|
|
#define CATCH_REC_LIST1(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0) ) ( f, peek, __VA_ARGS__ ) |
728
|
|
|
|
|
|
|
#define CATCH_REC_LIST2(f, x, peek, ...) f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) |
729
|
|
|
|
|
|
|
|
730
|
|
|
|
|
|
|
#define CATCH_REC_LIST0_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) |
731
|
|
|
|
|
|
|
#define CATCH_REC_LIST1_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0_UD) ) ( f, userdata, peek, __VA_ARGS__ ) |
732
|
|
|
|
|
|
|
#define CATCH_REC_LIST2_UD(f, userdata, x, peek, ...) f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) |
733
|
|
|
|
|
|
|
|
734
|
|
|
|
|
|
|
// Applies the function macro `f` to each of the remaining parameters, inserts commas between the results, |
735
|
|
|
|
|
|
|
// and passes userdata as the first parameter to each invocation, |
736
|
|
|
|
|
|
|
// e.g. CATCH_REC_LIST_UD(f, x, a, b, c) evaluates to f(x, a), f(x, b), f(x, c) |
737
|
|
|
|
|
|
|
#define CATCH_REC_LIST_UD(f, userdata, ...) CATCH_RECURSE(CATCH_REC_LIST2_UD(f, userdata, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) |
738
|
|
|
|
|
|
|
|
739
|
|
|
|
|
|
|
#define CATCH_REC_LIST(f, ...) CATCH_RECURSE(CATCH_REC_LIST2(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) |
740
|
|
|
|
|
|
|
|
741
|
|
|
|
|
|
|
#define INTERNAL_CATCH_EXPAND1(param) INTERNAL_CATCH_EXPAND2(param) |
742
|
|
|
|
|
|
|
#define INTERNAL_CATCH_EXPAND2(...) INTERNAL_CATCH_NO## __VA_ARGS__ |
743
|
|
|
|
|
|
|
#define INTERNAL_CATCH_DEF(...) INTERNAL_CATCH_DEF __VA_ARGS__ |
744
|
|
|
|
|
|
|
#define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF |
745
|
|
|
|
|
|
|
#define INTERNAL_CATCH_STRINGIZE(...) INTERNAL_CATCH_STRINGIZE2(__VA_ARGS__) |
746
|
|
|
|
|
|
|
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR |
747
|
|
|
|
|
|
|
#define INTERNAL_CATCH_STRINGIZE2(...) #__VA_ARGS__ |
748
|
|
|
|
|
|
|
#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) |
749
|
|
|
|
|
|
|
#else |
750
|
|
|
|
|
|
|
// MSVC is adding extra space and needs another indirection to expand INTERNAL_CATCH_NOINTERNAL_CATCH_DEF |
751
|
|
|
|
|
|
|
#define INTERNAL_CATCH_STRINGIZE2(...) INTERNAL_CATCH_STRINGIZE3(__VA_ARGS__) |
752
|
|
|
|
|
|
|
#define INTERNAL_CATCH_STRINGIZE3(...) #__VA_ARGS__ |
753
|
|
|
|
|
|
|
#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) (INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) + 1) |
754
|
|
|
|
|
|
|
#endif |
755
|
|
|
|
|
|
|
|
756
|
|
|
|
|
|
|
#define INTERNAL_CATCH_MAKE_NAMESPACE2(...) ns_##__VA_ARGS__ |
757
|
|
|
|
|
|
|
#define INTERNAL_CATCH_MAKE_NAMESPACE(name) INTERNAL_CATCH_MAKE_NAMESPACE2(name) |
758
|
|
|
|
|
|
|
|
759
|
|
|
|
|
|
|
#define INTERNAL_CATCH_REMOVE_PARENS(...) INTERNAL_CATCH_EXPAND1(INTERNAL_CATCH_DEF __VA_ARGS__) |
760
|
|
|
|
|
|
|
|
761
|
|
|
|
|
|
|
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR |
762
|
|
|
|
|
|
|
#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) decltype(get_wrapper()) |
763
|
|
|
|
|
|
|
#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__)) |
764
|
|
|
|
|
|
|
#else |
765
|
|
|
|
|
|
|
#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) INTERNAL_CATCH_EXPAND_VARGS(decltype(get_wrapper())) |
766
|
|
|
|
|
|
|
#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__))) |
767
|
|
|
|
|
|
|
#endif |
768
|
|
|
|
|
|
|
|
769
|
|
|
|
|
|
|
#define INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(...)\ |
770
|
|
|
|
|
|
|
CATCH_REC_LIST(INTERNAL_CATCH_MAKE_TYPE_LIST,__VA_ARGS__) |
771
|
|
|
|
|
|
|
|
772
|
|
|
|
|
|
|
#define INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_0) INTERNAL_CATCH_REMOVE_PARENS(_0) |
773
|
|
|
|
|
|
|
#define INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_0, _1) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_1) |
774
|
|
|
|
|
|
|
#define INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_0, _1, _2) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_1, _2) |
775
|
|
|
|
|
|
|
#define INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_0, _1, _2, _3) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_1, _2, _3) |
776
|
|
|
|
|
|
|
#define INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_0, _1, _2, _3, _4) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_1, _2, _3, _4) |
777
|
|
|
|
|
|
|
#define INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_0, _1, _2, _3, _4, _5) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_1, _2, _3, _4, _5) |
778
|
|
|
|
|
|
|
#define INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_0, _1, _2, _3, _4, _5, _6) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_1, _2, _4, _5, _6) |
779
|
|
|
|
|
|
|
#define INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_0, _1, _2, _3, _4, _5, _6, _7) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_1, _2, _3, _4, _5, _6, _7) |
780
|
|
|
|
|
|
|
#define INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_1, _2, _3, _4, _5, _6, _7, _8) |
781
|
|
|
|
|
|
|
#define INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9) |
782
|
|
|
|
|
|
|
#define INTERNAL_CATCH_REMOVE_PARENS_11_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) |
783
|
|
|
|
|
|
|
|
784
|
|
|
|
|
|
|
#define INTERNAL_CATCH_VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N |
785
|
|
|
|
|
|
|
|
786
|
|
|
|
|
|
|
#define INTERNAL_CATCH_TYPE_GEN\ |
787
|
|
|
|
|
|
|
template struct TypeList {};\ |
788
|
|
|
|
|
|
|
template\ |
789
|
|
|
|
|
|
|
constexpr auto get_wrapper() noexcept -> TypeList { return {}; }\ |
790
|
|
|
|
|
|
|
template class...> struct TemplateTypeList{};\ |
791
|
|
|
|
|
|
|
template class...Cs>\ |
792
|
|
|
|
|
|
|
constexpr auto get_wrapper() noexcept -> TemplateTypeList { return {}; }\ |
793
|
|
|
|
|
|
|
template\ |
794
|
|
|
|
|
|
|
struct append;\ |
795
|
|
|
|
|
|
|
template\ |
796
|
|
|
|
|
|
|
struct rewrap;\ |
797
|
|
|
|
|
|
|
template class, typename...>\ |
798
|
|
|
|
|
|
|
struct create;\ |
799
|
|
|
|
|
|
|
template class, typename>\ |
800
|
|
|
|
|
|
|
struct convert;\ |
801
|
|
|
|
|
|
|
\ |
802
|
|
|
|
|
|
|
template \ |
803
|
|
|
|
|
|
|
struct append { using type = T; };\ |
804
|
|
|
|
|
|
|
template< template class L1, typename...E1, template class L2, typename...E2, typename...Rest>\ |
805
|
|
|
|
|
|
|
struct append, L2, Rest...> { using type = typename append, Rest...>::type; };\ |
806
|
|
|
|
|
|
|
template< template class L1, typename...E1, typename...Rest>\ |
807
|
|
|
|
|
|
|
struct append, TypeList, Rest...> { using type = L1; };\ |
808
|
|
|
|
|
|
|
\ |
809
|
|
|
|
|
|
|
template< template class Container, template class List, typename...elems>\ |
810
|
|
|
|
|
|
|
struct rewrap, List> { using type = TypeList>; };\ |
811
|
|
|
|
|
|
|
template< template class Container, template class List, class...Elems, typename...Elements>\ |
812
|
|
|
|
|
|
|
struct rewrap, List, Elements...> { using type = typename append>, typename rewrap, Elements...>::type>::type; };\ |
813
|
|
|
|
|
|
|
\ |
814
|
|
|
|
|
|
|
template class Final, template< typename...> class...Containers, typename...Types>\
815
|
|
|
|
|
|
|
struct create, TypeList> { using type = typename append, typename rewrap, Types...>::type...>::type; };\ |
816
|
|
|
|
|
|
|
template class Final, template class List, typename...Ts>\
817
struct convert> { using type = typename append,TypeList...>::type; };
818
819
#define INTERNAL_CATCH_NTTP_1(signature, ...)\
820
template struct Nttp{};\
821
template\
822
constexpr auto get_wrapper() noexcept -> Nttp<__VA_ARGS__> { return {}; } \
823
template class...> struct NttpTemplateTypeList{};\
824
template class...Cs>\
825
constexpr auto get_wrapper() noexcept -> NttpTemplateTypeList { return {}; } \
826
\
827
template< template class Container, template class List, INTERNAL_CATCH_REMOVE_PARENS(signature)>\
828
struct rewrap, List<__VA_ARGS__>> { using type = TypeList>; };\
829
template< template class Container, template class List, INTERNAL_CATCH_REMOVE_PARENS(signature), typename...Elements>\
830
struct rewrap, List<__VA_ARGS__>, Elements...> { using type = typename append>, typename rewrap, Elements...>::type>::type; };\
831
template class Final, template class...Containers, typename...Types>\
832
struct create, TypeList> { using type = typename append, typename rewrap, Types...>::type...>::type; };
833
834
#define INTERNAL_CATCH_DECLARE_SIG_TEST0(TestName)
835
#define INTERNAL_CATCH_DECLARE_SIG_TEST1(TestName, signature)\
836
template\
837
static void TestName()
838
#define INTERNAL_CATCH_DECLARE_SIG_TEST_X(TestName, signature, ...)\
839
template\
840
static void TestName()
841
842
#define INTERNAL_CATCH_DEFINE_SIG_TEST0(TestName)
843
#define INTERNAL_CATCH_DEFINE_SIG_TEST1(TestName, signature)\
844
template\
845
static void TestName()
846
#define INTERNAL_CATCH_DEFINE_SIG_TEST_X(TestName, signature,...)\
847
template\
848
static void TestName()
849
850
#define INTERNAL_CATCH_NTTP_REGISTER0(TestFunc, signature)\
851
template\
852
void reg_test(TypeList, Catch::NameAndTags nameAndTags)\
853
{\
854
Catch::AutoReg( Catch::makeTestInvoker(&TestFunc), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), nameAndTags);\
855
}
856
857
#define INTERNAL_CATCH_NTTP_REGISTER(TestFunc, signature, ...)\
858
template\
859
void reg_test(Nttp<__VA_ARGS__>, Catch::NameAndTags nameAndTags)\
860
{\
861
Catch::AutoReg( Catch::makeTestInvoker(&TestFunc<__VA_ARGS__>), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), nameAndTags);\
862
}
863
864
#define INTERNAL_CATCH_NTTP_REGISTER_METHOD0(TestName, signature, ...)\
865
template\
866
void reg_test(TypeList, Catch::StringRef className, Catch::NameAndTags nameAndTags)\
867
{\
868
Catch::AutoReg( Catch::makeTestInvoker(&TestName::test), CATCH_INTERNAL_LINEINFO, className, nameAndTags);\
869
}
870
871
#define INTERNAL_CATCH_NTTP_REGISTER_METHOD(TestName, signature, ...)\
872
template\
873
void reg_test(Nttp<__VA_ARGS__>, Catch::StringRef className, Catch::NameAndTags nameAndTags)\
874
{\
875
Catch::AutoReg( Catch::makeTestInvoker(&TestName<__VA_ARGS__>::test), CATCH_INTERNAL_LINEINFO, className, nameAndTags);\
876
}
877
878
#define INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD0(TestName, ClassName)
879
#define INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD1(TestName, ClassName, signature)\
880
template \
881
struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \
882
void test();\
883
}
884
885
#define INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X(TestName, ClassName, signature, ...)\
886
template \
887
struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName)<__VA_ARGS__> { \
888
void test();\
889
}
890
891
#define INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD0(TestName)
892
#define INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD1(TestName, signature)\
893
template \
894
void INTERNAL_CATCH_MAKE_NAMESPACE(TestName)::TestName::test()
895
#define INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X(TestName, signature, ...)\
896
template \
897
void INTERNAL_CATCH_MAKE_NAMESPACE(TestName)::TestName<__VA_ARGS__>::test()
898
899
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
900
#define INTERNAL_CATCH_NTTP_0
901
#define INTERNAL_CATCH_NTTP_GEN(...) INTERNAL_CATCH_VA_NARGS_IMPL(__VA_ARGS__, INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1(__VA_ARGS__), INTERNAL_CATCH_NTTP_1( __VA_ARGS__), INTERNAL_CATCH_NTTP_1( __VA_ARGS__), INTERNAL_CATCH_NTTP_1( __VA_ARGS__), INTERNAL_CATCH_NTTP_1( __VA_ARGS__),INTERNAL_CATCH_NTTP_1( __VA_ARGS__), INTERNAL_CATCH_NTTP_0)
902
#define INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD(TestName, ...) INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD1, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD0)(TestName, __VA_ARGS__)
903
#define INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD(TestName, ClassName, ...) INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD1, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD0)(TestName, ClassName, __VA_ARGS__)
904
#define INTERNAL_CATCH_NTTP_REG_METHOD_GEN(TestName, ...) INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD0, INTERNAL_CATCH_NTTP_REGISTER_METHOD0)(TestName, __VA_ARGS__)
905
#define INTERNAL_CATCH_NTTP_REG_GEN(TestFunc, ...) INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER0, INTERNAL_CATCH_NTTP_REGISTER0)(TestFunc, __VA_ARGS__)
906
#define INTERNAL_CATCH_DEFINE_SIG_TEST(TestName, ...) INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X,INTERNAL_CATCH_DEFINE_SIG_TEST_X,INTERNAL_CATCH_DEFINE_SIG_TEST1, INTERNAL_CATCH_DEFINE_SIG_TEST0)(TestName, __VA_ARGS__)
907
#define INTERNAL_CATCH_DECLARE_SIG_TEST(TestName, ...) INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_DECLARE_SIG_TEST_X,INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X,INTERNAL_CATCH_DECLARE_SIG_TEST_X,INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST1, INTERNAL_CATCH_DECLARE_SIG_TEST0)(TestName, __VA_ARGS__)
908
#define INTERNAL_CATCH_REMOVE_PARENS_GEN(...) INTERNAL_CATCH_VA_NARGS_IMPL(__VA_ARGS__, INTERNAL_CATCH_REMOVE_PARENS_11_ARG,INTERNAL_CATCH_REMOVE_PARENS_10_ARG,INTERNAL_CATCH_REMOVE_PARENS_9_ARG,INTERNAL_CATCH_REMOVE_PARENS_8_ARG,INTERNAL_CATCH_REMOVE_PARENS_7_ARG,INTERNAL_CATCH_REMOVE_PARENS_6_ARG,INTERNAL_CATCH_REMOVE_PARENS_5_ARG,INTERNAL_CATCH_REMOVE_PARENS_4_ARG,INTERNAL_CATCH_REMOVE_PARENS_3_ARG,INTERNAL_CATCH_REMOVE_PARENS_2_ARG,INTERNAL_CATCH_REMOVE_PARENS_1_ARG)(__VA_ARGS__)
909
#else
910
#define INTERNAL_CATCH_NTTP_0(signature)
911
#define INTERNAL_CATCH_NTTP_GEN(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL(__VA_ARGS__, INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_1,INTERNAL_CATCH_NTTP_1, INTERNAL_CATCH_NTTP_0)( __VA_ARGS__))
912
#define INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD(TestName, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD1, INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD0)(TestName, __VA_ARGS__))
913
#define INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD(TestName, ClassName, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X,INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD_X, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD1, INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD0)(TestName, ClassName, __VA_ARGS__))
914
#define INTERNAL_CATCH_NTTP_REG_METHOD_GEN(TestName, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD, INTERNAL_CATCH_NTTP_REGISTER_METHOD0, INTERNAL_CATCH_NTTP_REGISTER_METHOD0)(TestName, __VA_ARGS__))
915
#define INTERNAL_CATCH_NTTP_REG_GEN(TestFunc, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER, INTERNAL_CATCH_NTTP_REGISTER0, INTERNAL_CATCH_NTTP_REGISTER0)(TestFunc, __VA_ARGS__))
916
#define INTERNAL_CATCH_DEFINE_SIG_TEST(TestName, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X,INTERNAL_CATCH_DEFINE_SIG_TEST_X,INTERNAL_CATCH_DEFINE_SIG_TEST1, INTERNAL_CATCH_DEFINE_SIG_TEST0)(TestName, __VA_ARGS__))
917
#define INTERNAL_CATCH_DECLARE_SIG_TEST(TestName, ...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL( "dummy", __VA_ARGS__, INTERNAL_CATCH_DECLARE_SIG_TEST_X,INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DEFINE_SIG_TEST_X,INTERNAL_CATCH_DECLARE_SIG_TEST_X,INTERNAL_CATCH_DECLARE_SIG_TEST_X, INTERNAL_CATCH_DECLARE_SIG_TEST1, INTERNAL_CATCH_DECLARE_SIG_TEST0)(TestName, __VA_ARGS__))
918
#define INTERNAL_CATCH_REMOVE_PARENS_GEN(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_VA_NARGS_IMPL(__VA_ARGS__, INTERNAL_CATCH_REMOVE_PARENS_11_ARG,INTERNAL_CATCH_REMOVE_PARENS_10_ARG,INTERNAL_CATCH_REMOVE_PARENS_9_ARG,INTERNAL_CATCH_REMOVE_PARENS_8_ARG,INTERNAL_CATCH_REMOVE_PARENS_7_ARG,INTERNAL_CATCH_REMOVE_PARENS_6_ARG,INTERNAL_CATCH_REMOVE_PARENS_5_ARG,INTERNAL_CATCH_REMOVE_PARENS_4_ARG,INTERNAL_CATCH_REMOVE_PARENS_3_ARG,INTERNAL_CATCH_REMOVE_PARENS_2_ARG,INTERNAL_CATCH_REMOVE_PARENS_1_ARG)(__VA_ARGS__))
919
#endif
920
921
// end catch_preprocessor.hpp
922
// start catch_meta.hpp
923
924
925
#include
926
927
namespace Catch {
928
template
929
struct always_false : std::false_type {};
930
931
template struct true_given : std::true_type {};
932
struct is_callable_tester {
933
template
934
true_given()(std::declval()...))> static test(int);
935
template
936
std::false_type static test(...);
937
};
938
939
template
940
struct is_callable;
941
942
template
943
struct is_callable : decltype(is_callable_tester::test(0)) {};
944
945
#if defined(__cpp_lib_is_invocable) && __cpp_lib_is_invocable >= 201703
946
// std::result_of is deprecated in C++17 and removed in C++20. Hence, it is
947
// replaced with std::invoke_result here. Also *_t format is preferred over
948
// typename *::type format.
949
template
950
using FunctionReturnType = std::remove_reference_t>>;
951
#else
952
template
953
using FunctionReturnType = typename std::remove_reference::type>::type>::type;
954
#endif
955
956
} // namespace Catch
957
958
namespace mpl_{
959
struct na;
960
}
961
962
// end catch_meta.hpp
963
namespace Catch {
964
965
template
966
class TestInvokerAsMethod : public ITestInvoker {
967
void (C::*m_testAsMethod)();
968
public:
969
TestInvokerAsMethod( void (C::*testAsMethod)() ) noexcept : m_testAsMethod( testAsMethod ) {}
970
971
void invoke() const override {
972
C obj;
973
(obj.*m_testAsMethod)();
974
}
975
};
976
977
auto makeTestInvoker( void(*testAsFunction)() ) noexcept -> ITestInvoker*;
978
979
template
980
auto makeTestInvoker( void (C::*testAsMethod)() ) noexcept -> ITestInvoker* {
981
return new(std::nothrow) TestInvokerAsMethod( testAsMethod );
982
}
983
984
struct NameAndTags {
985
NameAndTags( StringRef const& name_ = StringRef(), StringRef const& tags_ = StringRef() ) noexcept;
986
StringRef name;
987
StringRef tags;
988
};
989
990
struct AutoReg : NonCopyable {
991
AutoReg( ITestInvoker* invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept;
992
~AutoReg();
993
};
994
995
} // end namespace Catch
996
997
#if defined(CATCH_CONFIG_DISABLE)
998
#define INTERNAL_CATCH_TESTCASE_NO_REGISTRATION( TestName, ... ) \
999
static void TestName()
1000
#define INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION( TestName, ClassName, ... ) \
1001
namespace{ \
1002
struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \
1003
void test(); \
1004
}; \
1005
} \
1006
void TestName::test()
1007
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( TestName, TestFunc, Name, Tags, Signature, ... ) \
1008
INTERNAL_CATCH_DEFINE_SIG_TEST(TestFunc, INTERNAL_CATCH_REMOVE_PARENS(Signature))
1009
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( TestNameClass, TestName, ClassName, Name, Tags, Signature, ... ) \
1010
namespace{ \
1011
namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \
1012
INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD(TestName, ClassName, INTERNAL_CATCH_REMOVE_PARENS(Signature));\
1013
} \
1014
} \
1015
INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD(TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature))
1016
1017
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
1018
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(Name, Tags, ...) \
1019
INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, typename TestType, __VA_ARGS__ )
1020
#else
1021
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(Name, Tags, ...) \
1022
INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, typename TestType, __VA_ARGS__ ) )
1023
#endif
1024
1025
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
1026
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(Name, Tags, Signature, ...) \
1027
INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, Signature, __VA_ARGS__ )
1028
#else
1029
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG_NO_REGISTRATION(Name, Tags, Signature, ...) \
1030
INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, Signature, __VA_ARGS__ ) )
1031
#endif
1032
1033
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
1034
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION( ClassName, Name, Tags,... ) \
1035
INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, typename T, __VA_ARGS__ )
1036
#else
1037
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION( ClassName, Name, Tags,... ) \
1038
INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, typename T, __VA_ARGS__ ) )
1039
#endif
1040
1041
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
1042
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION( ClassName, Name, Tags, Signature, ... ) \
1043
INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, Signature, __VA_ARGS__ )
1044
#else
1045
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG_NO_REGISTRATION( ClassName, Name, Tags, Signature, ... ) \
1046
INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, Signature, __VA_ARGS__ ) )
1047
#endif
1048
#endif
1049
1050
///////////////////////////////////////////////////////////////////////////////
1051
#define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \
1052
static void TestName(); \
1053
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
1054
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
1055
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &TestName ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \
1056
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
1057
static void TestName()
1058
#define INTERNAL_CATCH_TESTCASE( ... ) \
1059
INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), __VA_ARGS__ )
1060
1061
///////////////////////////////////////////////////////////////////////////////
1062
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \
1063
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
1064
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
1065
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &QualifiedMethod ), CATCH_INTERNAL_LINEINFO, "&" #QualifiedMethod, Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \
1066
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
1067
1068
///////////////////////////////////////////////////////////////////////////////
1069
#define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\
1070
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
1071
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
1072
namespace{ \
1073
struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \
1074
void test(); \
1075
}; \
1076
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( Catch::makeTestInvoker( &TestName::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \
1077
} \
1078
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
1079
void TestName::test()
1080
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \
1081
INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, __VA_ARGS__ )
1082
1083
///////////////////////////////////////////////////////////////////////////////
1084
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \
1085
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
1086
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
1087
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( Function ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \
1088
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
1089
1090
///////////////////////////////////////////////////////////////////////////////
1091
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_2(TestName, TestFunc, Name, Tags, Signature, ... )\
1092
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
1093
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
1094
CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \
1095
CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
1096
INTERNAL_CATCH_DECLARE_SIG_TEST(TestFunc, INTERNAL_CATCH_REMOVE_PARENS(Signature));\
1097
namespace {\
1098
namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){\
1099
INTERNAL_CATCH_TYPE_GEN\
1100
INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature))\
1101
INTERNAL_CATCH_NTTP_REG_GEN(TestFunc,INTERNAL_CATCH_REMOVE_PARENS(Signature))\
1102
template \
1103
struct TestName{\
1104
TestName(){\
1105
int index = 0; \
1106
constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, __VA_ARGS__)};\
1107
using expander = int[];\
1108
(void)expander{(reg_test(Types{}, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index]), Tags } ), index++, 0)... };/* NOLINT */ \
1109
}\
1110
};\
1111
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
1112
TestName();\
1113
return 0;\
1114
}();\
1115
}\
1116
}\
1117
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
1118
INTERNAL_CATCH_DEFINE_SIG_TEST(TestFunc,INTERNAL_CATCH_REMOVE_PARENS(Signature))
1119
1120
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
1121
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE(Name, Tags, ...) \
1122
INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, typename TestType, __VA_ARGS__ )
1123
#else
1124
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE(Name, Tags, ...) \
1125
INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, typename TestType, __VA_ARGS__ ) )
1126
#endif
1127
1128
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
1129
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG(Name, Tags, Signature, ...) \
1130
INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, Signature, __VA_ARGS__ )
1131
#else
1132
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_SIG(Name, Tags, Signature, ...) \
1133
INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, Signature, __VA_ARGS__ ) )
1134
#endif
1135
1136
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(TestName, TestFuncName, Name, Tags, Signature, TmplTypes, TypesList) \
1137
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
1138
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
1139
CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \
1140
CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
1141
template static void TestFuncName(); \
1142
namespace {\
1143
namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName) { \
1144
INTERNAL_CATCH_TYPE_GEN \
1145
INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature)) \
1146
template \
1147
struct TestName { \
1148
void reg_tests() { \
1149
int index = 0; \
1150
using expander = int[]; \
1151
constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))};\
1152
constexpr char const* types_list[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))};\
1153
constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]);\
1154
(void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFuncName ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index / num_types]) + "<" + std::string(types_list[index % num_types]) + ">", Tags } ), index++, 0)... };/* NOLINT */\
1155
} \
1156
}; \
1157
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \
1158
using TestInit = typename create()), TypeList>::type; \
1159
TestInit t; \
1160
t.reg_tests(); \
1161
return 0; \
1162
}(); \
1163
} \
1164
} \
1165
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
1166
template \
1167
static void TestFuncName()
1168
1169
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
1170
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE(Name, Tags, ...)\
1171
INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, typename T,__VA_ARGS__)
1172
#else
1173
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE(Name, Tags, ...)\
1174
INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, typename T, __VA_ARGS__ ) )
1175
#endif
1176
1177
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
1178
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG(Name, Tags, Signature, ...)\
1179
INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, Signature, __VA_ARGS__)
1180
#else
1181
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_SIG(Name, Tags, Signature, ...)\
1182
INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, Signature, __VA_ARGS__ ) )
1183
#endif
1184
1185
#define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_2(TestName, TestFunc, Name, Tags, TmplList)\
1186
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
1187
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
1188
CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
1189
template static void TestFunc(); \
1190
namespace {\
1191
namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){\
1192
INTERNAL_CATCH_TYPE_GEN\
1193
template \
1194
struct TestName { \
1195
void reg_tests() { \
1196
int index = 0; \
1197
using expander = int[]; \
1198
(void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFunc ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " + std::string(INTERNAL_CATCH_STRINGIZE(TmplList)) + " - " + std::to_string(index), Tags } ), index++, 0)... };/* NOLINT */\
1199
} \
1200
};\
1201
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \
1202
using TestInit = typename convert::type; \
1203
TestInit t; \
1204
t.reg_tests(); \
1205
return 0; \
1206
}(); \
1207
}}\
1208
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
1209
template \
1210
static void TestFunc()
1211
1212
#define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE(Name, Tags, TmplList) \
1213
INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, TmplList )
1214
1215
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( TestNameClass, TestName, ClassName, Name, Tags, Signature, ... ) \
1216
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
1217
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
1218
CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \
1219
CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
1220
namespace {\
1221
namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){ \
1222
INTERNAL_CATCH_TYPE_GEN\
1223
INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature))\
1224
INTERNAL_CATCH_DECLARE_SIG_TEST_METHOD(TestName, ClassName, INTERNAL_CATCH_REMOVE_PARENS(Signature));\
1225
INTERNAL_CATCH_NTTP_REG_METHOD_GEN(TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature))\
1226
template \
1227
struct TestNameClass{\
1228
TestNameClass(){\
1229
int index = 0; \
1230
constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, __VA_ARGS__)};\
1231
using expander = int[];\
1232
(void)expander{(reg_test(Types{}, #ClassName, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index]), Tags } ), index++, 0)... };/* NOLINT */ \
1233
}\
1234
};\
1235
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
1236
TestNameClass();\
1237
return 0;\
1238
}();\
1239
}\
1240
}\
1241
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
1242
INTERNAL_CATCH_DEFINE_SIG_TEST_METHOD(TestName, INTERNAL_CATCH_REMOVE_PARENS(Signature))
1243
1244
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
1245
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( ClassName, Name, Tags,... ) \
1246
INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, typename T, __VA_ARGS__ )
1247
#else
1248
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( ClassName, Name, Tags,... ) \
1249
INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, typename T, __VA_ARGS__ ) )
1250
#endif
1251
1252
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
1253
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( ClassName, Name, Tags, Signature, ... ) \
1254
INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, Signature, __VA_ARGS__ )
1255
#else
1256
#define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_SIG( ClassName, Name, Tags, Signature, ... ) \
1257
INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, Signature, __VA_ARGS__ ) )
1258
#endif
1259
1260
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2(TestNameClass, TestName, ClassName, Name, Tags, Signature, TmplTypes, TypesList)\
1261
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
1262
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
1263
CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \
1264
CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
1265
template \
1266
struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName ) { \
1267
void test();\
1268
};\
1269
namespace {\
1270
namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestNameClass) {\
1271
INTERNAL_CATCH_TYPE_GEN \
1272
INTERNAL_CATCH_NTTP_GEN(INTERNAL_CATCH_REMOVE_PARENS(Signature))\
1273
template\
1274
struct TestNameClass{\
1275
void reg_tests(){\
1276
int index = 0;\
1277
using expander = int[];\
1278
constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))};\
1279
constexpr char const* types_list[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))};\
1280
constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]);\
1281
(void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index / num_types]) + "<" + std::string(types_list[index % num_types]) + ">", Tags } ), index++, 0)... };/* NOLINT */ \
1282
}\
1283
};\
1284
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
1285
using TestInit = typename create()), TypeList>::type;\
1286
TestInit t;\
1287
t.reg_tests();\
1288
return 0;\
1289
}(); \
1290
}\
1291
}\
1292
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
1293
template \
1294
void TestName::test()
1295
1296
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
1297
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( ClassName, Name, Tags, ... )\
1298
INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), ClassName, Name, Tags, typename T, __VA_ARGS__ )
1299
#else
1300
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD( ClassName, Name, Tags, ... )\
1301
INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), ClassName, Name, Tags, typename T,__VA_ARGS__ ) )
1302
#endif
1303
1304
#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
1305
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( ClassName, Name, Tags, Signature, ... )\
1306
INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), ClassName, Name, Tags, Signature, __VA_ARGS__ )
1307
#else
1308
#define INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_SIG( ClassName, Name, Tags, Signature, ... )\
1309
INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_PRODUCT_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), ClassName, Name, Tags, Signature,__VA_ARGS__ ) )
1310
#endif
1311
1312
#define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD_2( TestNameClass, TestName, ClassName, Name, Tags, TmplList) \
1313
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
1314
CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
1315
CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
1316
template \
1317
struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName ) { \
1318
void test();\
1319
};\
1320
namespace {\
1321
namespace INTERNAL_CATCH_MAKE_NAMESPACE(TestName){ \
1322
INTERNAL_CATCH_TYPE_GEN\
1323
template\
1324
struct TestNameClass{\
1325
void reg_tests(){\
1326
int index = 0;\
1327
using expander = int[];\
1328
(void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ Name " - " + std::string(INTERNAL_CATCH_STRINGIZE(TmplList)) + " - " + std::to_string(index), Tags } ), index++, 0)... };/* NOLINT */ \
1329
}\
1330
};\
1331
static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\
1332
using TestInit = typename convert::type;\
1333
TestInit t;\
1334
t.reg_tests();\
1335
return 0;\
1336
}(); \
1337
}}\
1338
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
1339
template \
1340
void TestName::test()
1341
1342
#define INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD(ClassName, Name, Tags, TmplList) \
1343
INTERNAL_CATCH_TEMPLATE_LIST_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), ClassName, Name, Tags, TmplList )
1344
1345
// end catch_test_registry.h
1346
// start catch_capture.hpp
1347
1348
// start catch_assertionhandler.h
1349
1350
// start catch_assertioninfo.h
1351
1352
// start catch_result_type.h
1353
1354
namespace Catch {
1355
1356
// ResultWas::OfType enum
1357
struct ResultWas { enum OfType {
1358
Unknown = -1,
1359
Ok = 0,
1360
Info = 1,
1361
Warning = 2,
1362
1363
FailureBit = 0x10,
1364
1365
ExpressionFailed = FailureBit | 1,
1366
ExplicitFailure = FailureBit | 2,
1367
1368
Exception = 0x100 | FailureBit,
1369
1370
ThrewException = Exception | 1,
1371
DidntThrowException = Exception | 2,
1372
1373
FatalErrorCondition = 0x200 | FailureBit
1374
1375
}; };
1376
1377
bool isOk( ResultWas::OfType resultType );
1378
bool isJustInfo( int flags );
1379
1380
// ResultDisposition::Flags enum
1381
struct ResultDisposition { enum Flags {
1382
Normal = 0x01,
1383
1384
ContinueOnFailure = 0x02, // Failures fail test, but execution continues
1385
FalseTest = 0x04, // Prefix expression with !
1386
SuppressFail = 0x08 // Failures are reported but do not fail the test
1387
}; };
1388
1389
ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs );
1390
1391
bool shouldContinueOnFailure( int flags );
1392
inline bool isFalseTest( int flags ) { return ( flags & ResultDisposition::FalseTest ) != 0; }
1393
bool shouldSuppressFailure( int flags );
1394
1395
} // end namespace Catch
1396
1397
// end catch_result_type.h
1398
namespace Catch {
1399
1400
struct AssertionInfo
1401
{
1402
StringRef macroName;
1403
SourceLineInfo lineInfo;
1404
StringRef capturedExpression;
1405
ResultDisposition::Flags resultDisposition;
1406
1407
// We want to delete this constructor but a compiler bug in 4.8 means
1408
// the struct is then treated as non-aggregate
1409
//AssertionInfo() = delete;
1410
};
1411
1412
} // end namespace Catch
1413
1414
// end catch_assertioninfo.h
1415
// start catch_decomposer.h
1416
1417
// start catch_tostring.h
1418
1419
#include
1420
#include
1421
#include
1422
#include
1423
// start catch_stream.h
1424
1425
#include
1426
#include
1427
#include
1428
1429
namespace Catch {
1430
1431
std::ostream& cout();
1432
std::ostream& cerr();
1433
std::ostream& clog();
1434
1435
class StringRef;
1436
1437
struct IStream {
1438
virtual ~IStream();
1439
virtual std::ostream& stream() const = 0;
1440
};
1441
1442
auto makeStream( StringRef const &filename ) -> IStream const*;
1443
1444
class ReusableStringStream : NonCopyable {
1445
std::size_t m_index;
1446
std::ostream* m_oss;
1447
public:
1448
ReusableStringStream();
1449
~ReusableStringStream();
1450
1451
auto str() const -> std::string;
1452
1453
template
1454
23
auto operator << ( T const& value ) -> ReusableStringStream& {
1455
23
50
*m_oss << value;
1456
23
return *this;
1457
}
1458
auto get() -> std::ostream& { return *m_oss; }
1459
};
1460
}
1461
1462
// end catch_stream.h
1463
// start catch_interfaces_enum_values_registry.h
1464
1465
#include
1466
1467
namespace Catch {
1468
1469
namespace Detail {
1470
struct EnumInfo {
1471
StringRef m_name;
1472
std::vector> m_values;
1473
1474
~EnumInfo();
1475
1476
StringRef lookup( int value ) const;
1477
};
1478
} // namespace Detail
1479
1480
struct IMutableEnumValuesRegistry {
1481
virtual ~IMutableEnumValuesRegistry();
1482
1483
virtual Detail::EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::vector const& values ) = 0;
1484
1485
template
1486
Detail::EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::initializer_list values ) {
1487
static_assert(sizeof(int) >= sizeof(E), "Cannot serialize enum to int");
1488
std::vector intValues;
1489
intValues.reserve( values.size() );
1490
for( auto enumValue : values )
1491
intValues.push_back( static_cast( enumValue ) );
1492
return registerEnum( enumName, allEnums, intValues );
1493
}
1494
};
1495
1496
} // Catch
1497
1498
// end catch_interfaces_enum_values_registry.h
1499
1500
#ifdef CATCH_CONFIG_CPP17_STRING_VIEW
1501
#include
1502
#endif
1503
1504
#ifdef __OBJC__
1505
// start catch_objc_arc.hpp
1506
1507
#import
1508
1509
#ifdef __has_feature
1510
#define CATCH_ARC_ENABLED __has_feature(objc_arc)
1511
#else
1512
#define CATCH_ARC_ENABLED 0
1513
#endif
1514
1515
void arcSafeRelease( NSObject* obj );
1516
id performOptionalSelector( id obj, SEL sel );
1517
1518
#if !CATCH_ARC_ENABLED
1519
inline void arcSafeRelease( NSObject* obj ) {
1520
[obj release];
1521
}
1522
inline id performOptionalSelector( id obj, SEL sel ) {
1523
if( [obj respondsToSelector: sel] )
1524
return [obj performSelector: sel];
1525
return nil;
1526
}
1527
#define CATCH_UNSAFE_UNRETAINED
1528
#define CATCH_ARC_STRONG
1529
#else
1530
inline void arcSafeRelease( NSObject* ){}
1531
inline id performOptionalSelector( id obj, SEL sel ) {
1532
#ifdef __clang__
1533
#pragma clang diagnostic push
1534
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
1535
#endif
1536
if( [obj respondsToSelector: sel] )
1537
return [obj performSelector: sel];
1538
#ifdef __clang__
1539
#pragma clang diagnostic pop
1540
#endif
1541
return nil;
1542
}
1543
#define CATCH_UNSAFE_UNRETAINED __unsafe_unretained
1544
#define CATCH_ARC_STRONG __strong
1545
#endif
1546
1547
// end catch_objc_arc.hpp
1548
#endif
1549
1550
#ifdef _MSC_VER
1551
#pragma warning(push)
1552
#pragma warning(disable:4180) // We attempt to stream a function (address) by const&, which MSVC complains about but is harmless
1553
#endif
1554
1555
namespace Catch {
1556
namespace Detail {
1557
1558
extern const std::string unprintableString;
1559
1560
std::string rawMemoryToString( const void *object, std::size_t size );
1561
1562
template
1563
std::string rawMemoryToString( const T& object ) {
1564
return rawMemoryToString( &object, sizeof(object) );
1565
}
1566
1567
template
1568
class IsStreamInsertable {
1569
template
1570
static auto test(int)
1571
-> decltype(std::declval() << std::declval(), std::true_type());
1572
1573
template
1574
static auto test(...)->std::false_type;
1575
1576
public:
1577
static const bool value = decltype(test(0))::value;
1578
};
1579
1580
template
1581
std::string convertUnknownEnumToString( E e );
1582
1583
template
1584
typename std::enable_if<
1585
!std::is_enum::value && !std::is_base_of::value,
1586
std::string>::type convertUnstreamable( T const& ) {
1587
return Detail::unprintableString;
1588
}
1589
template
1590
typename std::enable_if<
1591
!std::is_enum::value && std::is_base_of::value,
1592
std::string>::type convertUnstreamable(T const& ex) {
1593
return ex.what();
1594
}
1595
1596
template
1597
typename std::enable_if<
1598
std::is_enum::value
1599
, std::string>::type convertUnstreamable( T const& value ) {
1600
return convertUnknownEnumToString( value );
1601
}
1602
1603
#if defined(_MANAGED)
1604
//! Convert a CLR string to a utf8 std::string
1605
template
1606
std::string clrReferenceToString( T^ ref ) {
1607
if (ref == nullptr)
1608
return std::string("null");
1609
auto bytes = System::Text::Encoding::UTF8->GetBytes(ref->ToString());
1610
cli::pin_ptr p = &bytes[0];
1611
return std::string(reinterpret_cast(p), bytes->Length);
1612
}
1613
#endif
1614
1615
} // namespace Detail
1616
1617
// If we decide for C++14, change these to enable_if_ts
1618
template
1619
struct StringMaker {
1620
template
1621
static
1622
typename std::enable_if<::Catch::Detail::IsStreamInsertable::value, std::string>::type
1623
23
convert(const Fake& value) {
1624
46
50
ReusableStringStream rss;
50
50
1625
// NB: call using the function-like syntax to avoid ambiguity with
1626
// user-defined templated operator<< under clang.
1627
23
50
rss.operator<<(value);
50
50
1628
46
50
return rss.str();
50
50
1629
}
1630
1631
template
1632
static
1633
typename std::enable_if::value, std::string>::type
1634
convert( const Fake& value ) {
1635
#if !defined(CATCH_CONFIG_FALLBACK_STRINGIFIER)
1636
return Detail::convertUnstreamable(value);
1637
#else
1638
return CATCH_CONFIG_FALLBACK_STRINGIFIER(value);
1639
#endif
1640
}
1641
};
1642
1643
namespace Detail {
1644
1645
// This function dispatches all stringification requests inside of Catch.
1646
// Should be preferably called fully qualified, like ::Catch::Detail::stringify
1647
template
1648
274
std::string stringify(const T& e) {
1649
274
return ::Catch::StringMaker::type>::type>::convert(e);
1650
}
1651
1652
template
1653
std::string convertUnknownEnumToString( E e ) {
1654
return ::Catch::Detail::stringify(static_cast::type>(e));
1655
}
1656
1657
#if defined(_MANAGED)
1658
template
1659
std::string stringify( T^ e ) {
1660
return ::Catch::StringMaker::convert(e);
1661
}
1662
#endif
1663
1664
} // namespace Detail
1665
1666
// Some predefined specializations
1667
1668
template<>
1669
struct StringMaker {
1670
static std::string convert(const std::string& str);
1671
};
1672
1673
#ifdef CATCH_CONFIG_CPP17_STRING_VIEW
1674
template<>
1675
struct StringMaker {
1676
static std::string convert(std::string_view str);
1677
};
1678
#endif
1679
1680
template<>
1681
struct StringMaker {
1682
static std::string convert(char const * str);
1683
};
1684
template<>
1685
struct StringMaker {
1686
static std::string convert(char * str);
1687
};
1688
1689
#ifdef CATCH_CONFIG_WCHAR
1690
template<>
1691
struct StringMaker {
1692
static std::string convert(const std::wstring& wstr);
1693
};
1694
1695
# ifdef CATCH_CONFIG_CPP17_STRING_VIEW
1696
template<>
1697
struct StringMaker {
1698
static std::string convert(std::wstring_view str);
1699
};
1700
# endif
1701
1702
template<>
1703
struct StringMaker {
1704
static std::string convert(wchar_t const * str);
1705
};
1706
template<>
1707
struct StringMaker {
1708
static std::string convert(wchar_t * str);
1709
};
1710
#endif
1711
1712
// TBD: Should we use `strnlen` to ensure that we don't go out of the buffer,
1713
// while keeping string semantics?
1714
template
1715
struct StringMaker {
1716
13
static std::string convert(char const* str) {
1717
13
50
return ::Catch::Detail::stringify(std::string{ str });
50
50
50
50
50
50
50
50
50
1718
}
1719
};
1720
template
1721
struct StringMaker {
1722
static std::string convert(signed char const* str) {
1723
return ::Catch::Detail::stringify(std::string{ reinterpret_cast(str) });
1724
}
1725
};
1726
template
1727
struct StringMaker {
1728
static std::string convert(unsigned char const* str) {
1729
return ::Catch::Detail::stringify(std::string{ reinterpret_cast(str) });
1730
}
1731
};
1732
1733
#if defined(CATCH_CONFIG_CPP17_BYTE)
1734
template<>
1735
struct StringMaker {
1736
static std::string convert(std::byte value);
1737
};
1738
#endif // defined(CATCH_CONFIG_CPP17_BYTE)
1739
template<>
1740
struct StringMaker {
1741
static std::string convert(int value);
1742
};
1743
template<>
1744
struct StringMaker {
1745
static std::string convert(long value);
1746
};
1747
template<>
1748
struct StringMaker {
1749
static std::string convert(long long value);
1750
};
1751
template<>
1752
struct StringMaker {
1753
static std::string convert(unsigned int value);
1754
};
1755
template<>
1756
struct StringMaker {
1757
static std::string convert(unsigned long value);
1758
};
1759
template<>
1760
struct StringMaker {
1761
static std::string convert(unsigned long long value);
1762
};
1763
1764
template<>
1765
struct StringMaker {
1766
static std::string convert(bool b);
1767
};
1768
1769
template<>
1770
struct StringMaker {
1771
static std::string convert(char c);
1772
};
1773
template<>
1774
struct StringMaker {
1775
static std::string convert(signed char c);
1776
};
1777
template<>
1778
struct StringMaker {
1779
static std::string convert(unsigned char c);
1780
};
1781
1782
template<>
1783
struct StringMaker {
1784
static std::string convert(std::nullptr_t);
1785
};
1786
1787
template<>
1788
struct StringMaker {
1789
static std::string convert(float value);
1790
static int precision;
1791
};
1792
1793
template<>
1794
struct StringMaker {
1795
static std::string convert(double value);
1796
static int precision;
1797
};
1798
1799
template
1800
struct StringMaker {
1801
template
1802
static std::string convert(U* p) {
1803
if (p) {
1804
return ::Catch::Detail::rawMemoryToString(p);
1805
} else {
1806
return "nullptr";
1807
}
1808
}
1809
};
1810
1811
template
1812
struct StringMaker {
1813
static std::string convert(R C::* p) {
1814
if (p) {
1815
return ::Catch::Detail::rawMemoryToString(p);
1816
} else {
1817
return "nullptr";
1818
}
1819
}
1820
};
1821
1822
#if defined(_MANAGED)
1823
template
1824
struct StringMaker {
1825
static std::string convert( T^ ref ) {
1826
return ::Catch::Detail::clrReferenceToString(ref);
1827
}
1828
};
1829
#endif
1830
1831
namespace Detail {
1832
template
1833
std::string rangeToString(InputIterator first, InputIterator last) {
1834
ReusableStringStream rss;
1835
rss << "{ ";
1836
if (first != last) {
1837
rss << ::Catch::Detail::stringify(*first);
1838
for (++first; first != last; ++first)
1839
rss << ", " << ::Catch::Detail::stringify(*first);
1840
}
1841
rss << " }";
1842
return rss.str();
1843
}
1844
}
1845
1846
#ifdef __OBJC__
1847
template<>
1848
struct StringMaker {
1849
static std::string convert(NSString * nsstring) {
1850
if (!nsstring)
1851
return "nil";
1852
return std::string("@") + [nsstring UTF8String];
1853
}
1854
};
1855
template<>
1856
struct StringMaker {
1857
static std::string convert(NSObject* nsObject) {
1858
return ::Catch::Detail::stringify([nsObject description]);
1859
}
1860
1861
};
1862
namespace Detail {
1863
inline std::string stringify( NSString* nsstring ) {
1864
return StringMaker::convert( nsstring );
1865
}
1866
1867
} // namespace Detail
1868
#endif // __OBJC__
1869
1870
} // namespace Catch
1871
1872
//////////////////////////////////////////////////////
1873
// Separate std-lib types stringification, so it can be selectively enabled
1874
// This means that we do not bring in
1875
1876
#if defined(CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS)
1877
# define CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER
1878
# define CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER
1879
# define CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER
1880
# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER
1881
# define CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER
1882
#endif
1883
1884
// Separate std::pair specialization
1885
#if defined(CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER)
1886
#include
1887
namespace Catch {
1888
template
1889
struct StringMaker > {
1890
static std::string convert(const std::pair& pair) {
1891
ReusableStringStream rss;
1892
rss << "{ "
1893
<< ::Catch::Detail::stringify(pair.first)
1894
<< ", "
1895
<< ::Catch::Detail::stringify(pair.second)
1896
<< " }";
1897
return rss.str();
1898
}
1899
};
1900
}
1901
#endif // CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER
1902
1903
#if defined(CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER) && defined(CATCH_CONFIG_CPP17_OPTIONAL)
1904
#include
1905
namespace Catch {
1906
template
1907
struct StringMaker > {
1908
static std::string convert(const std::optional& optional) {
1909
ReusableStringStream rss;
1910
if (optional.has_value()) {
1911
rss << ::Catch::Detail::stringify(*optional);
1912
} else {
1913
rss << "{ }";
1914
}
1915
return rss.str();
1916
}
1917
};
1918
}
1919
#endif // CATCH_CONFIG_ENABLE_OPTIONAL_STRINGMAKER
1920
1921
// Separate std::tuple specialization
1922
#if defined(CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER)
1923
#include
1924
namespace Catch {
1925
namespace Detail {
1926
template<
1927
typename Tuple,
1928
std::size_t N = 0,
1929
bool = (N < std::tuple_size::value)
1930
>
1931
struct TupleElementPrinter {
1932
static void print(const Tuple& tuple, std::ostream& os) {
1933
os << (N ? ", " : " ")
1934
<< ::Catch::Detail::stringify(std::get(tuple));
1935
TupleElementPrinter::print(tuple, os);
1936
}
1937
};
1938
1939
template<
1940
typename Tuple,
1941
std::size_t N
1942
>
1943
struct TupleElementPrinter {
1944
static void print(const Tuple&, std::ostream&) {}
1945
};
1946
1947
}
1948
1949
template
1950
struct StringMaker> {
1951
static std::string convert(const std::tuple& tuple) {
1952
ReusableStringStream rss;
1953
rss << '{';
1954
Detail::TupleElementPrinter>::print(tuple, rss.get());
1955
rss << " }";
1956
return rss.str();
1957
}
1958
};
1959
}
1960
#endif // CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER
1961
1962
#if defined(CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER) && defined(CATCH_CONFIG_CPP17_VARIANT)
1963
#include
1964
namespace Catch {
1965
template<>
1966
struct StringMaker {
1967
static std::string convert(const std::monostate&) {
1968
return "{ }";
1969
}
1970
};
1971
1972
template
1973
struct StringMaker> {
1974
static std::string convert(const std::variant& variant) {
1975
if (variant.valueless_by_exception()) {
1976
return "{valueless variant}";
1977
} else {
1978
return std::visit(
1979
[](const auto& value) {
1980
return ::Catch::Detail::stringify(value);
1981
},
1982
variant
1983
);
1984
}
1985
}
1986
};
1987
}
1988
#endif // CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER
1989
1990
namespace Catch {
1991
struct not_this_one {}; // Tag type for detecting which begin/ end are being selected
1992
1993
// Import begin/ end from std here so they are considered alongside the fallback (...) overloads in this namespace
1994
using std::begin;
1995
using std::end;
1996
1997
not_this_one begin( ... );
1998
not_this_one end( ... );
1999
2000
template
2001
struct is_range {
2002
static const bool value =
2003
!std::is_same())), not_this_one>::value &&
2004
!std::is_same())), not_this_one>::value;
2005
};
2006
2007
#if defined(_MANAGED) // Managed types are never ranges
2008
template
2009
struct is_range {
2010
static const bool value = false;
2011
};
2012
#endif
2013
2014
template
2015
std::string rangeToString( Range const& range ) {
2016
return ::Catch::Detail::rangeToString( begin( range ), end( range ) );
2017
}
2018
2019
// Handle vector specially
2020
template
2021
std::string rangeToString( std::vector const& v ) {
2022
ReusableStringStream rss;
2023
rss << "{ ";
2024
bool first = true;
2025
for( bool b : v ) {
2026
if( first )
2027
first = false;
2028
else
2029
rss << ", ";
2030
rss << ::Catch::Detail::stringify( b );
2031
}
2032
rss << " }";
2033
return rss.str();
2034
}
2035
2036
template
2037
struct StringMaker::value && !::Catch::Detail::IsStreamInsertable::value>::type> {
2038
static std::string convert( R const& range ) {
2039
return rangeToString( range );
2040
}
2041
};
2042
2043
template
2044
struct StringMaker {
2045
static std::string convert(T const(&arr)[SZ]) {
2046
return rangeToString(arr);
2047
}
2048
};
2049
2050
} // namespace Catch
2051
2052
// Separate std::chrono::duration specialization
2053
#if defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER)
2054
#include
2055
#include
2056
#include
2057
2058
namespace Catch {
2059
2060
template
2061
struct ratio_string {
2062
static std::string symbol();
2063
};
2064
2065
template
2066
std::string ratio_string::symbol() {
2067
Catch::ReusableStringStream rss;
2068
rss << '[' << Ratio::num << '/'
2069
<< Ratio::den << ']';
2070
return rss.str();
2071
}
2072
template <>
2073
struct ratio_string {
2074
static std::string symbol();
2075
};
2076
template <>
2077
struct ratio_string {
2078
static std::string symbol();
2079
};
2080
template <>
2081
struct ratio_string {
2082
static std::string symbol();
2083
};
2084
template <>
2085
struct ratio_string {
2086
static std::string symbol();
2087
};
2088
template <>
2089
struct ratio_string {
2090
static std::string symbol();
2091
};
2092
template <>
2093
struct ratio_string {
2094
static std::string symbol();
2095
};
2096
2097
////////////
2098
// std::chrono::duration specializations
2099
template
2100
struct StringMaker> {
2101
static std::string convert(std::chrono::duration const& duration) {
2102
ReusableStringStream rss;
2103
rss << duration.count() << ' ' << ratio_string::symbol() << 's';
2104
return rss.str();
2105
}
2106
};
2107
template
2108
struct StringMaker>> {
2109
static std::string convert(std::chrono::duration> const& duration) {
2110
ReusableStringStream rss;
2111
rss << duration.count() << " s";
2112
return rss.str();
2113
}
2114
};
2115
template
2116
struct StringMaker>> {
2117
static std::string convert(std::chrono::duration> const& duration) {
2118
ReusableStringStream rss;
2119
rss << duration.count() << " m";
2120
return rss.str();
2121
}
2122
};
2123
template
2124
struct StringMaker>> {
2125
static std::string convert(std::chrono::duration> const& duration) {
2126
ReusableStringStream rss;
2127
rss << duration.count() << " h";
2128
return rss.str();
2129
}
2130
};
2131
2132
////////////
2133
// std::chrono::time_point specialization
2134
// Generic time_point cannot be specialized, only std::chrono::time_point
2135
template
2136
struct StringMaker> {
2137
static std::string convert(std::chrono::time_point const& time_point) {
2138
return ::Catch::Detail::stringify(time_point.time_since_epoch()) + " since epoch";
2139
}
2140
};
2141
// std::chrono::time_point specialization
2142
template
2143
struct StringMaker> {
2144
static std::string convert(std::chrono::time_point const& time_point) {
2145
auto converted = std::chrono::system_clock::to_time_t(time_point);
2146
2147
#ifdef _MSC_VER
2148
std::tm timeInfo = {};
2149
gmtime_s(&timeInfo, &converted);
2150
#else
2151
std::tm* timeInfo = std::gmtime(&converted);
2152
#endif
2153
2154
auto const timeStampSize = sizeof("2017-01-16T17:06:45Z");
2155
char timeStamp[timeStampSize];
2156
const char * const fmt = "%Y-%m-%dT%H:%M:%SZ";
2157
2158
#ifdef _MSC_VER
2159
std::strftime(timeStamp, timeStampSize, fmt, &timeInfo);
2160
#else
2161
std::strftime(timeStamp, timeStampSize, fmt, timeInfo);
2162
#endif
2163
return std::string(timeStamp);
2164
}
2165
};
2166
}
2167
#endif // CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER
2168
2169
#define INTERNAL_CATCH_REGISTER_ENUM( enumName, ... ) \
2170
namespace Catch { \
2171
template<> struct StringMaker { \
| |