42#ifndef DOCTEST_LIBRARY_INCLUDED
43#define DOCTEST_LIBRARY_INCLUDED
49#define DOCTEST_VERSION_MAJOR 2
50#define DOCTEST_VERSION_MINOR 4
51#define DOCTEST_VERSION_PATCH 11
54#define DOCTEST_TOSTR_IMPL(x) #x
55#define DOCTEST_TOSTR(x) DOCTEST_TOSTR_IMPL(x)
57#define DOCTEST_VERSION_STR \
58 DOCTEST_TOSTR(DOCTEST_VERSION_MAJOR) "." \
59 DOCTEST_TOSTR(DOCTEST_VERSION_MINOR) "." \
60 DOCTEST_TOSTR(DOCTEST_VERSION_PATCH)
62#define DOCTEST_VERSION \
63 (DOCTEST_VERSION_MAJOR * 10000 + DOCTEST_VERSION_MINOR * 100 + DOCTEST_VERSION_PATCH)
72#define DOCTEST_CPLUSPLUS _MSVC_LANG
74#define DOCTEST_CPLUSPLUS __cplusplus
77#define DOCTEST_COMPILER(MAJOR, MINOR, PATCH) ((MAJOR)*10000000 + (MINOR)*100000 + (PATCH))
80#if defined(_MSC_VER) && defined(_MSC_FULL_VER)
81#if _MSC_VER == _MSC_FULL_VER / 10000
82#define DOCTEST_MSVC DOCTEST_COMPILER(_MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 10000)
85 DOCTEST_COMPILER(_MSC_VER / 100, (_MSC_FULL_VER / 100000) % 100, _MSC_FULL_VER % 100000)
88#if defined(__clang__) && defined(__clang_minor__) && defined(__clang_patchlevel__)
89#define DOCTEST_CLANG DOCTEST_COMPILER(__clang_major__, __clang_minor__, __clang_patchlevel__)
90#elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) && \
91 !defined(__INTEL_COMPILER)
92#define DOCTEST_GCC DOCTEST_COMPILER(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
94#if defined(__INTEL_COMPILER)
95#define DOCTEST_ICC DOCTEST_COMPILER(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0)
102#define DOCTEST_CLANG 0
115#if DOCTEST_CLANG && !DOCTEST_ICC
116#define DOCTEST_PRAGMA_TO_STR(x) _Pragma(#x)
117#define DOCTEST_CLANG_SUPPRESS_WARNING_PUSH _Pragma("clang diagnostic push")
118#define DOCTEST_CLANG_SUPPRESS_WARNING(w) DOCTEST_PRAGMA_TO_STR(clang diagnostic ignored w)
119#define DOCTEST_CLANG_SUPPRESS_WARNING_POP _Pragma("clang diagnostic pop")
120#define DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH(w) \
121 DOCTEST_CLANG_SUPPRESS_WARNING_PUSH DOCTEST_CLANG_SUPPRESS_WARNING(w)
123#define DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
124#define DOCTEST_CLANG_SUPPRESS_WARNING(w)
125#define DOCTEST_CLANG_SUPPRESS_WARNING_POP
126#define DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH(w)
130#define DOCTEST_PRAGMA_TO_STR(x) _Pragma(#x)
131#define DOCTEST_GCC_SUPPRESS_WARNING_PUSH _Pragma("GCC diagnostic push")
132#define DOCTEST_GCC_SUPPRESS_WARNING(w) DOCTEST_PRAGMA_TO_STR(GCC diagnostic ignored w)
133#define DOCTEST_GCC_SUPPRESS_WARNING_POP _Pragma("GCC diagnostic pop")
134#define DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH(w) \
135 DOCTEST_GCC_SUPPRESS_WARNING_PUSH DOCTEST_GCC_SUPPRESS_WARNING(w)
137#define DOCTEST_GCC_SUPPRESS_WARNING_PUSH
138#define DOCTEST_GCC_SUPPRESS_WARNING(w)
139#define DOCTEST_GCC_SUPPRESS_WARNING_POP
140#define DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH(w)
144#define DOCTEST_MSVC_SUPPRESS_WARNING_PUSH __pragma(warning(push))
145#define DOCTEST_MSVC_SUPPRESS_WARNING(w) __pragma(warning(disable : w))
146#define DOCTEST_MSVC_SUPPRESS_WARNING_POP __pragma(warning(pop))
147#define DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(w) \
148 DOCTEST_MSVC_SUPPRESS_WARNING_PUSH DOCTEST_MSVC_SUPPRESS_WARNING(w)
150#define DOCTEST_MSVC_SUPPRESS_WARNING_PUSH
151#define DOCTEST_MSVC_SUPPRESS_WARNING(w)
152#define DOCTEST_MSVC_SUPPRESS_WARNING_POP
153#define DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(w)
162#define DOCTEST_SUPPRESS_COMMON_WARNINGS_PUSH \
163 DOCTEST_CLANG_SUPPRESS_WARNING_PUSH \
164 DOCTEST_CLANG_SUPPRESS_WARNING("-Wunknown-pragmas") \
165 DOCTEST_CLANG_SUPPRESS_WARNING("-Wweak-vtables") \
166 DOCTEST_CLANG_SUPPRESS_WARNING("-Wpadded") \
167 DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes") \
168 DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat") \
169 DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat-pedantic") \
171 DOCTEST_GCC_SUPPRESS_WARNING_PUSH \
172 DOCTEST_GCC_SUPPRESS_WARNING("-Wunknown-pragmas") \
173 DOCTEST_GCC_SUPPRESS_WARNING("-Wpragmas") \
174 DOCTEST_GCC_SUPPRESS_WARNING("-Weffc++") \
175 DOCTEST_GCC_SUPPRESS_WARNING("-Wstrict-overflow") \
176 DOCTEST_GCC_SUPPRESS_WARNING("-Wstrict-aliasing") \
177 DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations") \
178 DOCTEST_GCC_SUPPRESS_WARNING("-Wuseless-cast") \
179 DOCTEST_GCC_SUPPRESS_WARNING("-Wnoexcept") \
181 DOCTEST_MSVC_SUPPRESS_WARNING_PUSH \
183 DOCTEST_MSVC_SUPPRESS_WARNING(4514) \
184 DOCTEST_MSVC_SUPPRESS_WARNING(4571) \
185 DOCTEST_MSVC_SUPPRESS_WARNING(4710) \
186 DOCTEST_MSVC_SUPPRESS_WARNING(4711) \
188 DOCTEST_MSVC_SUPPRESS_WARNING(4616) \
189 DOCTEST_MSVC_SUPPRESS_WARNING(4619) \
190 DOCTEST_MSVC_SUPPRESS_WARNING(4996) \
191 DOCTEST_MSVC_SUPPRESS_WARNING(4706) \
192 DOCTEST_MSVC_SUPPRESS_WARNING(4512) \
193 DOCTEST_MSVC_SUPPRESS_WARNING(4127) \
194 DOCTEST_MSVC_SUPPRESS_WARNING(4820) \
195 DOCTEST_MSVC_SUPPRESS_WARNING(4625) \
196 DOCTEST_MSVC_SUPPRESS_WARNING(4626) \
197 DOCTEST_MSVC_SUPPRESS_WARNING(5027) \
198 DOCTEST_MSVC_SUPPRESS_WARNING(5026) \
199 DOCTEST_MSVC_SUPPRESS_WARNING(4640) \
200 DOCTEST_MSVC_SUPPRESS_WARNING(5045) \
201 DOCTEST_MSVC_SUPPRESS_WARNING(5264) \
203 DOCTEST_MSVC_SUPPRESS_WARNING(26439) \
204 DOCTEST_MSVC_SUPPRESS_WARNING(26495) \
205 DOCTEST_MSVC_SUPPRESS_WARNING(26451) \
206 DOCTEST_MSVC_SUPPRESS_WARNING(26444) \
207 DOCTEST_MSVC_SUPPRESS_WARNING(26812)
209#define DOCTEST_SUPPRESS_COMMON_WARNINGS_POP \
210 DOCTEST_CLANG_SUPPRESS_WARNING_POP \
211 DOCTEST_GCC_SUPPRESS_WARNING_POP \
212 DOCTEST_MSVC_SUPPRESS_WARNING_POP
228#define DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN \
229 DOCTEST_MSVC_SUPPRESS_WARNING_PUSH \
230 DOCTEST_MSVC_SUPPRESS_WARNING(4548) \
231 DOCTEST_MSVC_SUPPRESS_WARNING(4265) \
232 DOCTEST_MSVC_SUPPRESS_WARNING(4986) \
233 DOCTEST_MSVC_SUPPRESS_WARNING(4350) \
234 DOCTEST_MSVC_SUPPRESS_WARNING(4668) \
235 DOCTEST_MSVC_SUPPRESS_WARNING(4365) \
236 DOCTEST_MSVC_SUPPRESS_WARNING(4774) \
237 DOCTEST_MSVC_SUPPRESS_WARNING(4820) \
238 DOCTEST_MSVC_SUPPRESS_WARNING(4625) \
239 DOCTEST_MSVC_SUPPRESS_WARNING(4626) \
240 DOCTEST_MSVC_SUPPRESS_WARNING(5027) \
241 DOCTEST_MSVC_SUPPRESS_WARNING(5026) \
242 DOCTEST_MSVC_SUPPRESS_WARNING(4623) \
243 DOCTEST_MSVC_SUPPRESS_WARNING(5039) \
244 DOCTEST_MSVC_SUPPRESS_WARNING(5045) \
245 DOCTEST_MSVC_SUPPRESS_WARNING(5105) \
246 DOCTEST_MSVC_SUPPRESS_WARNING(4738) \
247 DOCTEST_MSVC_SUPPRESS_WARNING(5262)
249#define DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END DOCTEST_MSVC_SUPPRESS_WARNING_POP
271#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
272#define DOCTEST_CONFIG_NO_WINDOWS_SEH
274#if DOCTEST_MSVC && !defined(DOCTEST_CONFIG_WINDOWS_SEH)
275#define DOCTEST_CONFIG_WINDOWS_SEH
277#if defined(DOCTEST_CONFIG_NO_WINDOWS_SEH) && defined(DOCTEST_CONFIG_WINDOWS_SEH)
278#undef DOCTEST_CONFIG_WINDOWS_SEH
281#if !defined(_WIN32) && !defined(__QNX__) && !defined(DOCTEST_CONFIG_POSIX_SIGNALS) && \
282 !defined(__EMSCRIPTEN__) && !defined(__wasi__)
283#define DOCTEST_CONFIG_POSIX_SIGNALS
285#if defined(DOCTEST_CONFIG_NO_POSIX_SIGNALS) && defined(DOCTEST_CONFIG_POSIX_SIGNALS)
286#undef DOCTEST_CONFIG_POSIX_SIGNALS
289#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
290#if !defined(__cpp_exceptions) && !defined(__EXCEPTIONS) && !defined(_CPPUNWIND) \
292#define DOCTEST_CONFIG_NO_EXCEPTIONS
296#ifdef DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS
297#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
298#define DOCTEST_CONFIG_NO_EXCEPTIONS
302#if defined(DOCTEST_CONFIG_NO_EXCEPTIONS) && !defined(DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS)
303#define DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS
307#define DOCTEST_CONFIG_NO_MULTITHREADING
310#if defined(DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN) && !defined(DOCTEST_CONFIG_IMPLEMENT)
311#define DOCTEST_CONFIG_IMPLEMENT
314#if defined(_WIN32) || defined(__CYGWIN__)
316#define DOCTEST_SYMBOL_EXPORT __declspec(dllexport)
317#define DOCTEST_SYMBOL_IMPORT __declspec(dllimport)
319#define DOCTEST_SYMBOL_EXPORT __attribute__((dllexport))
320#define DOCTEST_SYMBOL_IMPORT __attribute__((dllimport))
323#define DOCTEST_SYMBOL_EXPORT __attribute__((visibility("default")))
324#define DOCTEST_SYMBOL_IMPORT
327#ifdef DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL
328#ifdef DOCTEST_CONFIG_IMPLEMENT
329#define DOCTEST_INTERFACE DOCTEST_SYMBOL_EXPORT
331#define DOCTEST_INTERFACE DOCTEST_SYMBOL_IMPORT
334#define DOCTEST_INTERFACE
340#define DOCTEST_INTERFACE_DECL
341#define DOCTEST_INTERFACE_DEF DOCTEST_INTERFACE
343#define DOCTEST_INTERFACE_DECL DOCTEST_INTERFACE
344#define DOCTEST_INTERFACE_DEF
350#define DOCTEST_NOINLINE __declspec(noinline)
351#define DOCTEST_UNUSED
352#define DOCTEST_ALIGNMENT(x)
353#elif DOCTEST_CLANG && DOCTEST_CLANG < DOCTEST_COMPILER(3, 5, 0)
354#define DOCTEST_NOINLINE
355#define DOCTEST_UNUSED
356#define DOCTEST_ALIGNMENT(x)
358#define DOCTEST_NOINLINE __attribute__((noinline))
359#define DOCTEST_UNUSED __attribute__((unused))
360#define DOCTEST_ALIGNMENT(x) __attribute__((aligned(x)))
363#ifdef DOCTEST_CONFIG_NO_CONTRADICTING_INLINE
364#define DOCTEST_INLINE_NOINLINE inline
366#define DOCTEST_INLINE_NOINLINE inline DOCTEST_NOINLINE
369#ifndef DOCTEST_NORETURN
370#if DOCTEST_MSVC && (DOCTEST_MSVC < DOCTEST_COMPILER(19, 0, 0))
371#define DOCTEST_NORETURN
373#define DOCTEST_NORETURN [[noreturn]]
377#ifndef DOCTEST_NOEXCEPT
378#if DOCTEST_MSVC && (DOCTEST_MSVC < DOCTEST_COMPILER(19, 0, 0))
379#define DOCTEST_NOEXCEPT
381#define DOCTEST_NOEXCEPT noexcept
385#ifndef DOCTEST_CONSTEXPR
386#if DOCTEST_MSVC && (DOCTEST_MSVC < DOCTEST_COMPILER(19, 0, 0))
387#define DOCTEST_CONSTEXPR const
388#define DOCTEST_CONSTEXPR_FUNC inline
390#define DOCTEST_CONSTEXPR constexpr
391#define DOCTEST_CONSTEXPR_FUNC constexpr
395#ifndef DOCTEST_NO_SANITIZE_INTEGER
396#if DOCTEST_CLANG >= DOCTEST_COMPILER(3, 7, 0)
397#define DOCTEST_NO_SANITIZE_INTEGER __attribute__((no_sanitize("integer")))
399#define DOCTEST_NO_SANITIZE_INTEGER
407#define DOCTEST_DECLARE_INTERFACE(name) \
410 name(const name&) = delete; \
411 name(name&&) = delete; \
412 name& operator=(const name&) = delete; \
413 name& operator=(name&&) = delete;
415#define DOCTEST_DEFINE_INTERFACE(name) \
416 name::~name() = default;
419#define DOCTEST_CAT_IMPL(s1, s2) s1##s2
420#define DOCTEST_CAT(s1, s2) DOCTEST_CAT_IMPL(s1, s2)
422#define DOCTEST_ANONYMOUS(x) DOCTEST_CAT(x, __COUNTER__)
424#define DOCTEST_ANONYMOUS(x) DOCTEST_CAT(x, __LINE__)
427#ifndef DOCTEST_CONFIG_ASSERTION_PARAMETERS_BY_VALUE
428#define DOCTEST_REF_WRAP(x) x&
430#define DOCTEST_REF_WRAP(x) x
434#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
435#define DOCTEST_PLATFORM_MAC
436#elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
437#define DOCTEST_PLATFORM_IPHONE
439#define DOCTEST_PLATFORM_WINDOWS
440#elif defined(__wasi__)
441#define DOCTEST_PLATFORM_WASI
443#define DOCTEST_PLATFORM_LINUX
450#define DOCTEST_GLOBAL_NO_WARNINGS(var, ...) \
451 DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wglobal-constructors") \
452 static const int var = doctest::detail::consume(&var, __VA_ARGS__); \
453 DOCTEST_CLANG_SUPPRESS_WARNING_POP
455#ifndef DOCTEST_BREAK_INTO_DEBUGGER
457#ifdef DOCTEST_PLATFORM_LINUX
458#if defined(__GNUC__) && (defined(__i386) || defined(__x86_64))
460#define DOCTEST_BREAK_INTO_DEBUGGER() __asm__("int $3\n" : :)
463#define DOCTEST_BREAK_INTO_DEBUGGER() raise(SIGTRAP)
465#elif defined(DOCTEST_PLATFORM_MAC)
466#if defined(__x86_64) || defined(__x86_64__) || defined(__amd64__) || defined(__i386)
467#define DOCTEST_BREAK_INTO_DEBUGGER() __asm__("int $3\n" : :)
468#elif defined(__ppc__) || defined(__ppc64__)
470#define DOCTEST_BREAK_INTO_DEBUGGER() __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n": : : "memory","r0","r3","r4")
472#define DOCTEST_BREAK_INTO_DEBUGGER() __asm__("brk #0");
475#define DOCTEST_BREAK_INTO_DEBUGGER() __debugbreak()
476#elif defined(__MINGW32__)
478extern "C" __declspec(dllimport)
void __stdcall DebugBreak();
480#define DOCTEST_BREAK_INTO_DEBUGGER() ::DebugBreak()
482#define DOCTEST_BREAK_INTO_DEBUGGER() (static_cast<void>(0))
487#ifdef DOCTEST_CONFIG_USE_IOSFWD
488#ifndef DOCTEST_CONFIG_USE_STD_HEADERS
489#define DOCTEST_CONFIG_USE_STD_HEADERS
502#ifdef _LIBCPP_VERSION
503#ifndef DOCTEST_CONFIG_USE_STD_HEADERS
504#define DOCTEST_CONFIG_USE_STD_HEADERS
508#ifdef DOCTEST_CONFIG_USE_STD_HEADERS
509#ifndef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
510#define DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
525template <
class charT>
529template <
class charT,
class traits>
532template<
class traits>
535template <
class charT,
class traits>
538template <
class... Types>
540#if DOCTEST_MSVC >= DOCTEST_COMPILER(19, 20, 0)
544template <
class Elem,
class Traits,
class Alloc>
554#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
555#include <type_traits>
564#ifndef DOCTEST_CONFIG_STRING_SIZE_TYPE
565#define DOCTEST_CONFIG_STRING_SIZE_TYPE unsigned
609 char* allocate(size_type sz);
611 bool isOnStack() const noexcept {
return (buf[last] & 128) == 0; }
612 void setOnHeap() noexcept;
613 void setLast(size_type in = last) noexcept;
614 void setSize(size_type sz) noexcept;
616 void copy(const String& other);
642 const
char* c_str()
const {
return const_cast<String*
>(
this)->
c_str(); }
645 return reinterpret_cast<char*
>(buf);
659 int compare(
const char* other,
bool no_case =
false)
const;
713namespace assertType {
854 bool check(
const String& str) {
return isContains ? (content == str) : (content.string == str); }
859 } m_exception_string;
862 const char* exception_type,
const StringContains& exception_string);
886 virtual
void stringify(
std::ostream*) const = 0;
943#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
946 template <
bool COND,
typename T =
void>
949 template <
typename T>
979 template <
typename T>
984 return static_cast<T&&
>(t);
989 return static_cast<T&&
>(t);
992 template <
typename T>
996#if !DOCTEST_CLANG && defined(_MSC_VER) && _MSC_VER <= 1900
997 template <
typename T,
typename =
void>
1000 template <
typename T>
1001 struct has_global_insertion_operator<T, decltype(::operator<<(declval<std::ostream&>(), declval<const T&>()), void())> : types::true_type { };
1003 template <
typename T,
typename =
void>
1004 struct has_insertion_operator {
static DOCTEST_CONSTEXPR bool value = has_global_insertion_operator<T>::value; };
1006 template <
typename T,
bool global>
1009 template <
typename T>
1010 struct insert_hack<
T, true> {
1011 static void insert(
std::ostream& os,
const T& t) { ::operator<<(
os, t); }
1014 template <
typename T>
1015 struct insert_hack<
T, false> {
1016 static void insert(
std::ostream& os,
const T& t) { operator<<(os, t); }
1019 template <
typename T>
1020 using insert_hack_t = insert_hack<T, has_global_insertion_operator<T>::value>;
1022 template <
typename T,
typename =
void>
1026 template <
typename T>
1029 template <
typename T>
1039 template <
typename T>
1041#ifdef DOCTEST_CONFIG_REQUIRE_STRINGIFICATION_FOR_ALL_USED_TYPES
1048 template <
typename T>
1051 template <
typename T>
1056 template <
typename T,
size_t N>
1063 template <
typename T>
1072 template <
typename T>
1079template <
typename T>
1081 detail::has_insertion_operator<T>::value || detail::types::is_pointer<T>::value || detail::types::is_array<T>::value>
1084#ifndef DOCTEST_STRINGIFY
1085#ifdef DOCTEST_CONFIG_DOUBLE_STRINGIFY
1086#define DOCTEST_STRINGIFY(...) toString(toString(__VA_ARGS__))
1088#define DOCTEST_STRINGIFY(...) toString(__VA_ARGS__)
1092template <
typename T>
1094#if DOCTEST_CLANG == 0 && DOCTEST_GCC == 0 && DOCTEST_ICC == 0
1095 String ret = __FUNCSIG__;
1099 String ret = __PRETTY_FUNCTION__;
1101 return ret.
substr(begin, ret.
size() - begin - 1);
1105template <typename T, typename detail::types::enable_if<!detail::should_stringify_as_underlying_type<T>::value,
bool>::type =
true>
1110#ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
1114#if DOCTEST_MSVC >= DOCTEST_COMPILER(19, 20, 0)
1141template <typename T, typename detail::types::enable_if<detail::should_stringify_as_underlying_type<T>::value,
bool>::type =
true>
1148 template <
typename T>
1152#if defined(_MSC_VER) && _MSC_VER <= 1900
1153 insert_hack_t<T>::insert(*stream, in);
1155 operator<<(*stream, in);
1162 template <typename T,
size_t N>
1166 for (
size_t i = 0; i < N; i++) {
1167 if (i != 0) { *stream <<
", "; }
1181 *stream <<
String(in, in[N - 1] ? N : N - 1);
1191 template <
typename T>
1199 reinterpret_cast<const void*
>(in)
1201 *
reinterpret_cast<const void* const*
>(&in)
1215#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
1216 template <
typename T>
1217 explicit Approx(
const T& value,
1219 static_cast<T*
>(
nullptr)) {
1220 *
this =
static_cast<double>(value);
1226#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
1227 template <
typename T>
1229 const T& newEpsilon) {
1230 m_epsilon =
static_cast<double>(newEpsilon);
1237#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
1238 template <
typename T>
1240 const T& newScale) {
1241 m_scale =
static_cast<double>(newScale);
1260#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
1261#define DOCTEST_APPROX_PREFIX \
1262 template <typename T> friend typename std::enable_if<std::is_constructible<double, T>::value, bool>::type
1266 DOCTEST_APPROX_PREFIX operator!=(
const T& lhs,
const Approx& rhs) {
return !operator==(lhs, rhs); }
1267 DOCTEST_APPROX_PREFIX
operator!=(
const Approx& lhs,
const T& rhs) {
return !
operator==(rhs, lhs); }
1268 DOCTEST_APPROX_PREFIX operator<=(
const T& lhs,
const Approx& rhs) {
return static_cast<double>(lhs) < rhs.m_value || lhs == rhs; }
1269 DOCTEST_APPROX_PREFIX operator<=(
const Approx& lhs,
const T& rhs) {
return lhs.m_value <
static_cast<double>(rhs) || lhs == rhs; }
1270 DOCTEST_APPROX_PREFIX
operator>=(
const T& lhs,
const Approx& rhs) {
return static_cast<double>(lhs) > rhs.m_value || lhs == rhs; }
1271 DOCTEST_APPROX_PREFIX
operator>=(
const Approx& lhs,
const T& rhs) {
return lhs.m_value >
static_cast<double>(rhs) || lhs == rhs; }
1272 DOCTEST_APPROX_PREFIX operator< (
const T& lhs,
const Approx& rhs) {
return static_cast<double>(lhs) < rhs.m_value && lhs != rhs; }
1273 DOCTEST_APPROX_PREFIX operator< (
const Approx& lhs,
const T& rhs) {
return lhs.m_value <
static_cast<double>(rhs) && lhs != rhs; }
1274 DOCTEST_APPROX_PREFIX operator> (
const T& lhs,
const Approx& rhs) {
return static_cast<double>(lhs) > rhs.m_value && lhs != rhs; }
1275 DOCTEST_APPROX_PREFIX operator> (
const Approx& lhs,
const T& rhs) {
return lhs.m_value >
static_cast<double>(rhs) && lhs != rhs; }
1276#undef DOCTEST_APPROX_PREFIX
1290template <
typename F>
1294 IsNaN(F f,
bool flip =
false) : value(f), flipped(flip) { }
1296 operator bool()
const;
1307#ifndef DOCTEST_CONFIG_DISABLE
1311#ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
1312 template<
class T>
struct decay_array {
using type = T; };
1313 template<
class T,
unsigned N>
struct decay_array<T[N]> {
using type = T*; };
1314 template<
class T>
struct decay_array<T[]> {
using type =
T*; };
1320 template<
class T>
struct can_use_op :
public not_char_pointer<typename decay_array<T>::type> {};
1330#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
1338 bool m_entered =
false;
1347 operator bool()
const;
1350 bool checkFilters();
1353 template <
typename L,
typename R>
1359#if DOCTEST_CLANG && DOCTEST_CLANG < DOCTEST_COMPILER(3, 6, 0)
1368#define SFINAE_OP(ret,op) ret
1370#define SFINAE_OP(ret,op) decltype((void)(doctest::detail::declval<L>() op doctest::detail::declval<R>()),ret{})
1373#define DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(op, op_str, op_macro) \
1374 template <typename R> \
1375 DOCTEST_NOINLINE SFINAE_OP(Result,op) operator op(R&& rhs) { \
1376 bool res = op_macro(doctest::detail::forward<const L>(lhs), doctest::detail::forward<R>(rhs)); \
1377 if(m_at & assertType::is_false) \
1379 if(!res || doctest::getContextOptions()->success) \
1380 return Result(res, stringifyBinaryExpr(lhs, op_str, rhs)); \
1381 return Result(res); \
1387#define DOCTEST_FORBIT_EXPRESSION(rt, op) \
1388 template <typename R> \
1389 rt& operator op(const R&) { \
1390 static_assert(deferred_false<R>::value, \
1391 "Expression Too Complex Please Rewrite As Binary Comparison!"); \
1428#ifndef DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION
1454#ifndef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
1455#define DOCTEST_COMPARISON_RETURN_TYPE bool
1457#define DOCTEST_COMPARISON_RETURN_TYPE typename types::enable_if<can_use_op<L>::value || can_use_op<R>::value, bool>::type
1458 inline bool eq(
const char* lhs,
const char* rhs) {
return String(lhs) == String(rhs); }
1459 inline bool ne(
const char* lhs,
const char* rhs) {
return String(lhs) != String(rhs); }
1460 inline bool lt(
const char* lhs,
const char* rhs) {
return String(lhs) < String(rhs); }
1461 inline bool gt(
const char* lhs,
const char* rhs) {
return String(lhs) > String(rhs); }
1462 inline bool le(
const char* lhs,
const char* rhs) {
return String(lhs) <= String(rhs); }
1463 inline bool ge(
const char* lhs,
const char* rhs) {
return String(lhs) >= String(rhs); }
1467#define DOCTEST_RELATIONAL_OP(name, op) \
1468 template <typename L, typename R> \
1469 DOCTEST_COMPARISON_RETURN_TYPE name(const DOCTEST_REF_WRAP(L) lhs, \
1470 const DOCTEST_REF_WRAP(R) rhs) { \
1471 return lhs op rhs; \
1481#ifndef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
1482#define DOCTEST_CMP_EQ(l, r) l == r
1483#define DOCTEST_CMP_NE(l, r) l != r
1484#define DOCTEST_CMP_GT(l, r) l > r
1485#define DOCTEST_CMP_LT(l, r) l < r
1486#define DOCTEST_CMP_GE(l, r) l >= r
1487#define DOCTEST_CMP_LE(l, r) l <= r
1489#define DOCTEST_CMP_EQ(l, r) eq(l, r)
1490#define DOCTEST_CMP_NE(l, r) ne(l, r)
1491#define DOCTEST_CMP_GT(l, r) gt(l, r)
1492#define DOCTEST_CMP_LT(l, r) lt(l, r)
1493#define DOCTEST_CMP_GE(l, r) ge(l, r)
1494#define DOCTEST_CMP_LE(l, r) le(l, r)
1497 template <
typename L>
1505 : lhs(static_cast<L&&>(in))
1511 bool res =
static_cast<bool>(lhs);
1513 if(m_at & assertType::is_false) {
1524 operator L()
const {
return lhs; }
1558#ifndef DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION
1566#if DOCTEST_CLANG && DOCTEST_CLANG < DOCTEST_COMPILER(3, 6, 0)
1580 template <
typename L>
1585 template <typename L,typename types::enable_if<!doctest::detail::types::is_rvalue_reference<L>::value,
void >::type* =
nullptr>
1593 const char* m_test_suite =
nullptr;
1594 const char* m_description =
nullptr;
1595 bool m_skip =
false;
1596 bool m_no_breaks =
false;
1597 bool m_no_output =
false;
1598 bool m_may_fail =
false;
1599 bool m_should_fail =
false;
1600 int m_expected_failures = 0;
1601 double m_timeout = 0;
1605 template <
typename T>
1636 template <typename T>
1652 template<
typename T>
1655 namespace binaryAssertComparison {
1670#define DOCTEST_BINARY_RELATIONAL_OP(n, op) \
1671 template <class L, class R> struct RelationalComparator<n, L, R> { bool operator()(const DOCTEST_REF_WRAP(L) lhs, const DOCTEST_REF_WRAP(R) rhs) const { return op(lhs, rhs); } };
1684 const char* exception_type =
"",
const String& exception_string =
"");
1687 const char* exception_type,
const Contains& exception_string);
1691 template <
int comparison,
typename L,
typename R>
1701 template <
typename L>
1705 if (m_at & assertType::is_false) {
1706 m_failed = !m_failed;
1722 namespace assertAction {
1736#define DOCTEST_ASSERT_OUT_OF_TESTS(decomp) \
1738 if(!is_running_in_test) { \
1740 ResultBuilder rb(at, file, line, expr); \
1741 rb.m_failed = failed; \
1742 rb.m_decomp = decomp; \
1743 failed_out_of_a_testing_context(rb); \
1744 if(isDebuggerActive() && !getContextOptions()->no_breaks) \
1745 DOCTEST_BREAK_INTO_DEBUGGER(); \
1746 if(checkIfShouldThrow(at)) \
1753#define DOCTEST_ASSERT_IN_TESTS(decomp) \
1754 ResultBuilder rb(at, file, line, expr); \
1755 rb.m_failed = failed; \
1756 if(rb.m_failed || getContextOptions()->success) \
1757 rb.m_decomp = decomp; \
1759 DOCTEST_BREAK_INTO_DEBUGGER(); \
1760 if(rb.m_failed && checkIfShouldThrow(at)) \
1763 template <
int comparison,
typename L,
typename R>
1778 template <
typename L>
1783 if(at & assertType::is_false)
1801 template <typename T>
1806 : m_translateFunction(translateFunction) {}
1809#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
1813 }
catch(
const T&
ex) {
1814 res = m_translateFunction(
ex);
1818 static_cast<void>(res);
1823 String (*m_translateFunction)(T);
1843 bool need_to_destroy{
true};
1863 if (need_to_destroy) {
1872 bool logged =
false;
1886 template <typename T>
1894 template <
typename T>
1901 template <
typename T>
1908 template <
typename L>
1914#define DOCTEST_DEFINE_DECORATOR(name, type, def) \
1918 name(type in = def) \
1920 void fill(detail::TestCase& state) const { state.DOCTEST_CAT(m_, name) = data; } \
1921 void fill(detail::TestSuite& state) const { state.DOCTEST_CAT(m_, name) = data; } \
1934template <
typename T>
1939 detail::registerExceptionTranslatorImpl(&exceptionTranslator);
1953template <
typename T>
1954int registerExceptionTranslator(String (*)(T)) {
1961 struct ContextState;
1966 detail::ContextState* p;
1968 void parseArgs(
int argc,
const char*
const* argv,
bool withDefaults =
false);
1971 explicit Context(
int argc = 0,
const char*
const* argv =
nullptr);
2000namespace TestCaseFailureReason {
2046 unsigned num_data = 0;
2090 static
int get_num_active_contexts();
2094 static
int get_num_stringified_contexts();
2095 static const
String* get_stringified_contexts();
2103 template <
typename Reporter>
2105 return new Reporter(o);
2109template <
typename Reporter>
2111 detail::registerReporterImpl(name, priority, detail::reporterCreator<Reporter>, isReporter);
2116#ifdef DOCTEST_CONFIG_ASSERTS_RETURN_VALUES
2117#define DOCTEST_FUNC_EMPTY [] { return false; }()
2119#define DOCTEST_FUNC_EMPTY (void)0
2123#ifndef DOCTEST_CONFIG_DISABLE
2125#ifdef DOCTEST_CONFIG_ASSERTS_RETURN_VALUES
2126#define DOCTEST_FUNC_SCOPE_BEGIN [&]
2127#define DOCTEST_FUNC_SCOPE_END ()
2128#define DOCTEST_FUNC_SCOPE_RET(v) return v
2130#define DOCTEST_FUNC_SCOPE_BEGIN do
2131#define DOCTEST_FUNC_SCOPE_END while(false)
2132#define DOCTEST_FUNC_SCOPE_RET(v) (void)0
2136#define DOCTEST_ASSERT_LOG_REACT_RETURN(b) \
2137 if(b.log()) DOCTEST_BREAK_INTO_DEBUGGER(); \
2139 DOCTEST_FUNC_SCOPE_RET(!b.m_failed)
2141#ifdef DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS
2142#define DOCTEST_WRAP_IN_TRY(x) x;
2144#define DOCTEST_WRAP_IN_TRY(x) \
2147 } catch(...) { DOCTEST_RB.translateException(); }
2150#ifdef DOCTEST_CONFIG_VOID_CAST_EXPRESSIONS
2151#define DOCTEST_CAST_TO_VOID(...) \
2152 DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wuseless-cast") \
2153 static_cast<void>(__VA_ARGS__); \
2154 DOCTEST_GCC_SUPPRESS_WARNING_POP
2156#define DOCTEST_CAST_TO_VOID(...) __VA_ARGS__;
2160#define DOCTEST_REGISTER_FUNCTION(global_prefix, f, decorators) \
2161 global_prefix DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(DOCTEST_ANON_VAR_), \
2162 doctest::detail::regTest( \
2163 doctest::detail::TestCase( \
2164 f, __FILE__, __LINE__, \
2165 doctest_detail_test_suite_ns::getCurrentTestSuite()) * \
2168#define DOCTEST_IMPLEMENT_FIXTURE(der, base, func, decorators) \
2170 struct der : public base \
2174 static DOCTEST_INLINE_NOINLINE void func() { \
2178 DOCTEST_REGISTER_FUNCTION(DOCTEST_EMPTY, func, decorators) \
2180 DOCTEST_INLINE_NOINLINE void der::f()
2182#define DOCTEST_CREATE_AND_REGISTER_FUNCTION(f, decorators) \
2184 DOCTEST_REGISTER_FUNCTION(DOCTEST_EMPTY, f, decorators) \
2187#define DOCTEST_CREATE_AND_REGISTER_FUNCTION_IN_CLASS(f, proxy, decorators) \
2188 static doctest::detail::funcType proxy() { return f; } \
2189 DOCTEST_REGISTER_FUNCTION(inline, proxy(), decorators) \
2193#define DOCTEST_TEST_CASE(decorators) \
2194 DOCTEST_CREATE_AND_REGISTER_FUNCTION(DOCTEST_ANONYMOUS(DOCTEST_ANON_FUNC_), decorators)
2197#if DOCTEST_CPLUSPLUS >= 201703L
2198#define DOCTEST_TEST_CASE_CLASS(decorators) \
2199 DOCTEST_CREATE_AND_REGISTER_FUNCTION_IN_CLASS(DOCTEST_ANONYMOUS(DOCTEST_ANON_FUNC_), \
2200 DOCTEST_ANONYMOUS(DOCTEST_ANON_PROXY_), \
2203#define DOCTEST_TEST_CASE_CLASS(...) \
2204 TEST_CASES_CAN_BE_REGISTERED_IN_CLASSES_ONLY_IN_CPP17_MODE_OR_WITH_VS_2017_OR_NEWER
2208#define DOCTEST_TEST_CASE_FIXTURE(c, decorators) \
2209 DOCTEST_IMPLEMENT_FIXTURE(DOCTEST_ANONYMOUS(DOCTEST_ANON_CLASS_), c, \
2210 DOCTEST_ANONYMOUS(DOCTEST_ANON_FUNC_), decorators)
2213#define DOCTEST_TYPE_TO_STRING_AS(str, ...) \
2214 namespace doctest { \
2216 inline String toString<__VA_ARGS__>() { \
2220 static_assert(true, "")
2222#define DOCTEST_TYPE_TO_STRING(...) DOCTEST_TYPE_TO_STRING_AS(#__VA_ARGS__, __VA_ARGS__)
2224#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, iter, func) \
2225 template <typename T> \
2226 static void func(); \
2228 template <typename Tuple> \
2230 template <typename Type, typename... Rest> \
2231 struct iter<std::tuple<Type, Rest...>> \
2233 iter(const char* file, unsigned line, int index) { \
2234 doctest::detail::regTest(doctest::detail::TestCase(func<Type>, file, line, \
2235 doctest_detail_test_suite_ns::getCurrentTestSuite(), \
2236 doctest::toString<Type>(), \
2237 int(line) * 1000 + index) \
2239 iter<std::tuple<Rest...>>(file, line, index + 1); \
2243 struct iter<std::tuple<>> \
2245 iter(const char*, unsigned, int) {} \
2248 template <typename T> \
2251#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE(dec, T, id) \
2252 DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, DOCTEST_CAT(id, ITERATOR), \
2253 DOCTEST_ANONYMOUS(DOCTEST_ANON_TMP_))
2255#define DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(id, anon, ...) \
2256 DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_CAT(anon, DUMMY), \
2257 doctest::detail::instantiationHelper( \
2258 DOCTEST_CAT(id, ITERATOR)<__VA_ARGS__>(__FILE__, __LINE__, 0)))
2260#define DOCTEST_TEST_CASE_TEMPLATE_INVOKE(id, ...) \
2261 DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(id, DOCTEST_ANONYMOUS(DOCTEST_ANON_TMP_), std::tuple<__VA_ARGS__>) \
2262 static_assert(true, "")
2264#define DOCTEST_TEST_CASE_TEMPLATE_APPLY(id, ...) \
2265 DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(id, DOCTEST_ANONYMOUS(DOCTEST_ANON_TMP_), __VA_ARGS__) \
2266 static_assert(true, "")
2268#define DOCTEST_TEST_CASE_TEMPLATE_IMPL(dec, T, anon, ...) \
2269 DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, DOCTEST_CAT(anon, ITERATOR), anon); \
2270 DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(anon, anon, std::tuple<__VA_ARGS__>) \
2271 template <typename T> \
2274#define DOCTEST_TEST_CASE_TEMPLATE(dec, T, ...) \
2275 DOCTEST_TEST_CASE_TEMPLATE_IMPL(dec, T, DOCTEST_ANONYMOUS(DOCTEST_ANON_TMP_), __VA_ARGS__)
2278#define DOCTEST_SUBCASE(name) \
2279 if(const doctest::detail::Subcase & DOCTEST_ANONYMOUS(DOCTEST_ANON_SUBCASE_) DOCTEST_UNUSED = \
2280 doctest::detail::Subcase(name, __FILE__, __LINE__))
2283#define DOCTEST_TEST_SUITE_IMPL(decorators, ns_name) \
2284 namespace ns_name { namespace doctest_detail_test_suite_ns { \
2285 static DOCTEST_NOINLINE doctest::detail::TestSuite& getCurrentTestSuite() noexcept { \
2286 DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4640) \
2287 DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wexit-time-destructors") \
2288 DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wmissing-field-initializers") \
2289 static doctest::detail::TestSuite data{}; \
2290 static bool inited = false; \
2291 DOCTEST_MSVC_SUPPRESS_WARNING_POP \
2292 DOCTEST_CLANG_SUPPRESS_WARNING_POP \
2293 DOCTEST_GCC_SUPPRESS_WARNING_POP \
2304#define DOCTEST_TEST_SUITE(decorators) \
2305 DOCTEST_TEST_SUITE_IMPL(decorators, DOCTEST_ANONYMOUS(DOCTEST_ANON_SUITE_))
2308#define DOCTEST_TEST_SUITE_BEGIN(decorators) \
2309 DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(DOCTEST_ANON_VAR_), \
2310 doctest::detail::setTestSuite(doctest::detail::TestSuite() * decorators)) \
2311 static_assert(true, "")
2314#define DOCTEST_TEST_SUITE_END \
2315 DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(DOCTEST_ANON_VAR_), \
2316 doctest::detail::setTestSuite(doctest::detail::TestSuite() * "")) \
2317 using DOCTEST_ANONYMOUS(DOCTEST_ANON_FOR_SEMICOLON_) = int
2320#define DOCTEST_REGISTER_EXCEPTION_TRANSLATOR_IMPL(translatorName, signature) \
2321 inline doctest::String translatorName(signature); \
2322 DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(DOCTEST_ANON_TRANSLATOR_), \
2323 doctest::registerExceptionTranslator(translatorName)) \
2324 doctest::String translatorName(signature)
2326#define DOCTEST_REGISTER_EXCEPTION_TRANSLATOR(signature) \
2327 DOCTEST_REGISTER_EXCEPTION_TRANSLATOR_IMPL(DOCTEST_ANONYMOUS(DOCTEST_ANON_TRANSLATOR_), \
2331#define DOCTEST_REGISTER_REPORTER(name, priority, reporter) \
2332 DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(DOCTEST_ANON_REPORTER_), \
2333 doctest::registerReporter<reporter>(name, priority, true)) \
2334 static_assert(true, "")
2337#define DOCTEST_REGISTER_LISTENER(name, priority, reporter) \
2338 DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(DOCTEST_ANON_REPORTER_), \
2339 doctest::registerReporter<reporter>(name, priority, false)) \
2340 static_assert(true, "")
2344#define DOCTEST_INFO(...) \
2345 DOCTEST_INFO_IMPL(DOCTEST_ANONYMOUS(DOCTEST_CAPTURE_), \
2346 DOCTEST_ANONYMOUS(DOCTEST_CAPTURE_OTHER_), \
2350#define DOCTEST_INFO_IMPL(mb_name, s_name, ...) \
2351 auto DOCTEST_ANONYMOUS(DOCTEST_CAPTURE_) = doctest::detail::MakeContextScope( \
2352 [&](std::ostream* s_name) { \
2353 doctest::detail::MessageBuilder mb_name(__FILE__, __LINE__, doctest::assertType::is_warn); \
2354 mb_name.m_stream = s_name; \
2355 mb_name * __VA_ARGS__; \
2358#define DOCTEST_CAPTURE(x) DOCTEST_INFO(#x " := ", x)
2360#define DOCTEST_ADD_AT_IMPL(type, file, line, mb, ...) \
2361 DOCTEST_FUNC_SCOPE_BEGIN { \
2362 doctest::detail::MessageBuilder mb(file, line, doctest::assertType::type); \
2365 DOCTEST_BREAK_INTO_DEBUGGER(); \
2367 } DOCTEST_FUNC_SCOPE_END
2370#define DOCTEST_ADD_MESSAGE_AT(file, line, ...) DOCTEST_ADD_AT_IMPL(is_warn, file, line, DOCTEST_ANONYMOUS(DOCTEST_MESSAGE_), __VA_ARGS__)
2371#define DOCTEST_ADD_FAIL_CHECK_AT(file, line, ...) DOCTEST_ADD_AT_IMPL(is_check, file, line, DOCTEST_ANONYMOUS(DOCTEST_MESSAGE_), __VA_ARGS__)
2372#define DOCTEST_ADD_FAIL_AT(file, line, ...) DOCTEST_ADD_AT_IMPL(is_require, file, line, DOCTEST_ANONYMOUS(DOCTEST_MESSAGE_), __VA_ARGS__)
2375#define DOCTEST_MESSAGE(...) DOCTEST_ADD_MESSAGE_AT(__FILE__, __LINE__, __VA_ARGS__)
2376#define DOCTEST_FAIL_CHECK(...) DOCTEST_ADD_FAIL_CHECK_AT(__FILE__, __LINE__, __VA_ARGS__)
2377#define DOCTEST_FAIL(...) DOCTEST_ADD_FAIL_AT(__FILE__, __LINE__, __VA_ARGS__)
2379#define DOCTEST_TO_LVALUE(...) __VA_ARGS__
2381#ifndef DOCTEST_CONFIG_SUPER_FAST_ASSERTS
2383#define DOCTEST_ASSERT_IMPLEMENT_2(assert_type, ...) \
2384 DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Woverloaded-shift-op-parentheses") \
2386 doctest::detail::ResultBuilder DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \
2387 __LINE__, #__VA_ARGS__); \
2388 DOCTEST_WRAP_IN_TRY(DOCTEST_RB.setResult( \
2389 doctest::detail::ExpressionDecomposer(doctest::assertType::assert_type) \
2391 DOCTEST_ASSERT_LOG_REACT_RETURN(DOCTEST_RB) \
2392 DOCTEST_CLANG_SUPPRESS_WARNING_POP
2394#define DOCTEST_ASSERT_IMPLEMENT_1(assert_type, ...) \
2395 DOCTEST_FUNC_SCOPE_BEGIN { \
2396 DOCTEST_ASSERT_IMPLEMENT_2(assert_type, __VA_ARGS__); \
2397 } DOCTEST_FUNC_SCOPE_END
2399#define DOCTEST_BINARY_ASSERT(assert_type, comp, ...) \
2400 DOCTEST_FUNC_SCOPE_BEGIN { \
2401 doctest::detail::ResultBuilder DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \
2402 __LINE__, #__VA_ARGS__); \
2403 DOCTEST_WRAP_IN_TRY( \
2404 DOCTEST_RB.binary_assert<doctest::detail::binaryAssertComparison::comp>( \
2406 DOCTEST_ASSERT_LOG_REACT_RETURN(DOCTEST_RB); \
2407 } DOCTEST_FUNC_SCOPE_END
2409#define DOCTEST_UNARY_ASSERT(assert_type, ...) \
2410 DOCTEST_FUNC_SCOPE_BEGIN { \
2411 doctest::detail::ResultBuilder DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \
2412 __LINE__, #__VA_ARGS__); \
2413 DOCTEST_WRAP_IN_TRY(DOCTEST_RB.unary_assert(__VA_ARGS__)) \
2414 DOCTEST_ASSERT_LOG_REACT_RETURN(DOCTEST_RB); \
2415 } DOCTEST_FUNC_SCOPE_END
2420#define DOCTEST_ASSERT_IMPLEMENT_2 DOCTEST_ASSERT_IMPLEMENT_1
2422#define DOCTEST_ASSERT_IMPLEMENT_1(assert_type, ...) \
2423 DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Woverloaded-shift-op-parentheses") \
2424 doctest::detail::decomp_assert( \
2425 doctest::assertType::assert_type, __FILE__, __LINE__, #__VA_ARGS__, \
2426 doctest::detail::ExpressionDecomposer(doctest::assertType::assert_type) \
2427 << __VA_ARGS__) DOCTEST_CLANG_SUPPRESS_WARNING_POP
2429#define DOCTEST_BINARY_ASSERT(assert_type, comparison, ...) \
2430 doctest::detail::binary_assert<doctest::detail::binaryAssertComparison::comparison>( \
2431 doctest::assertType::assert_type, __FILE__, __LINE__, #__VA_ARGS__, __VA_ARGS__)
2433#define DOCTEST_UNARY_ASSERT(assert_type, ...) \
2434 doctest::detail::unary_assert(doctest::assertType::assert_type, __FILE__, __LINE__, \
2435 #__VA_ARGS__, __VA_ARGS__)
2439#define DOCTEST_WARN(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_WARN, __VA_ARGS__)
2440#define DOCTEST_CHECK(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_CHECK, __VA_ARGS__)
2441#define DOCTEST_REQUIRE(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_REQUIRE, __VA_ARGS__)
2442#define DOCTEST_WARN_FALSE(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_WARN_FALSE, __VA_ARGS__)
2443#define DOCTEST_CHECK_FALSE(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_CHECK_FALSE, __VA_ARGS__)
2444#define DOCTEST_REQUIRE_FALSE(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_REQUIRE_FALSE, __VA_ARGS__)
2447#define DOCTEST_WARN_MESSAGE(cond, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_ASSERT_IMPLEMENT_2(DT_WARN, cond); } DOCTEST_FUNC_SCOPE_END
2448#define DOCTEST_CHECK_MESSAGE(cond, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_ASSERT_IMPLEMENT_2(DT_CHECK, cond); } DOCTEST_FUNC_SCOPE_END
2449#define DOCTEST_REQUIRE_MESSAGE(cond, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_ASSERT_IMPLEMENT_2(DT_REQUIRE, cond); } DOCTEST_FUNC_SCOPE_END
2450#define DOCTEST_WARN_FALSE_MESSAGE(cond, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_ASSERT_IMPLEMENT_2(DT_WARN_FALSE, cond); } DOCTEST_FUNC_SCOPE_END
2451#define DOCTEST_CHECK_FALSE_MESSAGE(cond, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_ASSERT_IMPLEMENT_2(DT_CHECK_FALSE, cond); } DOCTEST_FUNC_SCOPE_END
2452#define DOCTEST_REQUIRE_FALSE_MESSAGE(cond, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_ASSERT_IMPLEMENT_2(DT_REQUIRE_FALSE, cond); } DOCTEST_FUNC_SCOPE_END
2455#define DOCTEST_WARN_EQ(...) DOCTEST_BINARY_ASSERT(DT_WARN_EQ, eq, __VA_ARGS__)
2456#define DOCTEST_CHECK_EQ(...) DOCTEST_BINARY_ASSERT(DT_CHECK_EQ, eq, __VA_ARGS__)
2457#define DOCTEST_REQUIRE_EQ(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_EQ, eq, __VA_ARGS__)
2458#define DOCTEST_WARN_NE(...) DOCTEST_BINARY_ASSERT(DT_WARN_NE, ne, __VA_ARGS__)
2459#define DOCTEST_CHECK_NE(...) DOCTEST_BINARY_ASSERT(DT_CHECK_NE, ne, __VA_ARGS__)
2460#define DOCTEST_REQUIRE_NE(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_NE, ne, __VA_ARGS__)
2461#define DOCTEST_WARN_GT(...) DOCTEST_BINARY_ASSERT(DT_WARN_GT, gt, __VA_ARGS__)
2462#define DOCTEST_CHECK_GT(...) DOCTEST_BINARY_ASSERT(DT_CHECK_GT, gt, __VA_ARGS__)
2463#define DOCTEST_REQUIRE_GT(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_GT, gt, __VA_ARGS__)
2464#define DOCTEST_WARN_LT(...) DOCTEST_BINARY_ASSERT(DT_WARN_LT, lt, __VA_ARGS__)
2465#define DOCTEST_CHECK_LT(...) DOCTEST_BINARY_ASSERT(DT_CHECK_LT, lt, __VA_ARGS__)
2466#define DOCTEST_REQUIRE_LT(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_LT, lt, __VA_ARGS__)
2467#define DOCTEST_WARN_GE(...) DOCTEST_BINARY_ASSERT(DT_WARN_GE, ge, __VA_ARGS__)
2468#define DOCTEST_CHECK_GE(...) DOCTEST_BINARY_ASSERT(DT_CHECK_GE, ge, __VA_ARGS__)
2469#define DOCTEST_REQUIRE_GE(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_GE, ge, __VA_ARGS__)
2470#define DOCTEST_WARN_LE(...) DOCTEST_BINARY_ASSERT(DT_WARN_LE, le, __VA_ARGS__)
2471#define DOCTEST_CHECK_LE(...) DOCTEST_BINARY_ASSERT(DT_CHECK_LE, le, __VA_ARGS__)
2472#define DOCTEST_REQUIRE_LE(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_LE, le, __VA_ARGS__)
2474#define DOCTEST_WARN_UNARY(...) DOCTEST_UNARY_ASSERT(DT_WARN_UNARY, __VA_ARGS__)
2475#define DOCTEST_CHECK_UNARY(...) DOCTEST_UNARY_ASSERT(DT_CHECK_UNARY, __VA_ARGS__)
2476#define DOCTEST_REQUIRE_UNARY(...) DOCTEST_UNARY_ASSERT(DT_REQUIRE_UNARY, __VA_ARGS__)
2477#define DOCTEST_WARN_UNARY_FALSE(...) DOCTEST_UNARY_ASSERT(DT_WARN_UNARY_FALSE, __VA_ARGS__)
2478#define DOCTEST_CHECK_UNARY_FALSE(...) DOCTEST_UNARY_ASSERT(DT_CHECK_UNARY_FALSE, __VA_ARGS__)
2479#define DOCTEST_REQUIRE_UNARY_FALSE(...) DOCTEST_UNARY_ASSERT(DT_REQUIRE_UNARY_FALSE, __VA_ARGS__)
2481#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
2483#define DOCTEST_ASSERT_THROWS_AS(expr, assert_type, message, ...) \
2484 DOCTEST_FUNC_SCOPE_BEGIN { \
2485 if(!doctest::getContextOptions()->no_throw) { \
2486 doctest::detail::ResultBuilder DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \
2487 __LINE__, #expr, #__VA_ARGS__, message); \
2489 DOCTEST_CAST_TO_VOID(expr) \
2490 } catch(const typename doctest::detail::types::remove_const< \
2491 typename doctest::detail::types::remove_reference<__VA_ARGS__>::type>::type&) {\
2492 DOCTEST_RB.translateException(); \
2493 DOCTEST_RB.m_threw_as = true; \
2494 } catch(...) { DOCTEST_RB.translateException(); } \
2495 DOCTEST_ASSERT_LOG_REACT_RETURN(DOCTEST_RB); \
2497 DOCTEST_FUNC_SCOPE_RET(false); \
2499 } DOCTEST_FUNC_SCOPE_END
2501#define DOCTEST_ASSERT_THROWS_WITH(expr, expr_str, assert_type, ...) \
2502 DOCTEST_FUNC_SCOPE_BEGIN { \
2503 if(!doctest::getContextOptions()->no_throw) { \
2504 doctest::detail::ResultBuilder DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \
2505 __LINE__, expr_str, "", __VA_ARGS__); \
2507 DOCTEST_CAST_TO_VOID(expr) \
2508 } catch(...) { DOCTEST_RB.translateException(); } \
2509 DOCTEST_ASSERT_LOG_REACT_RETURN(DOCTEST_RB); \
2511 DOCTEST_FUNC_SCOPE_RET(false); \
2513 } DOCTEST_FUNC_SCOPE_END
2515#define DOCTEST_ASSERT_NOTHROW(assert_type, ...) \
2516 DOCTEST_FUNC_SCOPE_BEGIN { \
2517 doctest::detail::ResultBuilder DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \
2518 __LINE__, #__VA_ARGS__); \
2520 DOCTEST_CAST_TO_VOID(__VA_ARGS__) \
2521 } catch(...) { DOCTEST_RB.translateException(); } \
2522 DOCTEST_ASSERT_LOG_REACT_RETURN(DOCTEST_RB); \
2523 } DOCTEST_FUNC_SCOPE_END
2526#define DOCTEST_WARN_THROWS(...) DOCTEST_ASSERT_THROWS_WITH((__VA_ARGS__), #__VA_ARGS__, DT_WARN_THROWS, "")
2527#define DOCTEST_CHECK_THROWS(...) DOCTEST_ASSERT_THROWS_WITH((__VA_ARGS__), #__VA_ARGS__, DT_CHECK_THROWS, "")
2528#define DOCTEST_REQUIRE_THROWS(...) DOCTEST_ASSERT_THROWS_WITH((__VA_ARGS__), #__VA_ARGS__, DT_REQUIRE_THROWS, "")
2530#define DOCTEST_WARN_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_WARN_THROWS_AS, "", __VA_ARGS__)
2531#define DOCTEST_CHECK_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_CHECK_THROWS_AS, "", __VA_ARGS__)
2532#define DOCTEST_REQUIRE_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_REQUIRE_THROWS_AS, "", __VA_ARGS__)
2534#define DOCTEST_WARN_THROWS_WITH(expr, ...) DOCTEST_ASSERT_THROWS_WITH(expr, #expr, DT_WARN_THROWS_WITH, __VA_ARGS__)
2535#define DOCTEST_CHECK_THROWS_WITH(expr, ...) DOCTEST_ASSERT_THROWS_WITH(expr, #expr, DT_CHECK_THROWS_WITH, __VA_ARGS__)
2536#define DOCTEST_REQUIRE_THROWS_WITH(expr, ...) DOCTEST_ASSERT_THROWS_WITH(expr, #expr, DT_REQUIRE_THROWS_WITH, __VA_ARGS__)
2538#define DOCTEST_WARN_THROWS_WITH_AS(expr, message, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_WARN_THROWS_WITH_AS, message, __VA_ARGS__)
2539#define DOCTEST_CHECK_THROWS_WITH_AS(expr, message, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_CHECK_THROWS_WITH_AS, message, __VA_ARGS__)
2540#define DOCTEST_REQUIRE_THROWS_WITH_AS(expr, message, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_REQUIRE_THROWS_WITH_AS, message, __VA_ARGS__)
2542#define DOCTEST_WARN_NOTHROW(...) DOCTEST_ASSERT_NOTHROW(DT_WARN_NOTHROW, __VA_ARGS__)
2543#define DOCTEST_CHECK_NOTHROW(...) DOCTEST_ASSERT_NOTHROW(DT_CHECK_NOTHROW, __VA_ARGS__)
2544#define DOCTEST_REQUIRE_NOTHROW(...) DOCTEST_ASSERT_NOTHROW(DT_REQUIRE_NOTHROW, __VA_ARGS__)
2546#define DOCTEST_WARN_THROWS_MESSAGE(expr, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_WARN_THROWS(expr); } DOCTEST_FUNC_SCOPE_END
2547#define DOCTEST_CHECK_THROWS_MESSAGE(expr, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_CHECK_THROWS(expr); } DOCTEST_FUNC_SCOPE_END
2548#define DOCTEST_REQUIRE_THROWS_MESSAGE(expr, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_REQUIRE_THROWS(expr); } DOCTEST_FUNC_SCOPE_END
2549#define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_WARN_THROWS_AS(expr, ex); } DOCTEST_FUNC_SCOPE_END
2550#define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_CHECK_THROWS_AS(expr, ex); } DOCTEST_FUNC_SCOPE_END
2551#define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_REQUIRE_THROWS_AS(expr, ex); } DOCTEST_FUNC_SCOPE_END
2552#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_WARN_THROWS_WITH(expr, with); } DOCTEST_FUNC_SCOPE_END
2553#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_CHECK_THROWS_WITH(expr, with); } DOCTEST_FUNC_SCOPE_END
2554#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_REQUIRE_THROWS_WITH(expr, with); } DOCTEST_FUNC_SCOPE_END
2555#define DOCTEST_WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_WARN_THROWS_WITH_AS(expr, with, ex); } DOCTEST_FUNC_SCOPE_END
2556#define DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_CHECK_THROWS_WITH_AS(expr, with, ex); } DOCTEST_FUNC_SCOPE_END
2557#define DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_REQUIRE_THROWS_WITH_AS(expr, with, ex); } DOCTEST_FUNC_SCOPE_END
2558#define DOCTEST_WARN_NOTHROW_MESSAGE(expr, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_WARN_NOTHROW(expr); } DOCTEST_FUNC_SCOPE_END
2559#define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_CHECK_NOTHROW(expr); } DOCTEST_FUNC_SCOPE_END
2560#define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_REQUIRE_NOTHROW(expr); } DOCTEST_FUNC_SCOPE_END
2571#define DOCTEST_IMPLEMENT_FIXTURE(der, base, func, name) \
2573 template <typename DOCTEST_UNUSED_TEMPLATE_TYPE> \
2574 struct der : public base \
2577 template <typename DOCTEST_UNUSED_TEMPLATE_TYPE> \
2578 inline void der<DOCTEST_UNUSED_TEMPLATE_TYPE>::f()
2580#define DOCTEST_CREATE_AND_REGISTER_FUNCTION(f, name) \
2581 template <typename DOCTEST_UNUSED_TEMPLATE_TYPE> \
2582 static inline void f()
2585#define DOCTEST_TEST_CASE(name) \
2586 DOCTEST_CREATE_AND_REGISTER_FUNCTION(DOCTEST_ANONYMOUS(DOCTEST_ANON_FUNC_), name)
2589#define DOCTEST_TEST_CASE_CLASS(name) \
2590 DOCTEST_CREATE_AND_REGISTER_FUNCTION(DOCTEST_ANONYMOUS(DOCTEST_ANON_FUNC_), name)
2593#define DOCTEST_TEST_CASE_FIXTURE(x, name) \
2594 DOCTEST_IMPLEMENT_FIXTURE(DOCTEST_ANONYMOUS(DOCTEST_ANON_CLASS_), x, \
2595 DOCTEST_ANONYMOUS(DOCTEST_ANON_FUNC_), name)
2598#define DOCTEST_TYPE_TO_STRING_AS(str, ...) static_assert(true, "")
2599#define DOCTEST_TYPE_TO_STRING(...) static_assert(true, "")
2602#define DOCTEST_TEST_CASE_TEMPLATE(name, type, ...) \
2603 template <typename type> \
2604 inline void DOCTEST_ANONYMOUS(DOCTEST_ANON_TMP_)()
2606#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE(name, type, id) \
2607 template <typename type> \
2608 inline void DOCTEST_ANONYMOUS(DOCTEST_ANON_TMP_)()
2610#define DOCTEST_TEST_CASE_TEMPLATE_INVOKE(id, ...) static_assert(true, "")
2611#define DOCTEST_TEST_CASE_TEMPLATE_APPLY(id, ...) static_assert(true, "")
2614#define DOCTEST_SUBCASE(name)
2617#define DOCTEST_TEST_SUITE(name) namespace
2620#define DOCTEST_TEST_SUITE_BEGIN(name) static_assert(true, "")
2623#define DOCTEST_TEST_SUITE_END using DOCTEST_ANONYMOUS(DOCTEST_ANON_FOR_SEMICOLON_) = int
2625#define DOCTEST_REGISTER_EXCEPTION_TRANSLATOR(signature) \
2626 template <typename DOCTEST_UNUSED_TEMPLATE_TYPE> \
2627 static inline doctest::String DOCTEST_ANONYMOUS(DOCTEST_ANON_TRANSLATOR_)(signature)
2629#define DOCTEST_REGISTER_REPORTER(name, priority, reporter)
2630#define DOCTEST_REGISTER_LISTENER(name, priority, reporter)
2632#define DOCTEST_INFO(...) (static_cast<void>(0))
2633#define DOCTEST_CAPTURE(x) (static_cast<void>(0))
2634#define DOCTEST_ADD_MESSAGE_AT(file, line, ...) (static_cast<void>(0))
2635#define DOCTEST_ADD_FAIL_CHECK_AT(file, line, ...) (static_cast<void>(0))
2636#define DOCTEST_ADD_FAIL_AT(file, line, ...) (static_cast<void>(0))
2637#define DOCTEST_MESSAGE(...) (static_cast<void>(0))
2638#define DOCTEST_FAIL_CHECK(...) (static_cast<void>(0))
2639#define DOCTEST_FAIL(...) (static_cast<void>(0))
2641#if defined(DOCTEST_CONFIG_EVALUATE_ASSERTS_EVEN_WHEN_DISABLED) \
2642 && defined(DOCTEST_CONFIG_ASSERTS_RETURN_VALUES)
2644#define DOCTEST_WARN(...) [&] { return __VA_ARGS__; }()
2645#define DOCTEST_CHECK(...) [&] { return __VA_ARGS__; }()
2646#define DOCTEST_REQUIRE(...) [&] { return __VA_ARGS__; }()
2647#define DOCTEST_WARN_FALSE(...) [&] { return !(__VA_ARGS__); }()
2648#define DOCTEST_CHECK_FALSE(...) [&] { return !(__VA_ARGS__); }()
2649#define DOCTEST_REQUIRE_FALSE(...) [&] { return !(__VA_ARGS__); }()
2651#define DOCTEST_WARN_MESSAGE(cond, ...) [&] { return cond; }()
2652#define DOCTEST_CHECK_MESSAGE(cond, ...) [&] { return cond; }()
2653#define DOCTEST_REQUIRE_MESSAGE(cond, ...) [&] { return cond; }()
2654#define DOCTEST_WARN_FALSE_MESSAGE(cond, ...) [&] { return !(cond); }()
2655#define DOCTEST_CHECK_FALSE_MESSAGE(cond, ...) [&] { return !(cond); }()
2656#define DOCTEST_REQUIRE_FALSE_MESSAGE(cond, ...) [&] { return !(cond); }()
2660#define DOCTEST_RELATIONAL_OP(name, op) \
2661 template <typename L, typename R> \
2662 bool name(const DOCTEST_REF_WRAP(L) lhs, const DOCTEST_REF_WRAP(R) rhs) { return lhs op rhs; }
2673#define DOCTEST_WARN_EQ(...) [&] { return doctest::detail::eq(__VA_ARGS__); }()
2674#define DOCTEST_CHECK_EQ(...) [&] { return doctest::detail::eq(__VA_ARGS__); }()
2675#define DOCTEST_REQUIRE_EQ(...) [&] { return doctest::detail::eq(__VA_ARGS__); }()
2676#define DOCTEST_WARN_NE(...) [&] { return doctest::detail::ne(__VA_ARGS__); }()
2677#define DOCTEST_CHECK_NE(...) [&] { return doctest::detail::ne(__VA_ARGS__); }()
2678#define DOCTEST_REQUIRE_NE(...) [&] { return doctest::detail::ne(__VA_ARGS__); }()
2679#define DOCTEST_WARN_LT(...) [&] { return doctest::detail::lt(__VA_ARGS__); }()
2680#define DOCTEST_CHECK_LT(...) [&] { return doctest::detail::lt(__VA_ARGS__); }()
2681#define DOCTEST_REQUIRE_LT(...) [&] { return doctest::detail::lt(__VA_ARGS__); }()
2682#define DOCTEST_WARN_GT(...) [&] { return doctest::detail::gt(__VA_ARGS__); }()
2683#define DOCTEST_CHECK_GT(...) [&] { return doctest::detail::gt(__VA_ARGS__); }()
2684#define DOCTEST_REQUIRE_GT(...) [&] { return doctest::detail::gt(__VA_ARGS__); }()
2685#define DOCTEST_WARN_LE(...) [&] { return doctest::detail::le(__VA_ARGS__); }()
2686#define DOCTEST_CHECK_LE(...) [&] { return doctest::detail::le(__VA_ARGS__); }()
2687#define DOCTEST_REQUIRE_LE(...) [&] { return doctest::detail::le(__VA_ARGS__); }()
2688#define DOCTEST_WARN_GE(...) [&] { return doctest::detail::ge(__VA_ARGS__); }()
2689#define DOCTEST_CHECK_GE(...) [&] { return doctest::detail::ge(__VA_ARGS__); }()
2690#define DOCTEST_REQUIRE_GE(...) [&] { return doctest::detail::ge(__VA_ARGS__); }()
2691#define DOCTEST_WARN_UNARY(...) [&] { return __VA_ARGS__; }()
2692#define DOCTEST_CHECK_UNARY(...) [&] { return __VA_ARGS__; }()
2693#define DOCTEST_REQUIRE_UNARY(...) [&] { return __VA_ARGS__; }()
2694#define DOCTEST_WARN_UNARY_FALSE(...) [&] { return !(__VA_ARGS__); }()
2695#define DOCTEST_CHECK_UNARY_FALSE(...) [&] { return !(__VA_ARGS__); }()
2696#define DOCTEST_REQUIRE_UNARY_FALSE(...) [&] { return !(__VA_ARGS__); }()
2698#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
2700#define DOCTEST_WARN_THROWS_WITH(expr, with, ...) [] { static_assert(false, "Exception translation is not available when doctest is disabled."); return false; }()
2701#define DOCTEST_CHECK_THROWS_WITH(expr, with, ...) DOCTEST_WARN_THROWS_WITH(,,)
2702#define DOCTEST_REQUIRE_THROWS_WITH(expr, with, ...) DOCTEST_WARN_THROWS_WITH(,,)
2703#define DOCTEST_WARN_THROWS_WITH_AS(expr, with, ex, ...) DOCTEST_WARN_THROWS_WITH(,,)
2704#define DOCTEST_CHECK_THROWS_WITH_AS(expr, with, ex, ...) DOCTEST_WARN_THROWS_WITH(,,)
2705#define DOCTEST_REQUIRE_THROWS_WITH_AS(expr, with, ex, ...) DOCTEST_WARN_THROWS_WITH(,,)
2707#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_WARN_THROWS_WITH(,,)
2708#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_WARN_THROWS_WITH(,,)
2709#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_WARN_THROWS_WITH(,,)
2710#define DOCTEST_WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_WARN_THROWS_WITH(,,)
2711#define DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_WARN_THROWS_WITH(,,)
2712#define DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_WARN_THROWS_WITH(,,)
2714#define DOCTEST_WARN_THROWS(...) [&] { try { __VA_ARGS__; return false; } catch (...) { return true; } }()
2715#define DOCTEST_CHECK_THROWS(...) [&] { try { __VA_ARGS__; return false; } catch (...) { return true; } }()
2716#define DOCTEST_REQUIRE_THROWS(...) [&] { try { __VA_ARGS__; return false; } catch (...) { return true; } }()
2717#define DOCTEST_WARN_THROWS_AS(expr, ...) [&] { try { expr; } catch (__VA_ARGS__) { return true; } catch (...) { } return false; }()
2718#define DOCTEST_CHECK_THROWS_AS(expr, ...) [&] { try { expr; } catch (__VA_ARGS__) { return true; } catch (...) { } return false; }()
2719#define DOCTEST_REQUIRE_THROWS_AS(expr, ...) [&] { try { expr; } catch (__VA_ARGS__) { return true; } catch (...) { } return false; }()
2720#define DOCTEST_WARN_NOTHROW(...) [&] { try { __VA_ARGS__; return true; } catch (...) { return false; } }()
2721#define DOCTEST_CHECK_NOTHROW(...) [&] { try { __VA_ARGS__; return true; } catch (...) { return false; } }()
2722#define DOCTEST_REQUIRE_NOTHROW(...) [&] { try { __VA_ARGS__; return true; } catch (...) { return false; } }()
2724#define DOCTEST_WARN_THROWS_MESSAGE(expr, ...) [&] { try { __VA_ARGS__; return false; } catch (...) { return true; } }()
2725#define DOCTEST_CHECK_THROWS_MESSAGE(expr, ...) [&] { try { __VA_ARGS__; return false; } catch (...) { return true; } }()
2726#define DOCTEST_REQUIRE_THROWS_MESSAGE(expr, ...) [&] { try { __VA_ARGS__; return false; } catch (...) { return true; } }()
2727#define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, ...) [&] { try { expr; } catch (__VA_ARGS__) { return true; } catch (...) { } return false; }()
2728#define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, ...) [&] { try { expr; } catch (__VA_ARGS__) { return true; } catch (...) { } return false; }()
2729#define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, ...) [&] { try { expr; } catch (__VA_ARGS__) { return true; } catch (...) { } return false; }()
2730#define DOCTEST_WARN_NOTHROW_MESSAGE(expr, ...) [&] { try { __VA_ARGS__; return true; } catch (...) { return false; } }()
2731#define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, ...) [&] { try { __VA_ARGS__; return true; } catch (...) { return false; } }()
2732#define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, ...) [&] { try { __VA_ARGS__; return true; } catch (...) { return false; } }()
2738#define DOCTEST_WARN(...) DOCTEST_FUNC_EMPTY
2739#define DOCTEST_CHECK(...) DOCTEST_FUNC_EMPTY
2740#define DOCTEST_REQUIRE(...) DOCTEST_FUNC_EMPTY
2741#define DOCTEST_WARN_FALSE(...) DOCTEST_FUNC_EMPTY
2742#define DOCTEST_CHECK_FALSE(...) DOCTEST_FUNC_EMPTY
2743#define DOCTEST_REQUIRE_FALSE(...) DOCTEST_FUNC_EMPTY
2745#define DOCTEST_WARN_MESSAGE(cond, ...) DOCTEST_FUNC_EMPTY
2746#define DOCTEST_CHECK_MESSAGE(cond, ...) DOCTEST_FUNC_EMPTY
2747#define DOCTEST_REQUIRE_MESSAGE(cond, ...) DOCTEST_FUNC_EMPTY
2748#define DOCTEST_WARN_FALSE_MESSAGE(cond, ...) DOCTEST_FUNC_EMPTY
2749#define DOCTEST_CHECK_FALSE_MESSAGE(cond, ...) DOCTEST_FUNC_EMPTY
2750#define DOCTEST_REQUIRE_FALSE_MESSAGE(cond, ...) DOCTEST_FUNC_EMPTY
2752#define DOCTEST_WARN_EQ(...) DOCTEST_FUNC_EMPTY
2753#define DOCTEST_CHECK_EQ(...) DOCTEST_FUNC_EMPTY
2754#define DOCTEST_REQUIRE_EQ(...) DOCTEST_FUNC_EMPTY
2755#define DOCTEST_WARN_NE(...) DOCTEST_FUNC_EMPTY
2756#define DOCTEST_CHECK_NE(...) DOCTEST_FUNC_EMPTY
2757#define DOCTEST_REQUIRE_NE(...) DOCTEST_FUNC_EMPTY
2758#define DOCTEST_WARN_GT(...) DOCTEST_FUNC_EMPTY
2759#define DOCTEST_CHECK_GT(...) DOCTEST_FUNC_EMPTY
2760#define DOCTEST_REQUIRE_GT(...) DOCTEST_FUNC_EMPTY
2761#define DOCTEST_WARN_LT(...) DOCTEST_FUNC_EMPTY
2762#define DOCTEST_CHECK_LT(...) DOCTEST_FUNC_EMPTY
2763#define DOCTEST_REQUIRE_LT(...) DOCTEST_FUNC_EMPTY
2764#define DOCTEST_WARN_GE(...) DOCTEST_FUNC_EMPTY
2765#define DOCTEST_CHECK_GE(...) DOCTEST_FUNC_EMPTY
2766#define DOCTEST_REQUIRE_GE(...) DOCTEST_FUNC_EMPTY
2767#define DOCTEST_WARN_LE(...) DOCTEST_FUNC_EMPTY
2768#define DOCTEST_CHECK_LE(...) DOCTEST_FUNC_EMPTY
2769#define DOCTEST_REQUIRE_LE(...) DOCTEST_FUNC_EMPTY
2771#define DOCTEST_WARN_UNARY(...) DOCTEST_FUNC_EMPTY
2772#define DOCTEST_CHECK_UNARY(...) DOCTEST_FUNC_EMPTY
2773#define DOCTEST_REQUIRE_UNARY(...) DOCTEST_FUNC_EMPTY
2774#define DOCTEST_WARN_UNARY_FALSE(...) DOCTEST_FUNC_EMPTY
2775#define DOCTEST_CHECK_UNARY_FALSE(...) DOCTEST_FUNC_EMPTY
2776#define DOCTEST_REQUIRE_UNARY_FALSE(...) DOCTEST_FUNC_EMPTY
2778#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
2780#define DOCTEST_WARN_THROWS(...) DOCTEST_FUNC_EMPTY
2781#define DOCTEST_CHECK_THROWS(...) DOCTEST_FUNC_EMPTY
2782#define DOCTEST_REQUIRE_THROWS(...) DOCTEST_FUNC_EMPTY
2783#define DOCTEST_WARN_THROWS_AS(expr, ...) DOCTEST_FUNC_EMPTY
2784#define DOCTEST_CHECK_THROWS_AS(expr, ...) DOCTEST_FUNC_EMPTY
2785#define DOCTEST_REQUIRE_THROWS_AS(expr, ...) DOCTEST_FUNC_EMPTY
2786#define DOCTEST_WARN_THROWS_WITH(expr, ...) DOCTEST_FUNC_EMPTY
2787#define DOCTEST_CHECK_THROWS_WITH(expr, ...) DOCTEST_FUNC_EMPTY
2788#define DOCTEST_REQUIRE_THROWS_WITH(expr, ...) DOCTEST_FUNC_EMPTY
2789#define DOCTEST_WARN_THROWS_WITH_AS(expr, with, ...) DOCTEST_FUNC_EMPTY
2790#define DOCTEST_CHECK_THROWS_WITH_AS(expr, with, ...) DOCTEST_FUNC_EMPTY
2791#define DOCTEST_REQUIRE_THROWS_WITH_AS(expr, with, ...) DOCTEST_FUNC_EMPTY
2792#define DOCTEST_WARN_NOTHROW(...) DOCTEST_FUNC_EMPTY
2793#define DOCTEST_CHECK_NOTHROW(...) DOCTEST_FUNC_EMPTY
2794#define DOCTEST_REQUIRE_NOTHROW(...) DOCTEST_FUNC_EMPTY
2796#define DOCTEST_WARN_THROWS_MESSAGE(expr, ...) DOCTEST_FUNC_EMPTY
2797#define DOCTEST_CHECK_THROWS_MESSAGE(expr, ...) DOCTEST_FUNC_EMPTY
2798#define DOCTEST_REQUIRE_THROWS_MESSAGE(expr, ...) DOCTEST_FUNC_EMPTY
2799#define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_FUNC_EMPTY
2800#define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_FUNC_EMPTY
2801#define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_FUNC_EMPTY
2802#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_FUNC_EMPTY
2803#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_FUNC_EMPTY
2804#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_FUNC_EMPTY
2805#define DOCTEST_WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_FUNC_EMPTY
2806#define DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_FUNC_EMPTY
2807#define DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_FUNC_EMPTY
2808#define DOCTEST_WARN_NOTHROW_MESSAGE(expr, ...) DOCTEST_FUNC_EMPTY
2809#define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, ...) DOCTEST_FUNC_EMPTY
2810#define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, ...) DOCTEST_FUNC_EMPTY
2818#ifdef DOCTEST_CONFIG_NO_EXCEPTIONS
2820#ifdef DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS
2821#define DOCTEST_EXCEPTION_EMPTY_FUNC DOCTEST_FUNC_EMPTY
2823#define DOCTEST_EXCEPTION_EMPTY_FUNC [] { static_assert(false, "Exceptions are disabled! " \
2824 "Use DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS if you want to compile with exceptions disabled."); return false; }()
2826#undef DOCTEST_REQUIRE
2827#undef DOCTEST_REQUIRE_FALSE
2828#undef DOCTEST_REQUIRE_MESSAGE
2829#undef DOCTEST_REQUIRE_FALSE_MESSAGE
2830#undef DOCTEST_REQUIRE_EQ
2831#undef DOCTEST_REQUIRE_NE
2832#undef DOCTEST_REQUIRE_GT
2833#undef DOCTEST_REQUIRE_LT
2834#undef DOCTEST_REQUIRE_GE
2835#undef DOCTEST_REQUIRE_LE
2836#undef DOCTEST_REQUIRE_UNARY
2837#undef DOCTEST_REQUIRE_UNARY_FALSE
2839#define DOCTEST_REQUIRE DOCTEST_EXCEPTION_EMPTY_FUNC
2840#define DOCTEST_REQUIRE_FALSE DOCTEST_EXCEPTION_EMPTY_FUNC
2841#define DOCTEST_REQUIRE_MESSAGE DOCTEST_EXCEPTION_EMPTY_FUNC
2842#define DOCTEST_REQUIRE_FALSE_MESSAGE DOCTEST_EXCEPTION_EMPTY_FUNC
2843#define DOCTEST_REQUIRE_EQ DOCTEST_EXCEPTION_EMPTY_FUNC
2844#define DOCTEST_REQUIRE_NE DOCTEST_EXCEPTION_EMPTY_FUNC
2845#define DOCTEST_REQUIRE_GT DOCTEST_EXCEPTION_EMPTY_FUNC
2846#define DOCTEST_REQUIRE_LT DOCTEST_EXCEPTION_EMPTY_FUNC
2847#define DOCTEST_REQUIRE_GE DOCTEST_EXCEPTION_EMPTY_FUNC
2848#define DOCTEST_REQUIRE_LE DOCTEST_EXCEPTION_EMPTY_FUNC
2849#define DOCTEST_REQUIRE_UNARY DOCTEST_EXCEPTION_EMPTY_FUNC
2850#define DOCTEST_REQUIRE_UNARY_FALSE DOCTEST_EXCEPTION_EMPTY_FUNC
2854#define DOCTEST_WARN_THROWS(...) DOCTEST_EXCEPTION_EMPTY_FUNC
2855#define DOCTEST_CHECK_THROWS(...) DOCTEST_EXCEPTION_EMPTY_FUNC
2856#define DOCTEST_REQUIRE_THROWS(...) DOCTEST_EXCEPTION_EMPTY_FUNC
2857#define DOCTEST_WARN_THROWS_AS(expr, ...) DOCTEST_EXCEPTION_EMPTY_FUNC
2858#define DOCTEST_CHECK_THROWS_AS(expr, ...) DOCTEST_EXCEPTION_EMPTY_FUNC
2859#define DOCTEST_REQUIRE_THROWS_AS(expr, ...) DOCTEST_EXCEPTION_EMPTY_FUNC
2860#define DOCTEST_WARN_THROWS_WITH(expr, ...) DOCTEST_EXCEPTION_EMPTY_FUNC
2861#define DOCTEST_CHECK_THROWS_WITH(expr, ...) DOCTEST_EXCEPTION_EMPTY_FUNC
2862#define DOCTEST_REQUIRE_THROWS_WITH(expr, ...) DOCTEST_EXCEPTION_EMPTY_FUNC
2863#define DOCTEST_WARN_THROWS_WITH_AS(expr, with, ...) DOCTEST_EXCEPTION_EMPTY_FUNC
2864#define DOCTEST_CHECK_THROWS_WITH_AS(expr, with, ...) DOCTEST_EXCEPTION_EMPTY_FUNC
2865#define DOCTEST_REQUIRE_THROWS_WITH_AS(expr, with, ...) DOCTEST_EXCEPTION_EMPTY_FUNC
2866#define DOCTEST_WARN_NOTHROW(...) DOCTEST_EXCEPTION_EMPTY_FUNC
2867#define DOCTEST_CHECK_NOTHROW(...) DOCTEST_EXCEPTION_EMPTY_FUNC
2868#define DOCTEST_REQUIRE_NOTHROW(...) DOCTEST_EXCEPTION_EMPTY_FUNC
2870#define DOCTEST_WARN_THROWS_MESSAGE(expr, ...) DOCTEST_EXCEPTION_EMPTY_FUNC
2871#define DOCTEST_CHECK_THROWS_MESSAGE(expr, ...) DOCTEST_EXCEPTION_EMPTY_FUNC
2872#define DOCTEST_REQUIRE_THROWS_MESSAGE(expr, ...) DOCTEST_EXCEPTION_EMPTY_FUNC
2873#define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_EXCEPTION_EMPTY_FUNC
2874#define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_EXCEPTION_EMPTY_FUNC
2875#define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_EXCEPTION_EMPTY_FUNC
2876#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_EXCEPTION_EMPTY_FUNC
2877#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_EXCEPTION_EMPTY_FUNC
2878#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_EXCEPTION_EMPTY_FUNC
2879#define DOCTEST_WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_EXCEPTION_EMPTY_FUNC
2880#define DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_EXCEPTION_EMPTY_FUNC
2881#define DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_EXCEPTION_EMPTY_FUNC
2882#define DOCTEST_WARN_NOTHROW_MESSAGE(expr, ...) DOCTEST_EXCEPTION_EMPTY_FUNC
2883#define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, ...) DOCTEST_EXCEPTION_EMPTY_FUNC
2884#define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, ...) DOCTEST_EXCEPTION_EMPTY_FUNC
2890#define DOCTEST_FAST_WARN_EQ DOCTEST_WARN_EQ
2891#define DOCTEST_FAST_CHECK_EQ DOCTEST_CHECK_EQ
2892#define DOCTEST_FAST_REQUIRE_EQ DOCTEST_REQUIRE_EQ
2893#define DOCTEST_FAST_WARN_NE DOCTEST_WARN_NE
2894#define DOCTEST_FAST_CHECK_NE DOCTEST_CHECK_NE
2895#define DOCTEST_FAST_REQUIRE_NE DOCTEST_REQUIRE_NE
2896#define DOCTEST_FAST_WARN_GT DOCTEST_WARN_GT
2897#define DOCTEST_FAST_CHECK_GT DOCTEST_CHECK_GT
2898#define DOCTEST_FAST_REQUIRE_GT DOCTEST_REQUIRE_GT
2899#define DOCTEST_FAST_WARN_LT DOCTEST_WARN_LT
2900#define DOCTEST_FAST_CHECK_LT DOCTEST_CHECK_LT
2901#define DOCTEST_FAST_REQUIRE_LT DOCTEST_REQUIRE_LT
2902#define DOCTEST_FAST_WARN_GE DOCTEST_WARN_GE
2903#define DOCTEST_FAST_CHECK_GE DOCTEST_CHECK_GE
2904#define DOCTEST_FAST_REQUIRE_GE DOCTEST_REQUIRE_GE
2905#define DOCTEST_FAST_WARN_LE DOCTEST_WARN_LE
2906#define DOCTEST_FAST_CHECK_LE DOCTEST_CHECK_LE
2907#define DOCTEST_FAST_REQUIRE_LE DOCTEST_REQUIRE_LE
2909#define DOCTEST_FAST_WARN_UNARY DOCTEST_WARN_UNARY
2910#define DOCTEST_FAST_CHECK_UNARY DOCTEST_CHECK_UNARY
2911#define DOCTEST_FAST_REQUIRE_UNARY DOCTEST_REQUIRE_UNARY
2912#define DOCTEST_FAST_WARN_UNARY_FALSE DOCTEST_WARN_UNARY_FALSE
2913#define DOCTEST_FAST_CHECK_UNARY_FALSE DOCTEST_CHECK_UNARY_FALSE
2914#define DOCTEST_FAST_REQUIRE_UNARY_FALSE DOCTEST_REQUIRE_UNARY_FALSE
2916#define DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE(id, ...) DOCTEST_TEST_CASE_TEMPLATE_INVOKE(id,__VA_ARGS__)
2921#define DOCTEST_SCENARIO(name) DOCTEST_TEST_CASE(" Scenario: " name)
2922#define DOCTEST_SCENARIO_CLASS(name) DOCTEST_TEST_CASE_CLASS(" Scenario: " name)
2923#define DOCTEST_SCENARIO_TEMPLATE(name, T, ...) DOCTEST_TEST_CASE_TEMPLATE(" Scenario: " name, T, __VA_ARGS__)
2924#define DOCTEST_SCENARIO_TEMPLATE_DEFINE(name, T, id) DOCTEST_TEST_CASE_TEMPLATE_DEFINE(" Scenario: " name, T, id)
2926#define DOCTEST_GIVEN(name) DOCTEST_SUBCASE(" Given: " name)
2927#define DOCTEST_WHEN(name) DOCTEST_SUBCASE(" When: " name)
2928#define DOCTEST_AND_WHEN(name) DOCTEST_SUBCASE("And when: " name)
2929#define DOCTEST_THEN(name) DOCTEST_SUBCASE(" Then: " name)
2930#define DOCTEST_AND_THEN(name) DOCTEST_SUBCASE(" And: " name)
2934#ifndef DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES
2936#define TEST_CASE(name) DOCTEST_TEST_CASE(name)
2937#define TEST_CASE_CLASS(name) DOCTEST_TEST_CASE_CLASS(name)
2938#define TEST_CASE_FIXTURE(x, name) DOCTEST_TEST_CASE_FIXTURE(x, name)
2939#define TYPE_TO_STRING_AS(str, ...) DOCTEST_TYPE_TO_STRING_AS(str, __VA_ARGS__)
2940#define TYPE_TO_STRING(...) DOCTEST_TYPE_TO_STRING(__VA_ARGS__)
2941#define TEST_CASE_TEMPLATE(name, T, ...) DOCTEST_TEST_CASE_TEMPLATE(name, T, __VA_ARGS__)
2942#define TEST_CASE_TEMPLATE_DEFINE(name, T, id) DOCTEST_TEST_CASE_TEMPLATE_DEFINE(name, T, id)
2943#define TEST_CASE_TEMPLATE_INVOKE(id, ...) DOCTEST_TEST_CASE_TEMPLATE_INVOKE(id, __VA_ARGS__)
2944#define TEST_CASE_TEMPLATE_APPLY(id, ...) DOCTEST_TEST_CASE_TEMPLATE_APPLY(id, __VA_ARGS__)
2945#define SUBCASE(name) DOCTEST_SUBCASE(name)
2946#define TEST_SUITE(decorators) DOCTEST_TEST_SUITE(decorators)
2947#define TEST_SUITE_BEGIN(name) DOCTEST_TEST_SUITE_BEGIN(name)
2948#define TEST_SUITE_END DOCTEST_TEST_SUITE_END
2949#define REGISTER_EXCEPTION_TRANSLATOR(signature) DOCTEST_REGISTER_EXCEPTION_TRANSLATOR(signature)
2950#define REGISTER_REPORTER(name, priority, reporter) DOCTEST_REGISTER_REPORTER(name, priority, reporter)
2951#define REGISTER_LISTENER(name, priority, reporter) DOCTEST_REGISTER_LISTENER(name, priority, reporter)
2952#define INFO(...) DOCTEST_INFO(__VA_ARGS__)
2953#define CAPTURE(x) DOCTEST_CAPTURE(x)
2954#define ADD_MESSAGE_AT(file, line, ...) DOCTEST_ADD_MESSAGE_AT(file, line, __VA_ARGS__)
2955#define ADD_FAIL_CHECK_AT(file, line, ...) DOCTEST_ADD_FAIL_CHECK_AT(file, line, __VA_ARGS__)
2956#define ADD_FAIL_AT(file, line, ...) DOCTEST_ADD_FAIL_AT(file, line, __VA_ARGS__)
2957#define MESSAGE(...) DOCTEST_MESSAGE(__VA_ARGS__)
2958#define FAIL_CHECK(...) DOCTEST_FAIL_CHECK(__VA_ARGS__)
2959#define FAIL(...) DOCTEST_FAIL(__VA_ARGS__)
2960#define TO_LVALUE(...) DOCTEST_TO_LVALUE(__VA_ARGS__)
2962#define WARN(...) DOCTEST_WARN(__VA_ARGS__)
2963#define WARN_FALSE(...) DOCTEST_WARN_FALSE(__VA_ARGS__)
2964#define WARN_THROWS(...) DOCTEST_WARN_THROWS(__VA_ARGS__)
2965#define WARN_THROWS_AS(expr, ...) DOCTEST_WARN_THROWS_AS(expr, __VA_ARGS__)
2966#define WARN_THROWS_WITH(expr, ...) DOCTEST_WARN_THROWS_WITH(expr, __VA_ARGS__)
2967#define WARN_THROWS_WITH_AS(expr, with, ...) DOCTEST_WARN_THROWS_WITH_AS(expr, with, __VA_ARGS__)
2968#define WARN_NOTHROW(...) DOCTEST_WARN_NOTHROW(__VA_ARGS__)
2969#define CHECK(...) DOCTEST_CHECK(__VA_ARGS__)
2970#define CHECK_FALSE(...) DOCTEST_CHECK_FALSE(__VA_ARGS__)
2971#define CHECK_THROWS(...) DOCTEST_CHECK_THROWS(__VA_ARGS__)
2972#define CHECK_THROWS_AS(expr, ...) DOCTEST_CHECK_THROWS_AS(expr, __VA_ARGS__)
2973#define CHECK_THROWS_WITH(expr, ...) DOCTEST_CHECK_THROWS_WITH(expr, __VA_ARGS__)
2974#define CHECK_THROWS_WITH_AS(expr, with, ...) DOCTEST_CHECK_THROWS_WITH_AS(expr, with, __VA_ARGS__)
2975#define CHECK_NOTHROW(...) DOCTEST_CHECK_NOTHROW(__VA_ARGS__)
2976#define REQUIRE(...) DOCTEST_REQUIRE(__VA_ARGS__)
2977#define REQUIRE_FALSE(...) DOCTEST_REQUIRE_FALSE(__VA_ARGS__)
2978#define REQUIRE_THROWS(...) DOCTEST_REQUIRE_THROWS(__VA_ARGS__)
2979#define REQUIRE_THROWS_AS(expr, ...) DOCTEST_REQUIRE_THROWS_AS(expr, __VA_ARGS__)
2980#define REQUIRE_THROWS_WITH(expr, ...) DOCTEST_REQUIRE_THROWS_WITH(expr, __VA_ARGS__)
2981#define REQUIRE_THROWS_WITH_AS(expr, with, ...) DOCTEST_REQUIRE_THROWS_WITH_AS(expr, with, __VA_ARGS__)
2982#define REQUIRE_NOTHROW(...) DOCTEST_REQUIRE_NOTHROW(__VA_ARGS__)
2984#define WARN_MESSAGE(cond, ...) DOCTEST_WARN_MESSAGE(cond, __VA_ARGS__)
2985#define WARN_FALSE_MESSAGE(cond, ...) DOCTEST_WARN_FALSE_MESSAGE(cond, __VA_ARGS__)
2986#define WARN_THROWS_MESSAGE(expr, ...) DOCTEST_WARN_THROWS_MESSAGE(expr, __VA_ARGS__)
2987#define WARN_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, __VA_ARGS__)
2988#define WARN_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, with, __VA_ARGS__)
2989#define WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, __VA_ARGS__)
2990#define WARN_NOTHROW_MESSAGE(expr, ...) DOCTEST_WARN_NOTHROW_MESSAGE(expr, __VA_ARGS__)
2991#define CHECK_MESSAGE(cond, ...) DOCTEST_CHECK_MESSAGE(cond, __VA_ARGS__)
2992#define CHECK_FALSE_MESSAGE(cond, ...) DOCTEST_CHECK_FALSE_MESSAGE(cond, __VA_ARGS__)
2993#define CHECK_THROWS_MESSAGE(expr, ...) DOCTEST_CHECK_THROWS_MESSAGE(expr, __VA_ARGS__)
2994#define CHECK_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, __VA_ARGS__)
2995#define CHECK_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, with, __VA_ARGS__)
2996#define CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, __VA_ARGS__)
2997#define CHECK_NOTHROW_MESSAGE(expr, ...) DOCTEST_CHECK_NOTHROW_MESSAGE(expr, __VA_ARGS__)
2998#define REQUIRE_MESSAGE(cond, ...) DOCTEST_REQUIRE_MESSAGE(cond, __VA_ARGS__)
2999#define REQUIRE_FALSE_MESSAGE(cond, ...) DOCTEST_REQUIRE_FALSE_MESSAGE(cond, __VA_ARGS__)
3000#define REQUIRE_THROWS_MESSAGE(expr, ...) DOCTEST_REQUIRE_THROWS_MESSAGE(expr, __VA_ARGS__)
3001#define REQUIRE_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, __VA_ARGS__)
3002#define REQUIRE_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, with, __VA_ARGS__)
3003#define REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, __VA_ARGS__)
3004#define REQUIRE_NOTHROW_MESSAGE(expr, ...) DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, __VA_ARGS__)
3006#define SCENARIO(name) DOCTEST_SCENARIO(name)
3007#define SCENARIO_CLASS(name) DOCTEST_SCENARIO_CLASS(name)
3008#define SCENARIO_TEMPLATE(name, T, ...) DOCTEST_SCENARIO_TEMPLATE(name, T, __VA_ARGS__)
3009#define SCENARIO_TEMPLATE_DEFINE(name, T, id) DOCTEST_SCENARIO_TEMPLATE_DEFINE(name, T, id)
3010#define GIVEN(name) DOCTEST_GIVEN(name)
3011#define WHEN(name) DOCTEST_WHEN(name)
3012#define AND_WHEN(name) DOCTEST_AND_WHEN(name)
3013#define THEN(name) DOCTEST_THEN(name)
3014#define AND_THEN(name) DOCTEST_AND_THEN(name)
3016#define WARN_EQ(...) DOCTEST_WARN_EQ(__VA_ARGS__)
3017#define CHECK_EQ(...) DOCTEST_CHECK_EQ(__VA_ARGS__)
3018#define REQUIRE_EQ(...) DOCTEST_REQUIRE_EQ(__VA_ARGS__)
3019#define WARN_NE(...) DOCTEST_WARN_NE(__VA_ARGS__)
3020#define CHECK_NE(...) DOCTEST_CHECK_NE(__VA_ARGS__)
3021#define REQUIRE_NE(...) DOCTEST_REQUIRE_NE(__VA_ARGS__)
3022#define WARN_GT(...) DOCTEST_WARN_GT(__VA_ARGS__)
3023#define CHECK_GT(...) DOCTEST_CHECK_GT(__VA_ARGS__)
3024#define REQUIRE_GT(...) DOCTEST_REQUIRE_GT(__VA_ARGS__)
3025#define WARN_LT(...) DOCTEST_WARN_LT(__VA_ARGS__)
3026#define CHECK_LT(...) DOCTEST_CHECK_LT(__VA_ARGS__)
3027#define REQUIRE_LT(...) DOCTEST_REQUIRE_LT(__VA_ARGS__)
3028#define WARN_GE(...) DOCTEST_WARN_GE(__VA_ARGS__)
3029#define CHECK_GE(...) DOCTEST_CHECK_GE(__VA_ARGS__)
3030#define REQUIRE_GE(...) DOCTEST_REQUIRE_GE(__VA_ARGS__)
3031#define WARN_LE(...) DOCTEST_WARN_LE(__VA_ARGS__)
3032#define CHECK_LE(...) DOCTEST_CHECK_LE(__VA_ARGS__)
3033#define REQUIRE_LE(...) DOCTEST_REQUIRE_LE(__VA_ARGS__)
3034#define WARN_UNARY(...) DOCTEST_WARN_UNARY(__VA_ARGS__)
3035#define CHECK_UNARY(...) DOCTEST_CHECK_UNARY(__VA_ARGS__)
3036#define REQUIRE_UNARY(...) DOCTEST_REQUIRE_UNARY(__VA_ARGS__)
3037#define WARN_UNARY_FALSE(...) DOCTEST_WARN_UNARY_FALSE(__VA_ARGS__)
3038#define CHECK_UNARY_FALSE(...) DOCTEST_CHECK_UNARY_FALSE(__VA_ARGS__)
3039#define REQUIRE_UNARY_FALSE(...) DOCTEST_REQUIRE_UNARY_FALSE(__VA_ARGS__)
3042#define FAST_WARN_EQ(...) DOCTEST_FAST_WARN_EQ(__VA_ARGS__)
3043#define FAST_CHECK_EQ(...) DOCTEST_FAST_CHECK_EQ(__VA_ARGS__)
3044#define FAST_REQUIRE_EQ(...) DOCTEST_FAST_REQUIRE_EQ(__VA_ARGS__)
3045#define FAST_WARN_NE(...) DOCTEST_FAST_WARN_NE(__VA_ARGS__)
3046#define FAST_CHECK_NE(...) DOCTEST_FAST_CHECK_NE(__VA_ARGS__)
3047#define FAST_REQUIRE_NE(...) DOCTEST_FAST_REQUIRE_NE(__VA_ARGS__)
3048#define FAST_WARN_GT(...) DOCTEST_FAST_WARN_GT(__VA_ARGS__)
3049#define FAST_CHECK_GT(...) DOCTEST_FAST_CHECK_GT(__VA_ARGS__)
3050#define FAST_REQUIRE_GT(...) DOCTEST_FAST_REQUIRE_GT(__VA_ARGS__)
3051#define FAST_WARN_LT(...) DOCTEST_FAST_WARN_LT(__VA_ARGS__)
3052#define FAST_CHECK_LT(...) DOCTEST_FAST_CHECK_LT(__VA_ARGS__)
3053#define FAST_REQUIRE_LT(...) DOCTEST_FAST_REQUIRE_LT(__VA_ARGS__)
3054#define FAST_WARN_GE(...) DOCTEST_FAST_WARN_GE(__VA_ARGS__)
3055#define FAST_CHECK_GE(...) DOCTEST_FAST_CHECK_GE(__VA_ARGS__)
3056#define FAST_REQUIRE_GE(...) DOCTEST_FAST_REQUIRE_GE(__VA_ARGS__)
3057#define FAST_WARN_LE(...) DOCTEST_FAST_WARN_LE(__VA_ARGS__)
3058#define FAST_CHECK_LE(...) DOCTEST_FAST_CHECK_LE(__VA_ARGS__)
3059#define FAST_REQUIRE_LE(...) DOCTEST_FAST_REQUIRE_LE(__VA_ARGS__)
3061#define FAST_WARN_UNARY(...) DOCTEST_FAST_WARN_UNARY(__VA_ARGS__)
3062#define FAST_CHECK_UNARY(...) DOCTEST_FAST_CHECK_UNARY(__VA_ARGS__)
3063#define FAST_REQUIRE_UNARY(...) DOCTEST_FAST_REQUIRE_UNARY(__VA_ARGS__)
3064#define FAST_WARN_UNARY_FALSE(...) DOCTEST_FAST_WARN_UNARY_FALSE(__VA_ARGS__)
3065#define FAST_CHECK_UNARY_FALSE(...) DOCTEST_FAST_CHECK_UNARY_FALSE(__VA_ARGS__)
3066#define FAST_REQUIRE_UNARY_FALSE(...) DOCTEST_FAST_REQUIRE_UNARY_FALSE(__VA_ARGS__)
3068#define TEST_CASE_TEMPLATE_INSTANTIATE(id, ...) DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE(id, __VA_ARGS__)
3072#ifndef DOCTEST_CONFIG_DISABLE
3087#ifndef DOCTEST_SINGLE_HEADER
3088#define DOCTEST_SINGLE_HEADER
3091#if defined(DOCTEST_CONFIG_IMPLEMENT) || !defined(DOCTEST_SINGLE_HEADER)
3093#ifndef DOCTEST_SINGLE_HEADER
3094#include "doctest_fwd.h"
3099#ifndef DOCTEST_LIBRARY_IMPLEMENTATION
3100#define DOCTEST_LIBRARY_IMPLEMENTATION
3164#ifndef DOCTEST_CONFIG_NO_INCLUDE_IOSTREAM
3170#ifndef DOCTEST_CONFIG_NO_MULTITHREADING
3173#define DOCTEST_DECLARE_MUTEX(name) std::mutex name;
3174#define DOCTEST_DECLARE_STATIC_MUTEX(name) static DOCTEST_DECLARE_MUTEX(name)
3175#define DOCTEST_LOCK_MUTEX(name) std::lock_guard<std::mutex> DOCTEST_ANONYMOUS(DOCTEST_ANON_LOCK_)(name);
3177#define DOCTEST_DECLARE_MUTEX(name)
3178#define DOCTEST_DECLARE_STATIC_MUTEX(name)
3179#define DOCTEST_LOCK_MUTEX(name)
3183#include <unordered_set>
3192#ifdef DOCTEST_PLATFORM_MAC
3193#include <sys/types.h>
3195#include <sys/sysctl.h>
3198#ifdef DOCTEST_PLATFORM_WINDOWS
3201#ifndef WIN32_LEAN_AND_MEAN
3202#define WIN32_LEAN_AND_MEAN
3203#define DOCTEST_UNDEF_WIN32_LEAN_AND_MEAN
3207#define DOCTEST_UNDEF_NOMINMAX
3220#include <sys/time.h>
3227#if !defined(HAVE_UNISTD_H) && !defined(STDOUT_FILENO)
3228#define STDOUT_FILENO fileno(stdout)
3234#define DOCTEST_COUNTOF(x) (sizeof(x) / sizeof(x[0]))
3236#ifdef DOCTEST_CONFIG_DISABLE
3237#define DOCTEST_BRANCH_ON_DISABLED(if_disabled, if_not_disabled) if_disabled
3239#define DOCTEST_BRANCH_ON_DISABLED(if_disabled, if_not_disabled) if_not_disabled
3242#ifndef DOCTEST_CONFIG_OPTIONS_PREFIX
3243#define DOCTEST_CONFIG_OPTIONS_PREFIX "dt-"
3246#ifndef DOCTEST_THREAD_LOCAL
3247#if defined(DOCTEST_CONFIG_NO_MULTITHREADING) || DOCTEST_MSVC && (DOCTEST_MSVC < DOCTEST_COMPILER(19, 0, 0))
3248#define DOCTEST_THREAD_LOCAL
3250#define DOCTEST_THREAD_LOCAL thread_local
3254#ifndef DOCTEST_MULTI_LANE_ATOMICS_THREAD_LANES
3255#define DOCTEST_MULTI_LANE_ATOMICS_THREAD_LANES 32
3258#ifndef DOCTEST_MULTI_LANE_ATOMICS_CACHE_LINE_SIZE
3259#define DOCTEST_MULTI_LANE_ATOMICS_CACHE_LINE_SIZE 64
3262#ifdef DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS
3263#define DOCTEST_OPTIONS_PREFIX_DISPLAY DOCTEST_CONFIG_OPTIONS_PREFIX
3265#define DOCTEST_OPTIONS_PREFIX_DISPLAY ""
3268#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
3269#define DOCTEST_CONFIG_NO_MULTI_LANE_ATOMICS
3272#ifndef DOCTEST_CDECL
3273#define DOCTEST_CDECL __cdecl
3278bool is_running_in_test =
false;
3281 using namespace detail;
3283 template <
typename Ex>
3285#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
3288#ifdef DOCTEST_CONFIG_HANDLE_EXCEPTION
3289 DOCTEST_CONFIG_HANDLE_EXCEPTION(e);
3291#ifndef DOCTEST_CONFIG_NO_INCLUDE_IOSTREAM
3292 std::cerr <<
"doctest will terminate because it needed to throw an exception.\n"
3293 <<
"The message was: " << e.what() <<
'\n';
3300#ifndef DOCTEST_INTERNAL_ERROR
3301#define DOCTEST_INTERNAL_ERROR(msg) \
3302 throw_exception(std::logic_error( \
3303 __FILE__ ":" DOCTEST_TOSTR(__LINE__) ": Internal doctest error: " msg))
3307 int stricmp(
const char* a,
const char*
b) {
3309 const int d = tolower(*a) - tolower(*
b);
3323 static Arch which() {
3326 auto ptr =
reinterpret_cast<char*
>(&
x);
3335 DOCTEST_THREAD_LOCAL
class
3348 DOCTEST_INTERNAL_ERROR(
"TLSS was empty when trying to pop!");
3352 unsigned sz =
static_cast<unsigned>(ss.
tellp() - pos);
3353 ss.
rdbuf()->pubseekpos(pos, std::ios::in | std::ios::out);
3354 return String(ss, sz);
3359 return g_oss.push();
3366#ifndef DOCTEST_CONFIG_DISABLE
3368namespace timer_large_integer
3371#if defined(DOCTEST_PLATFORM_WINDOWS)
3372 using type = ULONGLONG;
3378using ticks_t = timer_large_integer::type;
3380#ifdef DOCTEST_CONFIG_GETCURRENTTICKS
3381 ticks_t getCurrentTicks() {
return DOCTEST_CONFIG_GETCURRENTTICKS(); }
3382#elif defined(DOCTEST_PLATFORM_WINDOWS)
3383 ticks_t getCurrentTicks() {
3384 static LARGE_INTEGER hz = { {0} }, hzo = { {0} };
3386 QueryPerformanceFrequency(&hz);
3387 QueryPerformanceCounter(&hzo);
3390 QueryPerformanceCounter(&t);
3391 return ((t.QuadPart - hzo.QuadPart) * LONGLONG(1000000)) / hz.QuadPart;
3394 ticks_t getCurrentTicks() {
3396 gettimeofday(&t,
nullptr);
3397 return static_cast<ticks_t
>(t.tv_sec) * 1000000 +
static_cast<ticks_t
>(t.tv_usec);
3403 void start() { m_ticks = getCurrentTicks(); }
3404 unsigned int getElapsedMicroseconds()
const {
3405 return static_cast<unsigned int>(getCurrentTicks() - m_ticks);
3410 double getElapsedSeconds()
const {
return static_cast<double>(getCurrentTicks() - m_ticks) / 1000000.0; }
3413 ticks_t m_ticks = 0;
3416#ifdef DOCTEST_CONFIG_NO_MULTITHREADING
3417 template <
typename T>
3420 template <
typename T>
3424#if defined(DOCTEST_CONFIG_NO_MULTI_LANE_ATOMICS) || defined(DOCTEST_CONFIG_NO_MULTITHREADING)
3425 template <
typename T>
3426 using MultiLaneAtomic = Atomic<T>;
3438 template <
typename T>
3439 class MultiLaneAtomic
3441 struct CacheLineAlignedAtomic
3444 char padding[DOCTEST_MULTI_LANE_ATOMICS_CACHE_LINE_SIZE -
sizeof(Atomic<T>)];
3446 CacheLineAlignedAtomic m_atomics[DOCTEST_MULTI_LANE_ATOMICS_THREAD_LANES];
3448 static_assert(
sizeof(CacheLineAlignedAtomic) == DOCTEST_MULTI_LANE_ATOMICS_CACHE_LINE_SIZE,
3449 "guarantee one atomic takes exactly one cache line");
3457 return myAtomic().fetch_add(arg,
order);
3461 return myAtomic().fetch_sub(arg,
order);
3468 for(
auto const& c : m_atomics) {
3481 for(
auto& c : m_atomics) {
3482 c.atomic.store(desired,
order);
3501 static Atomic<size_t> laneCounter;
3502 DOCTEST_THREAD_LOCAL
size_t tlsLaneIdx =
3503 laneCounter++ % DOCTEST_MULTI_LANE_ATOMICS_THREAD_LANES;
3505 return m_atomics[tlsLaneIdx].atomic;
3511 struct ContextState : ContextOptions, TestRunStats, CurrentTestCaseStats
3513 MultiLaneAtomic<int> numAssertsCurrentTest_atomic;
3514 MultiLaneAtomic<int> numAssertsFailedCurrentTest_atomic;
3520 assert_handler ah =
nullptr;
3531 size_t currentSubcaseDepth;
3532 Atomic<bool> shouldLogCurrentException;
3534 void resetRunData() {
3536 numTestCasesPassingFilters = 0;
3537 numTestSuitesPassingFilters = 0;
3538 numTestCasesFailed = 0;
3540 numAssertsFailed = 0;
3541 numAssertsCurrentTest = 0;
3542 numAssertsFailedCurrentTest = 0;
3545 void finalizeTestCaseData() {
3546 seconds = timer.getElapsedSeconds();
3549 numAsserts += numAssertsCurrentTest_atomic;
3550 numAssertsFailed += numAssertsFailedCurrentTest_atomic;
3551 numAssertsCurrentTest = numAssertsCurrentTest_atomic;
3552 numAssertsFailedCurrentTest = numAssertsFailedCurrentTest_atomic;
3554 if(numAssertsFailedCurrentTest)
3555 failure_flags |= TestCaseFailureReason::AssertFailure;
3557 if(Approx(currentTest->m_timeout).epsilon(DBL_EPSILON) != 0 &&
3558 Approx(seconds).epsilon(DBL_EPSILON) > currentTest->m_timeout)
3559 failure_flags |= TestCaseFailureReason::Timeout;
3561 if(currentTest->m_should_fail) {
3563 failure_flags |= TestCaseFailureReason::ShouldHaveFailedAndDid;
3565 failure_flags |= TestCaseFailureReason::ShouldHaveFailedButDidnt;
3567 }
else if(failure_flags && currentTest->m_may_fail) {
3568 failure_flags |= TestCaseFailureReason::CouldHaveFailedAndDid;
3569 }
else if(currentTest->m_expected_failures > 0) {
3570 if(numAssertsFailedCurrentTest == currentTest->m_expected_failures) {
3571 failure_flags |= TestCaseFailureReason::FailedExactlyNumTimes;
3573 failure_flags |= TestCaseFailureReason::DidntFailExactlyNumTimes;
3577 bool ok_to_fail = (TestCaseFailureReason::ShouldHaveFailedAndDid & failure_flags) ||
3578 (TestCaseFailureReason::CouldHaveFailedAndDid & failure_flags) ||
3579 (TestCaseFailureReason::FailedExactlyNumTimes & failure_flags);
3582 testCaseSuccess = !(failure_flags && !ok_to_fail);
3583 if(!testCaseSuccess)
3584 numTestCasesFailed++;
3588 ContextState* g_cs =
nullptr;
3593 DOCTEST_THREAD_LOCAL
bool g_no_colors;
3598char* String::allocate(size_type sz) {
3607 data.ptr =
new char[
data.capacity];
3608 data.ptr[sz] =
'\0';
3613void String::setOnHeap()
noexcept { *
reinterpret_cast<unsigned char*
>(&buf[last]) = 128; }
3614void String::setLast(size_type in)
noexcept { buf[last] = char(in); }
3615void String::setSize(size_type sz)
noexcept {
3616 if (isOnStack()) { buf[sz] =
'\0'; setLast(last - sz); }
3617 else {
data.ptr[sz] =
'\0';
data.size = sz; }
3620void String::copy(
const String& other) {
3621 if(other.isOnStack()) {
3622 memcpy(buf, other.buf, len);
3624 memcpy(allocate(other.data.size), other.data.ptr, other.data.size);
3628String::String()
noexcept {
3638String::String(
const char* in)
3639 : String(in, strlen(in)) {}
3641String::String(
const char* in, size_type in_size) {
3642 memcpy(allocate(in_size), in, in_size);
3646 in.read(allocate(in_size), in_size);
3649String::String(
const String& other) { copy(other); }
3651String& String::operator=(
const String& other) {
3652 if(
this != &other) {
3662String& String::operator+=(
const String& other) {
3663 const size_type my_old_size = size();
3664 const size_type other_size = other.size();
3665 const size_type total_size = my_old_size + other_size;
3667 if(total_size < len) {
3669 memcpy(buf + my_old_size, other.c_str(), other_size + 1);
3671 setLast(last - total_size);
3674 char* temp =
new char[total_size + 1];
3676 memcpy(temp, buf, my_old_size);
3679 data.size = total_size;
3683 memcpy(
data.ptr + my_old_size, other.c_str(), other_size + 1);
3686 if(
data.capacity > total_size) {
3688 data.size = total_size;
3689 memcpy(
data.ptr + my_old_size, other.c_str(), other_size + 1);
3693 if(
data.capacity <= total_size)
3694 data.capacity = total_size + 1;
3696 char* temp =
new char[
data.capacity];
3698 memcpy(temp,
data.ptr, my_old_size);
3702 data.size = total_size;
3705 memcpy(
data.ptr + my_old_size, other.c_str(), other_size + 1);
3712String::String(String&& other)
noexcept {
3713 memcpy(buf, other.buf, len);
3714 other.buf[0] =
'\0';
3718String& String::operator=(String&& other)
noexcept {
3719 if(
this != &other) {
3722 memcpy(buf, other.buf, len);
3723 other.buf[0] =
'\0';
3729char String::operator[](size_type i)
const {
3730 return const_cast<String*
>(
this)->
operator[](i);
3733char& String::operator[](size_type i) {
3735 return reinterpret_cast<char*
>(buf)[i];
3740String::size_type String::size()
const {
3742 return last - (size_type(buf[last]) & 31);
3747String::size_type String::capacity()
const {
3750 return data.capacity;
3753String String::substr(size_type pos, size_type cnt) && {
3754 cnt =
std::min(cnt, size() - 1 - pos);
3755 char* cptr = c_str();
3756 memmove(cptr, cptr + pos, cnt);
3761String String::substr(size_type pos, size_type cnt)
const & {
3762 cnt =
std::min(cnt, size() - 1 - pos);
3763 return String{ c_str() + pos, cnt };
3766String::size_type String::find(
char ch, size_type pos)
const {
3767 const char* begin = c_str();
3768 const char*
end = begin + size();
3769 const char* it = begin + pos;
3770 for (; it <
end && *it != ch; it++);
3771 if (it <
end) {
return static_cast<size_type
>(it - begin); }
3772 else {
return npos; }
3775String::size_type String::rfind(
char ch, size_type pos)
const {
3776 const char* begin = c_str();
3777 const char* it = begin +
std::min(pos, size() - 1);
3778 for (; it >= begin && *it != ch; it--);
3779 if (it >= begin) {
return static_cast<size_type
>(it - begin); }
3780 else {
return npos; }
3783int String::compare(
const char* other,
bool no_case)
const {
3785 return doctest::stricmp(c_str(), other);
3789int String::compare(
const String& other,
bool no_case)
const {
3790 return compare(other.c_str(), no_case);
3793String operator+(
const String& lhs,
const String& rhs) {
return String(lhs) += rhs; }
3795bool operator==(
const String& lhs,
const String& rhs) {
return lhs.compare(rhs) == 0; }
3796bool operator!=(
const String& lhs,
const String& rhs) {
return lhs.compare(rhs) != 0; }
3797bool operator< (
const String& lhs,
const String& rhs) {
return lhs.compare(rhs) < 0; }
3798bool operator> (
const String& lhs,
const String& rhs) {
return lhs.compare(rhs) > 0; }
3799bool operator<=(
const String& lhs,
const String& rhs) {
return (lhs != rhs) ? lhs.compare(rhs) < 0 :
true; }
3800bool operator>=(
const String& lhs,
const String& rhs) {
return (lhs != rhs) ? lhs.compare(rhs) > 0 :
true; }
3804Contains::Contains(
const String& str) :
string(str) { }
3806bool Contains::checkWith(
const String& other)
const {
3807 return strstr(other.c_str(),
string.c_str()) !=
nullptr;
3810String toString(
const Contains& in) {
3811 return "Contains( " + in.string +
" )";
3814bool operator==(
const String& lhs,
const Contains& rhs) {
return rhs.checkWith(lhs); }
3815bool operator==(
const Contains& lhs,
const String& rhs) {
return lhs.checkWith(rhs); }
3816bool operator!=(
const String& lhs,
const Contains& rhs) {
return !rhs.checkWith(lhs); }
3817bool operator!=(
const Contains& lhs,
const String& rhs) {
return !lhs.checkWith(rhs); }
3820 void color_to_stream(
std::ostream&, Color::Enum) DOCTEST_BRANCH_ON_DISABLED({}, ;)
3825 color_to_stream(s, code);
3831const char* assertString(assertType::Enum at) {
3833 #define DOCTEST_GENERATE_ASSERT_TYPE_CASE(assert_type) case assertType::DT_ ## assert_type: return #assert_type
3834 #define DOCTEST_GENERATE_ASSERT_TYPE_CASES(assert_type) \
3835 DOCTEST_GENERATE_ASSERT_TYPE_CASE(WARN_ ## assert_type); \
3836 DOCTEST_GENERATE_ASSERT_TYPE_CASE(CHECK_ ## assert_type); \
3837 DOCTEST_GENERATE_ASSERT_TYPE_CASE(REQUIRE_ ## assert_type)
3839 DOCTEST_GENERATE_ASSERT_TYPE_CASE(
WARN);
3840 DOCTEST_GENERATE_ASSERT_TYPE_CASE(
CHECK);
3841 DOCTEST_GENERATE_ASSERT_TYPE_CASE(
REQUIRE);
3843 DOCTEST_GENERATE_ASSERT_TYPE_CASES(FALSE);
3845 DOCTEST_GENERATE_ASSERT_TYPE_CASES(THROWS);
3847 DOCTEST_GENERATE_ASSERT_TYPE_CASES(THROWS_AS);
3849 DOCTEST_GENERATE_ASSERT_TYPE_CASES(THROWS_WITH);
3851 DOCTEST_GENERATE_ASSERT_TYPE_CASES(THROWS_WITH_AS);
3853 DOCTEST_GENERATE_ASSERT_TYPE_CASES(NOTHROW);
3855 DOCTEST_GENERATE_ASSERT_TYPE_CASES(EQ);
3856 DOCTEST_GENERATE_ASSERT_TYPE_CASES(NE);
3857 DOCTEST_GENERATE_ASSERT_TYPE_CASES(GT);
3858 DOCTEST_GENERATE_ASSERT_TYPE_CASES(LT);
3859 DOCTEST_GENERATE_ASSERT_TYPE_CASES(GE);
3860 DOCTEST_GENERATE_ASSERT_TYPE_CASES(LE);
3862 DOCTEST_GENERATE_ASSERT_TYPE_CASES(UNARY);
3863 DOCTEST_GENERATE_ASSERT_TYPE_CASES(UNARY_FALSE);
3865 default: DOCTEST_INTERNAL_ERROR(
"Tried stringifying invalid assert type!");
3871const char* failureString(assertType::Enum at) {
3872 if(at & assertType::is_warn)
3874 if(at & assertType::is_check)
3876 if(at & assertType::is_require)
3877 return "FATAL ERROR";
3884const char* skipPathFromFilename(
const char* file) {
3885#ifndef DOCTEST_CONFIG_DISABLE
3886 if(getContextOptions()->no_path_in_filenames) {
3889 if(back || forward) {
3901bool SubcaseSignature::operator==(
const SubcaseSignature& other)
const {
3902 return m_line == other.m_line
3904 && m_name == other.m_name;
3907bool SubcaseSignature::operator<(
const SubcaseSignature& other)
const {
3908 if(m_line != other.m_line)
3909 return m_line < other.m_line;
3912 return m_name.compare(other.m_name) < 0;
3918 void filldata<const void*>::fill(
std::ostream* stream,
const void* in) {
3919 if (in) { *stream << in; }
3920 else { *stream <<
"nullptr"; }
3923 template <
typename T>
3924 String toStreamLit(T t) {
3931#ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
3932String toString(
const char* in) {
return String(
"\"") + (in ? in :
"{null string}") +
"\""; }
3935#if DOCTEST_MSVC >= DOCTEST_COMPILER(19, 20, 0)
3940String toString(String in) {
return in; }
3944String toString(
bool in) {
return in ?
"true" :
"false"; }
3946String toString(
float in) {
return toStreamLit(in); }
3947String toString(
double in) {
return toStreamLit(in); }
3948String toString(
double long in) {
return toStreamLit(in); }
3950String toString(
char in) {
return toStreamLit(
static_cast<signed>(in)); }
3951String toString(
char signed in) {
return toStreamLit(
static_cast<signed>(in)); }
3952String toString(
char unsigned in) {
return toStreamLit(
static_cast<unsigned>(in)); }
3953String toString(
short in) {
return toStreamLit(in); }
3954String toString(
short unsigned in) {
return toStreamLit(in); }
3955String toString(
signed in) {
return toStreamLit(in); }
3956String toString(
unsigned in) {
return toStreamLit(in); }
3957String toString(
long in) {
return toStreamLit(in); }
3958String toString(
long unsigned in) {
return toStreamLit(in); }
3959String toString(
long long in) {
return toStreamLit(in); }
3960String toString(
long long unsigned in) {
return toStreamLit(in); }
3962Approx::Approx(
double value)
3967Approx Approx::operator()(
double value)
const {
3968 Approx approx(value);
3969 approx.epsilon(m_epsilon);
3970 approx.scale(m_scale);
3974Approx& Approx::epsilon(
double newEpsilon) {
3975 m_epsilon = newEpsilon;
3978Approx& Approx::scale(
double newScale) {
3983bool operator==(
double lhs,
const Approx& rhs) {
3986 rhs.m_epsilon * (rhs.m_scale + std::max<double>(
std::fabs(lhs),
std::fabs(rhs.m_value)));
3988bool operator==(
const Approx& lhs,
double rhs) {
return operator==(rhs, lhs); }
3989bool operator!=(
double lhs,
const Approx& rhs) {
return !operator==(lhs, rhs); }
3990bool operator!=(
const Approx& lhs,
double rhs) {
return !operator==(rhs, lhs); }
3991bool operator<=(
double lhs,
const Approx& rhs) {
return lhs < rhs.m_value || lhs == rhs; }
3992bool operator<=(
const Approx& lhs,
double rhs) {
return lhs.m_value < rhs || lhs == rhs; }
3993bool operator>=(
double lhs,
const Approx& rhs) {
return lhs > rhs.m_value || lhs == rhs; }
3994bool operator>=(
const Approx& lhs,
double rhs) {
return lhs.m_value > rhs || lhs == rhs; }
3995bool operator<(
double lhs,
const Approx& rhs) {
return lhs < rhs.m_value && lhs != rhs; }
3996bool operator<(
const Approx& lhs,
double rhs) {
return lhs.m_value < rhs && lhs != rhs; }
3997bool operator>(
double lhs,
const Approx& rhs) {
return lhs > rhs.m_value && lhs != rhs; }
3998bool operator>(
const Approx& lhs,
double rhs) {
return lhs.m_value > rhs && lhs != rhs; }
4000String toString(
const Approx& in) {
4003const ContextOptions* getContextOptions() {
return DOCTEST_BRANCH_ON_DISABLED(
nullptr, g_cs); }
4006template <
typename F>
4007IsNaN<F>::operator bool()
const {
4014template <
typename F>
4015String toString(IsNaN<F> in) {
return String(in.flipped ?
"! " :
"") +
"IsNaN( " +
doctest::toString(in.value) +
" )"; }
4016String toString(IsNaN<float> in) {
return toString<float>(in); }
4017String toString(IsNaN<double> in) {
return toString<double>(in); }
4018String toString(IsNaN<double long> in) {
return toString<double long>(in); }
4022#ifdef DOCTEST_CONFIG_DISABLE
4024Context::Context(
int,
const char*
const*) {}
4025Context::~Context() =
default;
4026void Context::applyCommandLine(
int,
const char*
const*) {}
4027void Context::addFilter(
const char*,
const char*) {}
4028void Context::clearFilters() {}
4029void Context::setOption(
const char*,
bool) {}
4030void Context::setOption(
const char*,
int) {}
4031void Context::setOption(
const char*,
const char*) {}
4032bool Context::shouldExit() {
return false; }
4033void Context::setAsDefaultForAssertsOutOfTestCases() {}
4034void Context::setAssertHandler(detail::assert_handler) {}
4036int Context::run() {
return 0; }
4038int IReporter::get_num_active_contexts() {
return 0; }
4039const IContextScope*
const* IReporter::get_active_contexts() {
return nullptr; }
4040int IReporter::get_num_stringified_contexts() {
return 0; }
4041const String* IReporter::get_stringified_contexts() {
return nullptr; }
4048#if !defined(DOCTEST_CONFIG_COLORS_NONE)
4049#if !defined(DOCTEST_CONFIG_COLORS_WINDOWS) && !defined(DOCTEST_CONFIG_COLORS_ANSI)
4050#ifdef DOCTEST_PLATFORM_WINDOWS
4051#define DOCTEST_CONFIG_COLORS_WINDOWS
4053#define DOCTEST_CONFIG_COLORS_ANSI
4072 reporterMap& getReporters() {
4073 static reporterMap
data;
4076 reporterMap& getListeners() {
4077 static reporterMap
data;
4082#define DOCTEST_ITERATE_THROUGH_REPORTERS(function, ...) \
4083 for(auto& curr_rep : g_cs->reporters_currently_used) \
4084 curr_rep->function(__VA_ARGS__)
4087 if(at & assertType::is_require)
4090 if((at & assertType::is_check)
4092 (g_cs->numAssertsFailed + g_cs->numAssertsFailedCurrentTest_atomic) >=
4099#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
4101 g_cs->shouldLogCurrentException =
false;
4102 throw TestFailureException();
4110 using namespace detail;
4113 int wildcmp(
const char* str,
const char* wild,
bool caseSensitive) {
4114 const char* cp = str;
4115 const char* mp = wild;
4117 while((*str) && (*wild !=
'*')) {
4118 if((caseSensitive ? (*wild != *str) : (
tolower(*wild) !=
tolower(*str))) &&
4133 }
else if((caseSensitive ? (*wild == *str) : (
tolower(*wild) ==
tolower(*str))) ||
4143 while(*wild ==
'*') {
4151 bool caseSensitive) {
4152 if (filters.
empty() && matchEmpty)
4154 for (
auto& curr : filters)
4155 if (wildcmp(name, curr.c_str(), caseSensitive))
4161 unsigned long long hash(
unsigned long long a,
unsigned long long b) {
4162 return (a << 5) +
b;
4167 unsigned long long hash(
const char* str) {
4168 unsigned long long hash = 5381;
4170 while ((c = *str++))
4175 unsigned long long hash(
const SubcaseSignature& sig) {
4180 unsigned long long running = 0;
4182 for (
auto it = sigs.
begin(); it !=
end; it++) {
4183 running =
hash(running,
hash(*it));
4189 unsigned long long running = 0;
4190 for (
const SubcaseSignature& sig : sigs) {
4191 running =
hash(running,
hash(sig));
4197 bool Subcase::checkFilters() {
4198 if (g_cs->subcaseStack.size() <
size_t(g_cs->subcase_filter_levels)) {
4199 if (!matchesAny(m_signature.m_name.c_str(), g_cs->filters[6],
true, g_cs->case_sensitive))
4201 if (matchesAny(m_signature.m_name.c_str(), g_cs->filters[7],
false, g_cs->case_sensitive))
4207 Subcase::Subcase(
const String& name,
const char* file,
int line)
4208 : m_signature({
name, file,
line}) {
4209 if (!g_cs->reachedLeaf) {
4210 if (g_cs->nextSubcaseStack.size() <= g_cs->subcaseStack.size()
4211 || g_cs->nextSubcaseStack[g_cs->subcaseStack.size()] == m_signature) {
4213 if (checkFilters()) {
return; }
4215 g_cs->subcaseStack.push_back(m_signature);
4216 g_cs->currentSubcaseDepth++;
4218 DOCTEST_ITERATE_THROUGH_REPORTERS(subcase_start, m_signature);
4221 if (g_cs->subcaseStack[g_cs->currentSubcaseDepth] == m_signature) {
4223 g_cs->currentSubcaseDepth++;
4225 DOCTEST_ITERATE_THROUGH_REPORTERS(subcase_start, m_signature);
4226 }
else if (g_cs->nextSubcaseStack.size() <= g_cs->currentSubcaseDepth
4227 && g_cs->fullyTraversedSubcases.find(
hash(
hash(g_cs->subcaseStack, g_cs->currentSubcaseDepth),
hash(m_signature)))
4228 == g_cs->fullyTraversedSubcases.end()) {
4229 if (checkFilters()) {
return; }
4231 g_cs->nextSubcaseStack.clear();
4232 g_cs->nextSubcaseStack.insert(g_cs->nextSubcaseStack.end(),
4233 g_cs->subcaseStack.begin(), g_cs->subcaseStack.begin() + g_cs->currentSubcaseDepth);
4234 g_cs->nextSubcaseStack.push_back(m_signature);
4243 Subcase::~Subcase() {
4245 g_cs->currentSubcaseDepth--;
4247 if (!g_cs->reachedLeaf) {
4249 g_cs->fullyTraversedSubcases.insert(
hash(g_cs->subcaseStack));
4250 g_cs->nextSubcaseStack.clear();
4251 g_cs->reachedLeaf =
true;
4252 }
else if (g_cs->nextSubcaseStack.empty()) {
4254 g_cs->fullyTraversedSubcases.insert(
hash(g_cs->subcaseStack));
4257#if defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411L && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200)
4258 if(std::uncaught_exceptions() > 0
4262 && g_cs->shouldLogCurrentException) {
4263 DOCTEST_ITERATE_THROUGH_REPORTERS(
4264 test_case_exception, {
"exception thrown in subcase - will translate later "
4265 "when the whole test case has been exited (cannot "
4266 "translate while there is an active exception)",
4268 g_cs->shouldLogCurrentException =
false;
4271 DOCTEST_ITERATE_THROUGH_REPORTERS(subcase_end,
DOCTEST_EMPTY);
4279 Subcase::operator bool()
const {
return m_entered; }
4281 Result::Result(
bool passed,
const String& decomposition)
4283 , m_decomp(decomposition) {}
4285 ExpressionDecomposer::ExpressionDecomposer(assertType::Enum at)
4288 TestSuite& TestSuite::operator*(
const char* in) {
4293 TestCase::TestCase(funcType test,
const char* file,
unsigned line,
const TestSuite& test_suite,
4294 const String& type,
int template_id) {
4298 m_test_suite = test_suite.m_test_suite;
4299 m_description = test_suite.m_description;
4300 m_skip = test_suite.m_skip;
4301 m_no_breaks = test_suite.m_no_breaks;
4302 m_no_output = test_suite.m_no_output;
4303 m_may_fail = test_suite.m_may_fail;
4304 m_should_fail = test_suite.m_should_fail;
4305 m_expected_failures = test_suite.m_expected_failures;
4306 m_timeout = test_suite.m_timeout;
4310 m_template_id = template_id;
4313 TestCase::TestCase(
const TestCase& other)
4319 TestCase& TestCase::operator=(const TestCase& other) {
4320 TestCaseData::operator=(other);
4321 m_test = other.m_test;
4322 m_type = other.m_type;
4323 m_template_id = other.m_template_id;
4324 m_full_name = other.m_full_name;
4326 if(m_template_id != -1)
4327 m_name = m_full_name.
c_str();
4332 TestCase& TestCase::operator*(
const char* in) {
4335 if(m_template_id != -1) {
4336 m_full_name = String(m_name) +
"<" + m_type +
">";
4338 m_name = m_full_name.
c_str();
4343 bool TestCase::operator<(
const TestCase& other)
const {
4345 if(m_line != other.m_line)
4346 return m_line < other.m_line;
4347 const int name_cmp =
strcmp(m_name, other.m_name);
4349 return name_cmp < 0;
4350 const int file_cmp = m_file.compare(other.m_file);
4352 return file_cmp < 0;
4353 return m_template_id < other.m_template_id;
4363 using namespace detail;
4365 bool fileOrderComparator(
const TestCase* lhs,
const TestCase* rhs) {
4368 const int res = lhs->m_file.compare(rhs->m_file,
bool(
DOCTEST_MSVC));
4371 if(lhs->m_line != rhs->m_line)
4372 return lhs->m_line < rhs->m_line;
4373 return lhs->m_template_id < rhs->m_template_id;
4377 bool suiteOrderComparator(
const TestCase* lhs,
const TestCase* rhs) {
4378 const int res =
std::strcmp(lhs->m_test_suite, rhs->m_test_suite);
4381 return fileOrderComparator(lhs, rhs);
4385 bool nameOrderComparator(
const TestCase* lhs,
const TestCase* rhs) {
4386 const int res =
std::strcmp(lhs->m_name, rhs->m_name);
4389 return suiteOrderComparator(lhs, rhs);
4393 void color_to_stream(
std::
ostream& s, Color::Enum code) {
4394 static_cast<void>(s);
4395 static_cast<void>(code);
4396#ifdef DOCTEST_CONFIG_COLORS_ANSI
4404 case Color::Red:
col =
"[0;31m";
break;
4405 case Color::Green:
col =
"[0;32m";
break;
4406 case Color::Blue:
col =
"[0;34m";
break;
4407 case Color::Cyan:
col =
"[0;36m";
break;
4408 case Color::Yellow:
col =
"[0;33m";
break;
4409 case Color::Grey:
col =
"[1;30m";
break;
4410 case Color::LightGrey:
col =
"[0;37m";
break;
4411 case Color::BrightRed:
col =
"[1;31m";
break;
4412 case Color::BrightGreen:
col =
"[1;32m";
break;
4413 case Color::BrightWhite:
col =
"[1;37m";
break;
4417 default:
col =
"[0m";
4423#ifdef DOCTEST_CONFIG_COLORS_WINDOWS
4428 static struct ConsoleHelper {
4429 HANDLE stdoutHandle;
4434 stdoutHandle = GetStdHandle(STD_OUTPUT_HANDLE);
4435 CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
4436 GetConsoleScreenBufferInfo(stdoutHandle, &csbiInfo);
4437 origFgAttrs = csbiInfo.wAttributes & ~(BACKGROUND_GREEN | BACKGROUND_RED |
4438 BACKGROUND_BLUE | BACKGROUND_INTENSITY);
4439 origBgAttrs = csbiInfo.wAttributes & ~(FOREGROUND_GREEN | FOREGROUND_RED |
4440 FOREGROUND_BLUE | FOREGROUND_INTENSITY);
4444#define DOCTEST_SET_ATTR(x) SetConsoleTextAttribute(ch.stdoutHandle, x | ch.origBgAttrs)
4448 case Color::White: DOCTEST_SET_ATTR(FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE);
break;
4449 case Color::Red: DOCTEST_SET_ATTR(FOREGROUND_RED);
break;
4450 case Color::Green: DOCTEST_SET_ATTR(FOREGROUND_GREEN);
break;
4451 case Color::Blue: DOCTEST_SET_ATTR(FOREGROUND_BLUE);
break;
4452 case Color::Cyan: DOCTEST_SET_ATTR(FOREGROUND_BLUE | FOREGROUND_GREEN);
break;
4453 case Color::Yellow: DOCTEST_SET_ATTR(FOREGROUND_RED | FOREGROUND_GREEN);
break;
4454 case Color::Grey: DOCTEST_SET_ATTR(0);
break;
4455 case Color::LightGrey: DOCTEST_SET_ATTR(FOREGROUND_INTENSITY);
break;
4456 case Color::BrightRed: DOCTEST_SET_ATTR(FOREGROUND_INTENSITY | FOREGROUND_RED);
break;
4457 case Color::BrightGreen: DOCTEST_SET_ATTR(FOREGROUND_INTENSITY | FOREGROUND_GREEN);
break;
4458 case Color::BrightWhite: DOCTEST_SET_ATTR(FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE);
break;
4461 default: DOCTEST_SET_ATTR(ch.origFgAttrs);
4473 String translateActiveException() {
4474#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
4476 auto& translators = getExceptionTranslators();
4477 for(
auto& curr : translators)
4488 }
catch(
const char* msg) {
4491 return "unknown exception";
4503 int regTest(
const TestCase& tc) {
4504 getRegisteredTests().insert(tc);
4514#ifdef DOCTEST_IS_DEBUGGER_ACTIVE
4517#ifdef DOCTEST_PLATFORM_LINUX
4520 ErrnoGuard() : m_oldErrno(errno) {}
4521 ~ErrnoGuard() { errno = m_oldErrno; }
4531 static const int PREFIX_LEN = 11;
4532 if(
line.compare(0, PREFIX_LEN,
"TracerPid:\t") == 0) {
4533 return line.length() > PREFIX_LEN &&
line[PREFIX_LEN] !=
'0';
4538#elif defined(DOCTEST_PLATFORM_MAC)
4549 info.kp_proc.p_flag = 0;
4554 mib[2] = KERN_PROC_PID;
4557 size =
sizeof(
info);
4558 if(sysctl(mib, DOCTEST_COUNTOF(mib), &info, &size, 0, 0) != 0) {
4559 std::cerr <<
"\nCall to sysctl failed - unable to determine if debugger is active **\n";
4563 return ((
info.kp_proc.p_flag & P_TRACED) != 0);
4565#elif DOCTEST_MSVC || defined(__MINGW32__) || defined(__MINGW64__)
4573 if(
std::find(getExceptionTranslators().
begin(), getExceptionTranslators().
end(), et) ==
4574 getExceptionTranslators().
end())
4575 getExceptionTranslators().push_back(et);
4580 ContextScopeBase::ContextScopeBase() {
4584 ContextScopeBase::ContextScopeBase(ContextScopeBase&& other)
noexcept {
4585 if (other.need_to_destroy) {
4588 other.need_to_destroy =
false;
4589 g_infoContexts.push_back(
this);
4599 void ContextScopeBase::destroy() {
4600#if defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411L && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200)
4601 if(std::uncaught_exceptions() > 0) {
4606 this->stringify(&s);
4607 g_cs->stringifiedContexts.push_back(s.str().c_str());
4609 g_infoContexts.pop_back();
4617 using namespace detail;
4619#if !defined(DOCTEST_CONFIG_POSIX_SIGNALS) && !defined(DOCTEST_CONFIG_WINDOWS_SEH)
4620 struct FatalConditionHandler
4622 static void reset() {}
4623 static void allocateAltStackMem() {}
4624 static void freeAltStackMem() {}
4630#ifdef DOCTEST_PLATFORM_WINDOWS
4640 SignalDefs signalDefs[] = {
4641 {
static_cast<DWORD
>(EXCEPTION_ILLEGAL_INSTRUCTION),
4642 "SIGILL - Illegal instruction signal"},
4643 {
static_cast<DWORD
>(EXCEPTION_STACK_OVERFLOW),
"SIGSEGV - Stack overflow"},
4644 {
static_cast<DWORD
>(EXCEPTION_ACCESS_VIOLATION),
4645 "SIGSEGV - Segmentation violation signal"},
4646 {
static_cast<DWORD
>(EXCEPTION_INT_DIVIDE_BY_ZERO),
"Divide by zero error"},
4649 struct FatalConditionHandler
4651 static LONG CALLBACK handleException(PEXCEPTION_POINTERS ExceptionInfo) {
4654 DOCTEST_DECLARE_STATIC_MUTEX(
mutex)
4655 static bool execute =
true;
4657 DOCTEST_LOCK_MUTEX(
mutex)
4659 bool reported =
false;
4660 for(
size_t i = 0; i < DOCTEST_COUNTOF(signalDefs); ++i) {
4661 if(ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) {
4662 reportFatal(signalDefs[i].name);
4667 if(reported ==
false)
4668 reportFatal(
"Unhandled SEH exception caught");
4677 static void allocateAltStackMem() {}
4678 static void freeAltStackMem() {}
4680 FatalConditionHandler() {
4684 guaranteeSize = 32 * 1024;
4686 previousTop = SetUnhandledExceptionFilter(handleException);
4688 SetThreadStackGuarantee(&guaranteeSize);
4698 reportFatal(
"Terminate handler called");
4709 if(signal == SIGABRT) {
4710 reportFatal(
"SIGABRT - Abort (abnormal termination) signal");
4721 prev_error_mode_1 = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT |
4722 SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
4724 prev_error_mode_2 = _set_error_mode(_OUT_TO_STDERR);
4727 prev_abort_behavior = _set_abort_behavior(0x0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
4732 prev_report_mode = _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
4733 prev_report_file = _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
4736 static void reset() {
4739 SetUnhandledExceptionFilter(previousTop);
4740 SetThreadStackGuarantee(&guaranteeSize);
4743 SetErrorMode(prev_error_mode_1);
4744 _set_error_mode(prev_error_mode_2);
4745 _set_abort_behavior(prev_abort_behavior, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
4746 static_cast<void>(_CrtSetReportMode(_CRT_ASSERT, prev_report_mode));
4747 static_cast<void>(_CrtSetReportFile(_CRT_ASSERT, prev_report_file));
4752 ~FatalConditionHandler() { reset(); }
4755 static UINT prev_error_mode_1;
4756 static int prev_error_mode_2;
4757 static unsigned int prev_abort_behavior;
4758 static int prev_report_mode;
4759 static _HFILE prev_report_file;
4760 static void (DOCTEST_CDECL *prev_sigabrt_handler)(
int);
4763 static ULONG guaranteeSize;
4764 static LPTOP_LEVEL_EXCEPTION_FILTER previousTop;
4767 UINT FatalConditionHandler::prev_error_mode_1;
4768 int FatalConditionHandler::prev_error_mode_2;
4769 unsigned int FatalConditionHandler::prev_abort_behavior;
4770 int FatalConditionHandler::prev_report_mode;
4771 _HFILE FatalConditionHandler::prev_report_file;
4772 void (DOCTEST_CDECL *FatalConditionHandler::prev_sigabrt_handler)(
int);
4774 bool FatalConditionHandler::isSet =
false;
4775 ULONG FatalConditionHandler::guaranteeSize = 0;
4776 LPTOP_LEVEL_EXCEPTION_FILTER FatalConditionHandler::previousTop =
nullptr;
4785 SignalDefs signalDefs[] = {{SIGINT,
"SIGINT - Terminal interrupt signal"},
4786 {SIGILL,
"SIGILL - Illegal instruction signal"},
4787 {SIGFPE,
"SIGFPE - Floating point error signal"},
4788 {SIGSEGV,
"SIGSEGV - Segmentation violation signal"},
4789 {SIGTERM,
"SIGTERM - Termination request signal"},
4790 {SIGABRT,
"SIGABRT - Abort (abnormal termination) signal"}};
4792 struct FatalConditionHandler
4795 static struct sigaction oldSigActions[DOCTEST_COUNTOF(signalDefs)];
4796 static stack_t oldSigStack;
4797 static size_t altStackSize;
4798 static char* altStackMem;
4800 static void handleSignal(
int sig) {
4801 const char* name =
"<unknown signal>";
4802 for(
std::size_t i = 0; i < DOCTEST_COUNTOF(signalDefs); ++i) {
4803 SignalDefs& def = signalDefs[i];
4814 static void allocateAltStackMem() {
4815 altStackMem =
new char[altStackSize];
4818 static void freeAltStackMem() {
4819 delete[] altStackMem;
4822 FatalConditionHandler() {
4825 sigStack.ss_sp = altStackMem;
4826 sigStack.ss_size = altStackSize;
4827 sigStack.ss_flags = 0;
4828 sigaltstack(&sigStack, &oldSigStack);
4829 struct sigaction sa = {};
4830 sa.sa_handler = handleSignal;
4831 sa.sa_flags = SA_ONSTACK;
4832 for(
std::size_t i = 0; i < DOCTEST_COUNTOF(signalDefs); ++i) {
4833 sigaction(signalDefs[i].
id, &sa, &oldSigActions[i]);
4837 ~FatalConditionHandler() { reset(); }
4838 static void reset() {
4841 for(
std::size_t i = 0; i < DOCTEST_COUNTOF(signalDefs); ++i) {
4842 sigaction(signalDefs[i].
id, &oldSigActions[i],
nullptr);
4845 sigaltstack(&oldSigStack,
nullptr);
4851 bool FatalConditionHandler::isSet =
false;
4852 struct sigaction FatalConditionHandler::oldSigActions[DOCTEST_COUNTOF(signalDefs)] = {};
4853 stack_t FatalConditionHandler::oldSigStack = {};
4854 size_t FatalConditionHandler::altStackSize = 4 * SIGSTKSZ;
4855 char* FatalConditionHandler::altStackMem =
nullptr;
4863 using namespace detail;
4865#ifdef DOCTEST_PLATFORM_WINDOWS
4866#define DOCTEST_OUTPUT_DEBUG_STRING(text) ::OutputDebugStringA(text)
4869#define DOCTEST_OUTPUT_DEBUG_STRING(text)
4872 void addAssert(assertType::Enum at) {
4873 if((at & assertType::is_warn) == 0)
4874 g_cs->numAssertsCurrentTest_atomic++;
4877 void addFailedAssert(assertType::Enum at) {
4878 if((at & assertType::is_warn) == 0)
4879 g_cs->numAssertsFailedCurrentTest_atomic++;
4882#if defined(DOCTEST_CONFIG_POSIX_SIGNALS) || defined(DOCTEST_CONFIG_WINDOWS_SEH)
4884 g_cs->failure_flags |= TestCaseFailureReason::Crash;
4886 DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_exception, {message.
c_str(),
true});
4888 while (g_cs->subcaseStack.size()) {
4889 g_cs->subcaseStack.pop_back();
4890 DOCTEST_ITERATE_THROUGH_REPORTERS(subcase_end,
DOCTEST_EMPTY);
4893 g_cs->finalizeTestCaseData();
4895 DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_end, *g_cs);
4897 DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_end, *g_cs);
4902AssertData::AssertData(assertType::Enum at,
const char* file,
int line,
const char* expr,
4903 const char* exception_type,
const StringContains& exception_string)
4904 : m_test_case(g_cs->currentTest), m_at(at), m_file(file), m_line(
line), m_expr(expr),
4905 m_failed(true), m_threw(false), m_threw_as(false), m_exception_type(exception_type),
4906 m_exception_string(exception_string) {
4908 if (m_expr[0] ==
' ')
4914 ResultBuilder::ResultBuilder(assertType::Enum at,
const char* file,
int line,
const char* expr,
4915 const char* exception_type,
const String& exception_string)
4916 : AssertData(at, file,
line, expr, exception_type, exception_string) { }
4918 ResultBuilder::ResultBuilder(assertType::Enum at,
const char* file,
int line,
const char* expr,
4919 const char* exception_type,
const Contains& exception_string)
4920 : AssertData(at, file,
line, expr, exception_type, exception_string) { }
4922 void ResultBuilder::setResult(
const Result& res) {
4923 m_decomp = res.m_decomp;
4924 m_failed = !res.m_passed;
4927 void ResultBuilder::translateException() {
4929 m_exception = translateActiveException();
4932 bool ResultBuilder::log() {
4933 if(m_at & assertType::is_throws) {
4934 m_failed = !m_threw;
4935 }
else if((m_at & assertType::is_throws_as) && (m_at & assertType::is_throws_with)) {
4936 m_failed = !m_threw_as || !m_exception_string.check(m_exception);
4937 }
else if(m_at & assertType::is_throws_as) {
4938 m_failed = !m_threw_as;
4939 }
else if(m_at & assertType::is_throws_with) {
4940 m_failed = !m_exception_string.check(m_exception);
4941 }
else if(m_at & assertType::is_nothrow) {
4945 if(m_exception.size())
4946 m_exception =
"\"" + m_exception +
"\"";
4948 if(is_running_in_test) {
4950 DOCTEST_ITERATE_THROUGH_REPORTERS(log_assert, *
this);
4953 addFailedAssert(m_at);
4954 }
else if(m_failed) {
4959 (g_cs->currentTest ==
nullptr || !g_cs->currentTest->m_no_breaks);
4962 void ResultBuilder::react()
const {
4974 bool decomp_assert(assertType::Enum at,
const char* file,
int line,
const char* expr,
4976 bool failed = !
result.m_passed;
4987 MessageBuilder::MessageBuilder(
const char* file,
int line, assertType::Enum severity) {
4991 m_severity = severity;
4994 MessageBuilder::~MessageBuilder() {
5001 bool MessageBuilder::log() {
5007 DOCTEST_ITERATE_THROUGH_REPORTERS(log_message, *
this);
5009 const bool isWarn = m_severity & assertType::is_warn;
5013 addAssert(m_severity);
5014 addFailedAssert(m_severity);
5018 (g_cs->currentTest ==
nullptr || !g_cs->currentTest->m_no_breaks);
5021 void MessageBuilder::react() {
5022 if(m_severity & assertType::is_require)
5027 using namespace detail;
5038 enum ForWhat { ForTextNodes, ForAttributes };
5040 XmlEncode(
std::string const& str, ForWhat forWhat = ForTextNodes );
5054 class ScopedElement {
5056 ScopedElement( XmlWriter* writer );
5063 ScopedElement& writeText(
std::string const& text,
bool indent =
true );
5065 template<
typename T>
5066 ScopedElement& writeAttribute(
std::string const& name, T
const& attribute ) {
5067 m_writer->writeAttribute( name, attribute );
5072 mutable XmlWriter* m_writer =
nullptr;
5075#ifndef DOCTEST_CONFIG_NO_INCLUDE_IOSTREAM
5082 XmlWriter( XmlWriter
const& ) =
delete;
5083 XmlWriter& operator=( XmlWriter
const& ) =
delete;
5085 XmlWriter& startElement(
std::string const& name );
5087 ScopedElement scopedElement(
std::string const& name );
5089 XmlWriter& endElement();
5093 XmlWriter& writeAttribute(
std::string const& name,
const char* attribute );
5095 XmlWriter& writeAttribute(
std::string const& name,
bool attribute );
5097 template<
typename T>
5098 XmlWriter& writeAttribute(
std::string const& name, T
const& attribute ) {
5101 return writeAttribute( name, rss.
str() );
5104 XmlWriter& writeText(
std::string const& text,
bool indent =
true );
5112 void ensureTagClosed();
5114 void writeDeclaration();
5118 void newlineIfNecessary();
5120 bool m_tagIsOpen =
false;
5121 bool m_needsNewline =
false;
5132using uchar =
unsigned char;
5136 size_t trailingBytes(
unsigned char c) {
5137 if ((c & 0xE0) == 0xC0) {
5140 if ((c & 0xF0) == 0xE0) {
5143 if ((c & 0xF8) == 0xF0) {
5146 DOCTEST_INTERNAL_ERROR(
"Invalid multibyte utf-8 start byte encountered");
5149 uint32_t headerValue(
unsigned char c) {
5150 if ((c & 0xE0) == 0xC0) {
5153 if ((c & 0xF0) == 0xE0) {
5156 if ((c & 0xF8) == 0xF0) {
5159 DOCTEST_INTERNAL_ERROR(
"Invalid multibyte utf-8 start byte encountered");
5162 void hexEscapeChar(
std::ostream& os,
unsigned char c) {
5163 std::ios_base::fmtflags f(os.flags());
5166 <<
static_cast<int>(c);
5172 XmlEncode::XmlEncode(
std::string const& str, ForWhat forWhat )
5174 m_forWhat( forWhat )
5181 for(
std::size_t idx = 0; idx < m_str.size(); ++ idx ) {
5182 uchar c = m_str[idx];
5184 case '<': os <<
"<";
break;
5185 case '&': os <<
"&";
break;
5189 if (idx > 2 && m_str[idx - 1] ==
']' && m_str[idx - 2] ==
']')
5196 if (m_forWhat == ForAttributes)
5207 if (c < 0x09 || (c > 0x0D && c < 0x20) || c == 0x7F) {
5208 hexEscapeChar(os, c);
5226 hexEscapeChar(os, c);
5230 auto encBytes = trailingBytes(c);
5232 if (idx + encBytes - 1 >= m_str.size()) {
5233 hexEscapeChar(os, c);
5242 uchar nc = m_str[idx + n];
5243 valid &= ((nc & 0xC0) == 0x80);
5252 ( value < 0x800 && encBytes > 2) ||
5253 (0x800 <
value && value < 0x10000 && encBytes > 3) ||
5257 hexEscapeChar(os, c);
5263 os << m_str[idx + n];
5265 idx += encBytes - 1;
5272 xmlEncode.encodeTo( os );
5276 XmlWriter::ScopedElement::ScopedElement( XmlWriter* writer )
5277 : m_writer( writer )
5280 XmlWriter::ScopedElement::ScopedElement( ScopedElement&& other )
DOCTEST_NOEXCEPT
5281 : m_writer( other.m_writer ){
5282 other.m_writer =
nullptr;
5284 XmlWriter::ScopedElement& XmlWriter::ScopedElement::operator=( ScopedElement&& other )
DOCTEST_NOEXCEPT {
5286 m_writer->endElement();
5288 m_writer = other.m_writer;
5289 other.m_writer =
nullptr;
5294 XmlWriter::ScopedElement::~ScopedElement() {
5296 m_writer->endElement();
5299 XmlWriter::ScopedElement& XmlWriter::ScopedElement::writeText(
std::string const& text,
bool indent ) {
5300 m_writer->writeText( text, indent );
5309 XmlWriter::~XmlWriter() {
5310 while( !m_tags.empty() )
5314 XmlWriter& XmlWriter::startElement(
std::string const& name ) {
5316 newlineIfNecessary();
5317 m_os << m_indent <<
'<' <<
name;
5318 m_tags.push_back( name );
5324 XmlWriter::ScopedElement XmlWriter::scopedElement(
std::string const& name ) {
5325 ScopedElement scoped(
this );
5326 startElement( name );
5330 XmlWriter& XmlWriter::endElement() {
5331 newlineIfNecessary();
5332 m_indent = m_indent.substr( 0, m_indent.size()-2 );
5335 m_tagIsOpen =
false;
5338 m_os << m_indent <<
"</" << m_tags.back() <<
">";
5346 if( !name.empty() && !attribute.empty() )
5347 m_os <<
' ' << name <<
"=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) <<
'"';
5351 XmlWriter& XmlWriter::writeAttribute(
std::string const& name,
const char* attribute ) {
5352 if( !name.empty() && attribute && attribute[0] !=
'\0' )
5353 m_os <<
' ' << name <<
"=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) <<
'"';
5357 XmlWriter& XmlWriter::writeAttribute(
std::string const& name,
bool attribute ) {
5358 m_os <<
' ' << name <<
"=\"" << ( attribute ?
"true" :
"false" ) <<
'"';
5362 XmlWriter& XmlWriter::writeText(
std::string const& text,
bool indent ) {
5363 if( !text.
empty() ){
5364 bool tagWasOpen = m_tagIsOpen;
5366 if( tagWasOpen && indent )
5368 m_os << XmlEncode( text );
5369 m_needsNewline =
true;
5391 void XmlWriter::ensureTagClosed() {
5394 m_tagIsOpen =
false;
5398 void XmlWriter::writeDeclaration() {
5399 m_os <<
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
5402 void XmlWriter::newlineIfNecessary() {
5403 if( m_needsNewline ) {
5405 m_needsNewline =
false;
5415 struct XmlReporter :
public IReporter
5418 DOCTEST_DECLARE_MUTEX(
mutex)
5421 const ContextOptions& opt;
5422 const TestCaseData* tc =
nullptr;
5424 XmlReporter(
const ContextOptions& co)
5428 void log_contexts() {
5429 int num_contexts = get_num_active_contexts();
5431 auto contexts = get_active_contexts();
5433 for(
int i = 0; i < num_contexts; ++i) {
5434 contexts[i]->stringify(&ss);
5435 xml.scopedElement(
"Info").writeText(ss.
str());
5441 unsigned line(
unsigned l)
const {
return opt.no_line_numbers ? 0 : l; }
5443 void test_case_start_impl(
const TestCaseData& in) {
5444 bool open_ts_tag =
false;
5446 if(
std::strcmp(tc->m_test_suite, in.m_test_suite) != 0) {
5456 xml.startElement(
"TestSuite");
5457 xml.writeAttribute(
"name", in.m_test_suite);
5461 xml.startElement(
"TestCase")
5462 .writeAttribute(
"name", in.m_name)
5464 .writeAttribute(
"line",
line(in.m_line))
5465 .writeAttribute(
"description", in.m_description);
5467 if(Approx(in.m_timeout) != 0)
5468 xml.writeAttribute(
"timeout", in.m_timeout);
5470 xml.writeAttribute(
"may_fail",
true);
5471 if(in.m_should_fail)
5472 xml.writeAttribute(
"should_fail",
true);
5479 void report_query(
const QueryData& in)
override {
5481 if(opt.list_reporters) {
5482 for(
auto& curr : getListeners())
5483 xml.scopedElement(
"Listener")
5484 .writeAttribute(
"priority", curr.
first.
first)
5486 for(
auto& curr : getReporters())
5487 xml.scopedElement(
"Reporter")
5488 .writeAttribute(
"priority", curr.
first.
first)
5490 }
else if(opt.count || opt.list_test_cases) {
5491 for(
unsigned i = 0; i < in.num_data; ++i) {
5492 xml.scopedElement(
"TestCase").writeAttribute(
"name", in.data[i]->m_name)
5493 .writeAttribute(
"testsuite", in.data[i]->m_test_suite)
5495 .writeAttribute(
"line",
line(in.data[i]->m_line))
5496 .writeAttribute(
"skipped", in.data[i]->m_skip);
5498 xml.scopedElement(
"OverallResultsTestCases")
5499 .writeAttribute(
"unskipped", in.run_stats->numTestCasesPassingFilters);
5500 }
else if(opt.list_test_suites) {
5501 for(
unsigned i = 0; i < in.num_data; ++i)
5502 xml.scopedElement(
"TestSuite").writeAttribute(
"name", in.data[i]->m_test_suite);
5503 xml.scopedElement(
"OverallResultsTestCases")
5504 .writeAttribute(
"unskipped", in.run_stats->numTestCasesPassingFilters);
5505 xml.scopedElement(
"OverallResultsTestSuites")
5506 .writeAttribute(
"unskipped", in.run_stats->numTestSuitesPassingFilters);
5511 void test_run_start()
override {
5512 xml.writeDeclaration();
5516#ifdef DOCTEST_PLATFORM_WINDOWS
5517 if(binary_name.
rfind(
".exe") != std::string::npos)
5518 binary_name = binary_name.
substr(0, binary_name.
length() - 4);
5521 xml.startElement(
"doctest").writeAttribute(
"binary", binary_name);
5522 if(opt.no_version ==
false)
5526 xml.scopedElement(
"Options")
5527 .writeAttribute(
"order_by", opt.order_by.c_str())
5528 .writeAttribute(
"rand_seed", opt.rand_seed)
5529 .writeAttribute(
"first", opt.first)
5530 .writeAttribute(
"last", opt.last)
5531 .writeAttribute(
"abort_after", opt.abort_after)
5532 .writeAttribute(
"subcase_filter_levels", opt.subcase_filter_levels)
5533 .writeAttribute(
"case_sensitive", opt.case_sensitive)
5534 .writeAttribute(
"no_throw", opt.no_throw)
5535 .writeAttribute(
"no_skip", opt.no_skip);
5538 void test_run_end(
const TestRunStats& p)
override {
5542 xml.scopedElement(
"OverallResultsAsserts")
5543 .writeAttribute(
"successes", p.numAsserts - p.numAssertsFailed)
5544 .writeAttribute(
"failures", p.numAssertsFailed);
5546 xml.startElement(
"OverallResultsTestCases")
5547 .writeAttribute(
"successes",
5548 p.numTestCasesPassingFilters - p.numTestCasesFailed)
5549 .writeAttribute(
"failures", p.numTestCasesFailed);
5550 if(opt.no_skipped_summary ==
false)
5551 xml.writeAttribute(
"skipped", p.numTestCases - p.numTestCasesPassingFilters);
5557 void test_case_start(
const TestCaseData& in)
override {
5558 test_case_start_impl(in);
5559 xml.ensureTagClosed();
5562 void test_case_reenter(
const TestCaseData&)
override {}
5564 void test_case_end(
const CurrentTestCaseStats& st)
override {
5565 xml.startElement(
"OverallResultsAsserts")
5566 .writeAttribute(
"successes",
5567 st.numAssertsCurrentTest - st.numAssertsFailedCurrentTest)
5568 .writeAttribute(
"failures", st.numAssertsFailedCurrentTest)
5569 .writeAttribute(
"test_case_success", st.testCaseSuccess);
5571 xml.writeAttribute(
"duration", st.seconds);
5572 if(tc->m_expected_failures)
5573 xml.writeAttribute(
"expected_failures", tc->m_expected_failures);
5579 void test_case_exception(
const TestCaseException& e)
override {
5580 DOCTEST_LOCK_MUTEX(
mutex)
5582 xml.scopedElement(
"Exception")
5583 .writeAttribute(
"crash", e.is_crash)
5584 .writeText(e.error_string.c_str());
5587 void subcase_start(
const SubcaseSignature& in)
override {
5588 xml.startElement(
"SubCase")
5589 .writeAttribute(
"name", in.m_name)
5591 .writeAttribute(
"line",
line(in.m_line));
5592 xml.ensureTagClosed();
5595 void subcase_end()
override { xml.endElement(); }
5597 void log_assert(
const AssertData& rb)
override {
5598 if(!rb.m_failed && !opt.success)
5601 DOCTEST_LOCK_MUTEX(
mutex)
5603 xml.startElement(
"Expression")
5604 .writeAttribute(
"success", !rb.m_failed)
5607 .writeAttribute(
"line",
line(rb.m_line));
5609 xml.scopedElement(
"Original").writeText(rb.m_expr);
5612 xml.scopedElement(
"Exception").writeText(rb.m_exception.c_str());
5614 if(rb.m_at & assertType::is_throws_as)
5615 xml.scopedElement(
"ExpectedException").writeText(rb.m_exception_type);
5616 if(rb.m_at & assertType::is_throws_with)
5617 xml.scopedElement(
"ExpectedExceptionString").writeText(rb.m_exception_string.c_str());
5618 if((rb.m_at & assertType::is_normal) && !rb.m_threw)
5619 xml.scopedElement(
"Expanded").writeText(rb.m_decomp.c_str());
5626 void log_message(
const MessageData& mb)
override {
5627 DOCTEST_LOCK_MUTEX(
mutex)
5629 xml.startElement(
"Message")
5632 .writeAttribute(
"line",
line(mb.m_line));
5634 xml.scopedElement(
"Text").writeText(mb.m_string.c_str());
5641 void test_case_skipped(
const TestCaseData& in)
override {
5642 if(opt.no_skipped_summary ==
false) {
5643 test_case_start_impl(in);
5644 xml.writeAttribute(
"skipped",
"true");
5652 void fulltext_log_assert_to_stream(
std::ostream& s,
const AssertData& rb) {
5653 if((rb.m_at & (assertType::is_throws_as | assertType::is_throws_with)) ==
5655 s << Color::Cyan <<
assertString(rb.m_at) <<
"( " << rb.m_expr <<
" ) "
5658 if(rb.m_at & assertType::is_throws) {
5659 s << (rb.m_threw ?
"threw as expected!" :
"did NOT throw at all!") <<
"\n";
5660 }
else if((rb.m_at & assertType::is_throws_as) &&
5661 (rb.m_at & assertType::is_throws_with)) {
5662 s << Color::Cyan <<
assertString(rb.m_at) <<
"( " << rb.m_expr <<
", \""
5663 << rb.m_exception_string.c_str()
5664 <<
"\", " << rb.m_exception_type <<
" ) " << Color::None;
5667 s <<
"threw as expected!\n";
5669 s <<
"threw a DIFFERENT exception! (contents: " << rb.m_exception <<
")\n";
5672 s <<
"did NOT throw at all!\n";
5675 assertType::is_throws_as) {
5676 s << Color::Cyan <<
assertString(rb.m_at) <<
"( " << rb.m_expr <<
", "
5677 << rb.m_exception_type <<
" ) " << Color::None
5678 << (rb.m_threw ? (rb.m_threw_as ?
"threw as expected!" :
5679 "threw a DIFFERENT exception: ") :
5680 "did NOT throw at all!")
5681 << Color::
Cyan << rb.m_exception <<
"\n";
5683 assertType::is_throws_with) {
5684 s << Color::Cyan <<
assertString(rb.m_at) <<
"( " << rb.m_expr <<
", \""
5685 << rb.m_exception_string.c_str()
5686 <<
"\" ) " << Color::None
5687 << (rb.m_threw ? (!rb.m_failed ?
"threw as expected!" :
5688 "threw a DIFFERENT exception: ") :
5689 "did NOT throw at all!")
5690 << Color::
Cyan << rb.m_exception <<
"\n";
5691 }
else if(rb.m_at & assertType::is_nothrow) {
5692 s << (rb.m_threw ?
"THREW exception: " :
"didn't throw!") << Color::Cyan
5693 << rb.m_exception <<
"\n";
5695 s << (rb.m_threw ?
"THREW exception: " :
5696 (!rb.m_failed ?
"is correct!\n" :
"is NOT correct!\n"));
5698 s << rb.m_exception <<
"\n";
5700 s <<
" values: " <<
assertString(rb.m_at) <<
"( " << rb.m_decomp <<
" )\n";
5709 struct JUnitReporter :
public IReporter
5712 DOCTEST_DECLARE_MUTEX(
mutex)
5716 struct JUnitTestCaseData
5723 auto const timeStampSize =
sizeof(
"2017-01-16T17:06:45Z");
5726#ifdef DOCTEST_PLATFORM_WINDOWS
5727 gmtime_s(&timeInfo, &rawtime);
5729 gmtime_r(&rawtime, &timeInfo);
5732 char timeStamp[timeStampSize];
5733 const char*
const fmt =
"%Y-%m-%dT%H:%M:%SZ";
5739 struct JUnitTestMessage
5742 : message(_message), type(_type),
details(_details) {}
5745 : message(_message), type(),
details(_details) {}
5750 struct JUnitTestCase
5753 : classname(_classname), name(_name), time(0), failures() {}
5761 testcases.emplace_back(classname, name);
5765 for(
auto& curr: nameStack)
5767 testcases.back().name +=
std::
string(
"/") + curr.c_str();
5770 void addTime(
double time) {
5773 testcases.
back().time = time;
5774 totalSeconds += time;
5778 testcases.back().failures.emplace_back(message, type,
details);
5783 testcases.back().errors.emplace_back(message,
details);
5788 double totalSeconds = 0;
5789 int totalErrors = 0, totalFailures = 0;
5792 JUnitTestCaseData testCaseData;
5795 const ContextOptions& opt;
5796 const TestCaseData* tc =
nullptr;
5798 JUnitReporter(
const ContextOptions& co)
5802 unsigned line(
unsigned l)
const {
return opt.no_line_numbers ? 0 : l; }
5808 void report_query(
const QueryData&)
override {
5809 xml.writeDeclaration();
5812 void test_run_start()
override {
5813 xml.writeDeclaration();
5816 void test_run_end(
const TestRunStats& p)
override {
5819#ifdef DOCTEST_PLATFORM_WINDOWS
5820 if(binary_name.
rfind(
".exe") != std::string::npos)
5821 binary_name = binary_name.
substr(0, binary_name.
length() - 4);
5823 xml.startElement(
"testsuites");
5824 xml.startElement(
"testsuite").writeAttribute(
"name", binary_name)
5825 .writeAttribute(
"errors", testCaseData.totalErrors)
5826 .writeAttribute(
"failures", testCaseData.totalFailures)
5827 .writeAttribute(
"tests", p.numAsserts);
5828 if(opt.no_time_in_output ==
false) {
5829 xml.writeAttribute(
"time", testCaseData.totalSeconds);
5830 xml.writeAttribute(
"timestamp", JUnitTestCaseData::getCurrentTimestamp());
5832 if(opt.no_version ==
false)
5835 for(
const auto& testCase : testCaseData.testcases) {
5836 xml.startElement(
"testcase")
5837 .writeAttribute(
"classname", testCase.classname)
5838 .writeAttribute(
"name", testCase.name);
5839 if(opt.no_time_in_output ==
false)
5840 xml.writeAttribute(
"time", testCase.time);
5842 xml.writeAttribute(
"status",
"run");
5844 for(
const auto& failure : testCase.failures) {
5845 xml.scopedElement(
"failure")
5846 .writeAttribute(
"message", failure.message)
5847 .writeAttribute(
"type", failure.type)
5848 .writeText(failure.details,
false);
5851 for(
const auto& error : testCase.errors) {
5852 xml.scopedElement(
"error")
5853 .writeAttribute(
"message",
error.message)
5854 .writeText(
error.details);
5863 void test_case_start(
const TestCaseData& in)
override {
5868 void test_case_reenter(
const TestCaseData& in)
override {
5869 testCaseData.addTime(timer.getElapsedSeconds());
5870 testCaseData.appendSubcaseNamesToLastTestcase(deepestSubcaseStackNames);
5871 deepestSubcaseStackNames.
clear();
5877 void test_case_end(
const CurrentTestCaseStats&)
override {
5878 testCaseData.addTime(timer.getElapsedSeconds());
5879 testCaseData.appendSubcaseNamesToLastTestcase(deepestSubcaseStackNames);
5880 deepestSubcaseStackNames.
clear();
5883 void test_case_exception(
const TestCaseException& e)
override {
5884 DOCTEST_LOCK_MUTEX(
mutex)
5885 testCaseData.addError(
"exception", e.error_string.c_str());
5888 void subcase_start(
const SubcaseSignature& in)
override {
5889 deepestSubcaseStackNames.
push_back(in.m_name);
5892 void subcase_end()
override {}
5894 void log_assert(
const AssertData& rb)
override {
5898 DOCTEST_LOCK_MUTEX(
mutex)
5902 <<
line(rb.m_line) << (opt.gnu_file_line ?
":" :
"):") <<
std::endl;
5904 fulltext_log_assert_to_stream(os, rb);
5906 testCaseData.addFailure(rb.m_decomp.c_str(),
assertString(rb.m_at), os.str());
5909 void log_message(
const MessageData& mb)
override {
5910 if(mb.m_severity & assertType::is_warn)
5913 DOCTEST_LOCK_MUTEX(
mutex)
5917 <<
line(mb.m_line) << (opt.gnu_file_line ?
":" :
"):") <<
std::endl;
5919 os << mb.m_string.c_str() <<
"\n";
5922 testCaseData.addFailure(mb.m_string.c_str(),
5923 mb.m_severity & assertType::is_check ?
"FAIL_CHECK" :
"FAIL", os.str());
5926 void test_case_skipped(
const TestCaseData&)
override {}
5929 int num_contexts = get_num_active_contexts();
5931 auto contexts = get_active_contexts();
5934 for(
int i = 0; i < num_contexts; ++i) {
5935 s << (i == 0 ?
"" :
" ");
5936 contexts[i]->stringify(&s);
5948 explicit Whitespace(
int nr)
5953 if(
ws.nrSpaces != 0)
5958 struct ConsoleReporter :
public IReporter
5961 bool hasLoggedCurrentTestStart;
5963 size_t currentSubcaseLevel;
5964 DOCTEST_DECLARE_MUTEX(
mutex)
5967 const ContextOptions& opt;
5968 const TestCaseData* tc;
5970 ConsoleReporter(
const ContextOptions& co)
5974 ConsoleReporter(
const ContextOptions& co,
std::ostream& ostr)
5982 void separator_to_stream() {
5984 <<
"==============================================================================="
5988 const char* getSuccessOrFailString(
bool success, assertType::Enum at,
5989 const char* success_str) {
5995 Color::Enum getSuccessOrFailColor(
bool success, assertType::Enum at) {
5996 return success ? Color::BrightGreen :
5997 (at & assertType::is_warn) ? Color::Yellow : Color::
Red;
6000 void successOrFailColoredStringToStream(
bool success, assertType::Enum at,
6001 const char* success_str =
"SUCCESS") {
6002 s << getSuccessOrFailColor(success, at)
6003 << getSuccessOrFailString(success, at, success_str) <<
": ";
6006 void log_contexts() {
6007 int num_contexts = get_num_active_contexts();
6009 auto contexts = get_active_contexts();
6011 s << Color::None <<
" logged: ";
6012 for(
int i = 0; i < num_contexts; ++i) {
6013 s << (i == 0 ?
"" :
" ");
6014 contexts[i]->stringify(&s);
6023 virtual void file_line_to_stream(
const char* file,
int line,
6024 const char* tail =
"") {
6026 << (opt.no_line_numbers ? 0 :
line)
6027 << (opt.gnu_file_line ?
":" :
"):") << tail;
6030 void logTestStart() {
6031 if(hasLoggedCurrentTestStart)
6034 separator_to_stream();
6035 file_line_to_stream(tc->m_file.c_str(), tc->m_line,
"\n");
6036 if(tc->m_description)
6037 s << Color::Yellow <<
"DESCRIPTION: " << Color::None << tc->m_description <<
"\n";
6038 if(tc->m_test_suite && tc->m_test_suite[0] !=
'\0')
6039 s << Color::Yellow <<
"TEST SUITE: " << Color::None << tc->m_test_suite <<
"\n";
6040 if(
strncmp(tc->m_name,
" Scenario:", 11) != 0)
6041 s << Color::Yellow <<
"TEST CASE: ";
6042 s << Color::None << tc->m_name <<
"\n";
6044 for(
size_t i = 0; i < currentSubcaseLevel; ++i) {
6045 if(subcasesStack[i].m_name[0] !=
'\0')
6046 s <<
" " << subcasesStack[i].m_name <<
"\n";
6049 if(currentSubcaseLevel != subcasesStack.
size()) {
6050 s << Color::Yellow <<
"\nDEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE):\n" << Color::None;
6051 for(
size_t i = 0; i < subcasesStack.
size(); ++i) {
6052 if(subcasesStack[i].m_name[0] !=
'\0')
6053 s <<
" " << subcasesStack[i].m_name <<
"\n";
6059 hasLoggedCurrentTestStart =
true;
6062 void printVersion() {
6063 if(opt.no_version ==
false)
6064 s << Color::Cyan <<
"[doctest] " << Color::None <<
"doctest version is \""
6069 if(opt.no_intro ==
false) {
6071 s << Color::Cyan <<
"[doctest] " << Color::None
6072 <<
"run with \"--" DOCTEST_OPTIONS_PREFIX_DISPLAY
"help\" for options\n";
6077 int sizePrefixDisplay =
static_cast<int>(
strlen(DOCTEST_OPTIONS_PREFIX_DISPLAY));
6080 s << Color::Cyan <<
"[doctest]\n" << Color::None;
6081 s << Color::Cyan <<
"[doctest] " << Color::None;
6082 s <<
"boolean values: \"1/on/yes/true\" or \"0/off/no/false\"\n";
6083 s << Color::Cyan <<
"[doctest] " << Color::None;
6084 s <<
"filter values: \"str1,str2,str3\" (comma separated strings)\n";
6085 s << Color::Cyan <<
"[doctest]\n" << Color::None;
6086 s << Color::Cyan <<
"[doctest] " << Color::None;
6087 s <<
"filters use wildcards for matching strings\n";
6088 s << Color::Cyan <<
"[doctest] " << Color::None;
6089 s <<
"something passes a filter if any of the strings in a filter matches\n";
6090#ifndef DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS
6091 s << Color::Cyan <<
"[doctest]\n" << Color::None;
6092 s << Color::Cyan <<
"[doctest] " << Color::None;
6093 s <<
"ALL FLAGS, OPTIONS AND FILTERS ALSO AVAILABLE WITH A \"" DOCTEST_CONFIG_OPTIONS_PREFIX
"\" PREFIX!!!\n";
6095 s << Color::Cyan <<
"[doctest]\n" << Color::None;
6096 s << Color::Cyan <<
"[doctest] " << Color::None;
6097 s <<
"Query flags - the program quits after them. Available:\n\n";
6098 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"?, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"help, -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"h "
6099 << Whitespace(sizePrefixDisplay*0) <<
"prints this message\n";
6100 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"v, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"version "
6101 << Whitespace(sizePrefixDisplay*1) <<
"prints the version\n";
6102 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"c, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"count "
6103 << Whitespace(sizePrefixDisplay*1) <<
"prints the number of matching tests\n";
6104 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"ltc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"list-test-cases "
6105 << Whitespace(sizePrefixDisplay*1) <<
"lists all matching tests by name\n";
6106 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"lts, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"list-test-suites "
6107 << Whitespace(sizePrefixDisplay*1) <<
"lists all matching test suites\n";
6108 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"lr, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"list-reporters "
6109 << Whitespace(sizePrefixDisplay*1) <<
"lists all registered reporters\n\n";
6111 s << Color::Cyan <<
"[doctest] " << Color::None;
6112 s <<
"The available <int>/<string> options/filters are:\n\n";
6113 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"tc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"test-case=<filters> "
6114 << Whitespace(sizePrefixDisplay*1) <<
"filters tests by their name\n";
6115 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"tce, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"test-case-exclude=<filters> "
6116 << Whitespace(sizePrefixDisplay*1) <<
"filters OUT tests by their name\n";
6117 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"sf, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"source-file=<filters> "
6118 << Whitespace(sizePrefixDisplay*1) <<
"filters tests by their file\n";
6119 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"sfe, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"source-file-exclude=<filters> "
6120 << Whitespace(sizePrefixDisplay*1) <<
"filters OUT tests by their file\n";
6121 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"ts, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"test-suite=<filters> "
6122 << Whitespace(sizePrefixDisplay*1) <<
"filters tests by their test suite\n";
6123 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"tse, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"test-suite-exclude=<filters> "
6124 << Whitespace(sizePrefixDisplay*1) <<
"filters OUT tests by their test suite\n";
6125 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"sc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"subcase=<filters> "
6126 << Whitespace(sizePrefixDisplay*1) <<
"filters subcases by their name\n";
6127 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"sce, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"subcase-exclude=<filters> "
6128 << Whitespace(sizePrefixDisplay*1) <<
"filters OUT subcases by their name\n";
6129 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"r, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"reporters=<filters> "
6130 << Whitespace(sizePrefixDisplay*1) <<
"reporters to use (console is default)\n";
6131 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"o, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"out=<string> "
6132 << Whitespace(sizePrefixDisplay*1) <<
"output filename\n";
6133 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"ob, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"order-by=<string> "
6134 << Whitespace(sizePrefixDisplay*1) <<
"how the tests should be ordered\n";
6135 s << Whitespace(sizePrefixDisplay*3) <<
" <string> - [file/suite/name/rand/none]\n";
6136 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"rs, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"rand-seed=<int> "
6137 << Whitespace(sizePrefixDisplay*1) <<
"seed for random ordering\n";
6138 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"f, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"first=<int> "
6139 << Whitespace(sizePrefixDisplay*1) <<
"the first test passing the filters to\n";
6140 s << Whitespace(sizePrefixDisplay*3) <<
" execute - for range-based execution\n";
6141 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"l, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"last=<int> "
6142 << Whitespace(sizePrefixDisplay*1) <<
"the last test passing the filters to\n";
6143 s << Whitespace(sizePrefixDisplay*3) <<
" execute - for range-based execution\n";
6144 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"aa, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"abort-after=<int> "
6145 << Whitespace(sizePrefixDisplay*1) <<
"stop after <int> failed assertions\n";
6146 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"scfl,--" DOCTEST_OPTIONS_PREFIX_DISPLAY
"subcase-filter-levels=<int> "
6147 << Whitespace(sizePrefixDisplay*1) <<
"apply filters for the first <int> levels\n";
6148 s << Color::Cyan <<
"\n[doctest] " << Color::None;
6149 s <<
"Bool options - can be used like flags and true is assumed. Available:\n\n";
6150 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"s, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"success=<bool> "
6151 << Whitespace(sizePrefixDisplay*1) <<
"include successful assertions in output\n";
6152 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"cs, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"case-sensitive=<bool> "
6153 << Whitespace(sizePrefixDisplay*1) <<
"filters being treated as case sensitive\n";
6154 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"e, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"exit=<bool> "
6155 << Whitespace(sizePrefixDisplay*1) <<
"exits after the tests finish\n";
6156 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"d, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"duration=<bool> "
6157 << Whitespace(sizePrefixDisplay*1) <<
"prints the time duration of each test\n";
6158 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"m, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"minimal=<bool> "
6159 << Whitespace(sizePrefixDisplay*1) <<
"minimal console output (only failures)\n";
6160 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"q, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"quiet=<bool> "
6161 << Whitespace(sizePrefixDisplay*1) <<
"no console output\n";
6162 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"nt, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"no-throw=<bool> "
6163 << Whitespace(sizePrefixDisplay*1) <<
"skips exceptions-related assert checks\n";
6164 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"ne, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"no-exitcode=<bool> "
6165 << Whitespace(sizePrefixDisplay*1) <<
"returns (or exits) always with success\n";
6166 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"nr, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"no-run=<bool> "
6167 << Whitespace(sizePrefixDisplay*1) <<
"skips all runtime doctest operations\n";
6168 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"ni, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"no-intro=<bool> "
6169 << Whitespace(sizePrefixDisplay*1) <<
"omit the framework intro in the output\n";
6170 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"nv, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"no-version=<bool> "
6171 << Whitespace(sizePrefixDisplay*1) <<
"omit the framework version in the output\n";
6172 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"nc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"no-colors=<bool> "
6173 << Whitespace(sizePrefixDisplay*1) <<
"disables colors in output\n";
6174 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"fc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"force-colors=<bool> "
6175 << Whitespace(sizePrefixDisplay*1) <<
"use colors even when not in a tty\n";
6176 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"nb, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"no-breaks=<bool> "
6177 << Whitespace(sizePrefixDisplay*1) <<
"disables breakpoints in debuggers\n";
6178 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"ns, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"no-skip=<bool> "
6179 << Whitespace(sizePrefixDisplay*1) <<
"don't skip test cases marked as skip\n";
6180 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"gfl, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"gnu-file-line=<bool> "
6181 << Whitespace(sizePrefixDisplay*1) <<
":n: vs (n): for line numbers in output\n";
6182 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"npf, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"no-path-filenames=<bool> "
6183 << Whitespace(sizePrefixDisplay*1) <<
"only filenames and no paths in output\n";
6184 s <<
" -" DOCTEST_OPTIONS_PREFIX_DISPLAY
"nln, --" DOCTEST_OPTIONS_PREFIX_DISPLAY
"no-line-numbers=<bool> "
6185 << Whitespace(sizePrefixDisplay*1) <<
"0 instead of real line numbers in output\n";
6189 s << Color::Cyan <<
"\n[doctest] " << Color::None;
6190 s <<
"for more information visit the project documentation\n\n";
6193 void printRegisteredReporters() {
6195 auto printReporters = [
this] (
const reporterMap& reporters,
const char*
type) {
6196 if(reporters.size()) {
6197 s << Color::Cyan <<
"[doctest] " << Color::None <<
"listing all registered " << type <<
"\n";
6198 for(
auto& curr : reporters)
6203 printReporters(getListeners(),
"listeners");
6204 printReporters(getReporters(),
"reporters");
6211 void report_query(
const QueryData& in)
override {
6214 }
else if(opt.help) {
6216 }
else if(opt.list_reporters) {
6217 printRegisteredReporters();
6218 }
else if(opt.count || opt.list_test_cases) {
6219 if(opt.list_test_cases) {
6220 s << Color::Cyan <<
"[doctest] " << Color::None
6221 <<
"listing all test case names\n";
6222 separator_to_stream();
6225 for(
unsigned i = 0; i < in.num_data; ++i)
6226 s << Color::None << in.data[i]->m_name <<
"\n";
6228 separator_to_stream();
6230 s << Color::Cyan <<
"[doctest] " << Color::None
6231 <<
"unskipped test cases passing the current filters: "
6232 << g_cs->numTestCasesPassingFilters <<
"\n";
6234 }
else if(opt.list_test_suites) {
6235 s << Color::Cyan <<
"[doctest] " << Color::None <<
"listing all test suites\n";
6236 separator_to_stream();
6238 for(
unsigned i = 0; i < in.num_data; ++i)
6239 s << Color::None << in.data[i]->m_test_suite <<
"\n";
6241 separator_to_stream();
6243 s << Color::Cyan <<
"[doctest] " << Color::None
6244 <<
"unskipped test cases passing the current filters: "
6245 << g_cs->numTestCasesPassingFilters <<
"\n";
6246 s << Color::Cyan <<
"[doctest] " << Color::None
6247 <<
"test suites with unskipped test cases passing the current filters: "
6248 << g_cs->numTestSuitesPassingFilters <<
"\n";
6252 void test_run_start()
override {
6257 void test_run_end(
const TestRunStats& p)
override {
6258 if(opt.minimal && p.numTestCasesFailed == 0)
6261 separator_to_stream();
6264 auto totwidth =
int(
std::ceil(log10(
static_cast<double>(
std::max(p.numTestCasesPassingFilters,
static_cast<unsigned>(p.numAsserts))) + 1)));
6265 auto passwidth =
int(
std::ceil(log10(
static_cast<double>(
std::max(p.numTestCasesPassingFilters - p.numTestCasesFailed,
static_cast<unsigned>(p.numAsserts - p.numAssertsFailed))) + 1)));
6266 auto failwidth =
int(
std::ceil(log10(
static_cast<double>(
std::max(p.numTestCasesFailed,
static_cast<unsigned>(p.numAssertsFailed))) + 1)));
6267 const bool anythingFailed = p.numTestCasesFailed > 0 || p.numAssertsFailed > 0;
6268 s << Color::Cyan <<
"[doctest] " << Color::None <<
"test cases: " <<
std::setw(totwidth)
6269 << p.numTestCasesPassingFilters <<
" | "
6270 << ((p.numTestCasesPassingFilters == 0 || anythingFailed) ? Color::None :
6272 <<
std::
setw(passwidth) << p.numTestCasesPassingFilters - p.numTestCasesFailed <<
" passed"
6273 << Color::
None <<
" | " << (p.numTestCasesFailed > 0 ? Color::
Red : Color::
None)
6274 <<
std::
setw(failwidth) << p.numTestCasesFailed <<
" failed" << Color::
None <<
" |";
6275 if(opt.no_skipped_summary ==
false) {
6276 const int numSkipped = p.numTestCases - p.numTestCasesPassingFilters;
6277 s <<
" " << (numSkipped == 0 ? Color::None : Color::Yellow) << numSkipped
6278 <<
" skipped" << Color::None;
6281 s << Color::Cyan <<
"[doctest] " << Color::None <<
"assertions: " <<
std::setw(totwidth)
6282 << p.numAsserts <<
" | "
6283 << ((p.numAsserts == 0 || anythingFailed) ? Color::None : Color::
Green)
6284 <<
std::
setw(passwidth) << (p.numAsserts - p.numAssertsFailed) <<
" passed" << Color::
None
6285 <<
" | " << (p.numAssertsFailed > 0 ? Color::
Red : Color::
None) <<
std::
setw(failwidth)
6286 << p.numAssertsFailed <<
" failed" << Color::
None <<
" |\n";
6287 s << Color::Cyan <<
"[doctest] " << Color::None
6288 <<
"Status: " << (p.numTestCasesFailed > 0 ? Color::Red : Color::Green)
6289 << ((p.numTestCasesFailed > 0) ?
"FAILURE!" :
"SUCCESS!") << Color::None <<
std::endl;
6292 void test_case_start(
const TestCaseData& in)
override {
6293 hasLoggedCurrentTestStart =
false;
6295 subcasesStack.
clear();
6296 currentSubcaseLevel = 0;
6299 void test_case_reenter(
const TestCaseData&)
override {
6300 subcasesStack.
clear();
6303 void test_case_end(
const CurrentTestCaseStats& st)
override {
6310 (st.failure_flags && st.failure_flags !=
static_cast<int>(TestCaseFailureReason::AssertFailure)))
6315 <<
" s: " << tc->m_name <<
"\n";
6317 if(st.failure_flags & TestCaseFailureReason::Timeout)
6321 if(st.failure_flags & TestCaseFailureReason::ShouldHaveFailedButDidnt) {
6322 s << Color::Red <<
"Should have failed but didn't! Marking it as failed!\n";
6323 }
else if(st.failure_flags & TestCaseFailureReason::ShouldHaveFailedAndDid) {
6324 s << Color::Yellow <<
"Failed as expected so marking it as not failed\n";
6325 }
else if(st.failure_flags & TestCaseFailureReason::CouldHaveFailedAndDid) {
6326 s << Color::Yellow <<
"Allowed to fail so marking it as not failed\n";
6327 }
else if(st.failure_flags & TestCaseFailureReason::DidntFailExactlyNumTimes) {
6328 s << Color::Red <<
"Didn't fail exactly " << tc->m_expected_failures
6329 <<
" times so marking it as failed!\n";
6330 }
else if(st.failure_flags & TestCaseFailureReason::FailedExactlyNumTimes) {
6331 s << Color::Yellow <<
"Failed exactly " << tc->m_expected_failures
6332 <<
" times as expected so marking it as not failed!\n";
6334 if(st.failure_flags & TestCaseFailureReason::TooManyFailedAsserts) {
6335 s << Color::Red <<
"Aborting - too many failed asserts!\n";
6340 void test_case_exception(
const TestCaseException& e)
override {
6341 DOCTEST_LOCK_MUTEX(
mutex)
6347 file_line_to_stream(tc->m_file.c_str(), tc->m_line,
" ");
6348 successOrFailColoredStringToStream(
false, e.is_crash ? assertType::is_require :
6350 s << Color::Red << (e.is_crash ?
"test case CRASHED: " :
"test case THREW exception: ")
6351 << Color::Cyan << e.error_string <<
"\n";
6353 int num_stringified_contexts = get_num_stringified_contexts();
6354 if(num_stringified_contexts) {
6355 auto stringified_contexts = get_stringified_contexts();
6356 s << Color::None <<
" logged: ";
6357 for(
int i = num_stringified_contexts; i > 0; --i) {
6358 s << (i == num_stringified_contexts ?
"" :
" ")
6359 << stringified_contexts[i - 1] <<
"\n";
6362 s <<
"\n" << Color::None;
6365 void subcase_start(
const SubcaseSignature& subc)
override {
6367 ++currentSubcaseLevel;
6368 hasLoggedCurrentTestStart =
false;
6371 void subcase_end()
override {
6372 --currentSubcaseLevel;
6373 hasLoggedCurrentTestStart =
false;
6376 void log_assert(
const AssertData& rb)
override {
6377 if((!rb.m_failed && !opt.success) || tc->m_no_output)
6380 DOCTEST_LOCK_MUTEX(
mutex)
6384 file_line_to_stream(rb.m_file, rb.m_line,
" ");
6385 successOrFailColoredStringToStream(!rb.m_failed, rb.m_at);
6387 fulltext_log_assert_to_stream(s, rb);
6392 void log_message(
const MessageData& mb)
override {
6396 DOCTEST_LOCK_MUTEX(
mutex)
6400 file_line_to_stream(mb.m_file, mb.m_line,
" ");
6401 s << getSuccessOrFailColor(
false, mb.m_severity)
6402 << getSuccessOrFailString(mb.m_severity & assertType::is_warn, mb.m_severity,
6404 s << Color::None << mb.m_string <<
"\n";
6408 void test_case_skipped(
const TestCaseData&)
override {}
6413#ifdef DOCTEST_PLATFORM_WINDOWS
6414 struct DebugOutputWindowReporter :
public ConsoleReporter
6418 DebugOutputWindowReporter(
const ContextOptions& co)
6419 : ConsoleReporter(co, oss) {}
6421#define DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(func, type, arg) \
6422 void func(type arg) override { \
6423 bool with_col = g_no_colors; \
6424 g_no_colors = false; \
6425 ConsoleReporter::func(arg); \
6426 if(oss.tellp() != std::streampos{}) { \
6427 DOCTEST_OUTPUT_DEBUG_STRING(oss.str().c_str()); \
6430 g_no_colors = with_col; \
6434 DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_run_end,
const TestRunStats&, in)
6435 DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_case_start,
const TestCaseData&, in)
6436 DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_case_reenter,
const TestCaseData&, in)
6437 DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_case_end,
const CurrentTestCaseStats&, in)
6438 DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_case_exception,
const TestCaseException&, in)
6439 DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(subcase_start,
const SubcaseSignature&, in)
6441 DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(log_assert,
const AssertData&, in)
6442 DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(log_message,
const MessageData&, in)
6443 DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_case_skipped,
const TestCaseData&, in)
6450 bool parseOptionImpl(
int argc,
const char*
const* argv,
const char* pattern, String* value) {
6452 for(
int i = argc; i > 0; --i) {
6455 if(temp && (value ||
strlen(temp) ==
strlen(pattern))) {
6457 bool noBadCharsFound =
true;
6458 auto curr =
argv[index];
6459 while(curr != temp) {
6460 if(*curr++ !=
'-') {
6461 noBadCharsFound =
false;
6465 if(noBadCharsFound && argv[index][0] ==
'-') {
6469 const unsigned len =
strlen(temp);
6485 bool parseOption(
int argc,
const char*
const* argv,
const char* pattern, String* value =
nullptr,
6486 const String& defaultVal = String()) {
6488 *
value = defaultVal;
6489#ifndef DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS
6491 if(parseOptionImpl(argc, argv, pattern +
strlen(DOCTEST_CONFIG_OPTIONS_PREFIX), value))
6494 return parseOptionImpl(argc, argv, pattern, value);
6498 bool parseFlag(
int argc,
const char*
const* argv,
const char* pattern) {
6499 return parseOption(argc, argv, pattern);
6503 bool parseCommaSepArgs(
int argc,
const char*
const* argv,
const char* pattern,
6505 String filtersString;
6506 if(parseOption(argc, argv, pattern, &filtersString)) {
6509 auto flush = [&s, &res]() {
6510 auto string = s.str();
6511 if(
string.size() > 0) {
6517 bool seenBackslash =
false;
6518 const char* current = filtersString.c_str();
6519 const char*
end = current +
strlen(current);
6520 while(current !=
end) {
6521 char character = *current++;
6523 seenBackslash =
false;
6524 if(character ==
',' || character ==
'\\') {
6530 if(character ==
'\\') {
6531 seenBackslash =
true;
6532 }
else if(character ==
',') {
6555 bool parseIntOption(
int argc,
const char*
const* argv,
const char* pattern, optionType type,
6558 if(!parseOption(argc, argv, pattern, &parsedValue))
6564 int theInt =
std::atoi(parsedValue.c_str());
6571 const char positive[][5] = {
"1",
"true",
"on",
"yes" };
6572 const char negative[][6] = {
"0",
"false",
"off",
"no" };
6575 for (
unsigned i = 0; i < 4; i++) {
6576 if (parsedValue.compare(positive[i],
true) == 0) {
6580 if (parsedValue.compare(negative[i],
true) == 0) {
6590Context::Context(
int argc,
const char*
const* argv)
6591 : p(new detail::ContextState) {
6592 parseArgs(argc, argv,
true);
6594 p->binary_name =
argv[0];
6597Context::~Context() {
6603void Context::applyCommandLine(
int argc,
const char*
const* argv) {
6604 parseArgs(argc, argv);
6606 p->binary_name =
argv[0];
6610void Context::parseArgs(
int argc,
const char*
const* argv,
bool withDefaults) {
6611 using namespace detail;
6614 parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"source-file=", p->filters[0]);
6615 parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"sf=", p->filters[0]);
6616 parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"source-file-exclude=",p->filters[1]);
6617 parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"sfe=", p->filters[1]);
6618 parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"test-suite=", p->filters[2]);
6619 parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"ts=", p->filters[2]);
6620 parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"test-suite-exclude=", p->filters[3]);
6621 parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"tse=", p->filters[3]);
6622 parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"test-case=", p->filters[4]);
6623 parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"tc=", p->filters[4]);
6624 parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"test-case-exclude=", p->filters[5]);
6625 parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"tce=", p->filters[5]);
6626 parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"subcase=", p->filters[6]);
6627 parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"sc=", p->filters[6]);
6628 parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"subcase-exclude=", p->filters[7]);
6629 parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"sce=", p->filters[7]);
6630 parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"reporters=", p->filters[8]);
6631 parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"r=", p->filters[8]);
6637#define DOCTEST_PARSE_AS_BOOL_OR_FLAG(name, sname, var, default) \
6638 if(parseIntOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX name "=", option_bool, intRes) || \
6639 parseIntOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX sname "=", option_bool, intRes)) \
6640 p->var = static_cast<bool>(intRes); \
6641 else if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX name) || \
6642 parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX sname)) \
6644 else if(withDefaults) \
6647#define DOCTEST_PARSE_INT_OPTION(name, sname, var, default) \
6648 if(parseIntOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX name "=", option_int, intRes) || \
6649 parseIntOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX sname "=", option_int, intRes)) \
6651 else if(withDefaults) \
6654#define DOCTEST_PARSE_STR_OPTION(name, sname, var, default) \
6655 if(parseOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX name "=", &strRes, default) || \
6656 parseOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX sname "=", &strRes, default) || \
6661 DOCTEST_PARSE_STR_OPTION(
"out",
"o", out,
"");
6662 DOCTEST_PARSE_STR_OPTION(
"order-by",
"ob", order_by,
"file");
6663 DOCTEST_PARSE_INT_OPTION(
"rand-seed",
"rs", rand_seed, 0);
6665 DOCTEST_PARSE_INT_OPTION(
"first",
"f", first, 0);
6666 DOCTEST_PARSE_INT_OPTION(
"last",
"l", last, UINT_MAX);
6668 DOCTEST_PARSE_INT_OPTION(
"abort-after",
"aa", abort_after, 0);
6669 DOCTEST_PARSE_INT_OPTION(
"subcase-filter-levels",
"scfl", subcase_filter_levels, INT_MAX);
6671 DOCTEST_PARSE_AS_BOOL_OR_FLAG(
"success",
"s", success,
false);
6672 DOCTEST_PARSE_AS_BOOL_OR_FLAG(
"case-sensitive",
"cs", case_sensitive,
false);
6673 DOCTEST_PARSE_AS_BOOL_OR_FLAG(
"exit",
"e", exit,
false);
6674 DOCTEST_PARSE_AS_BOOL_OR_FLAG(
"duration",
"d", duration,
false);
6675 DOCTEST_PARSE_AS_BOOL_OR_FLAG(
"minimal",
"m",
minimal,
false);
6676 DOCTEST_PARSE_AS_BOOL_OR_FLAG(
"quiet",
"q", quiet,
false);
6677 DOCTEST_PARSE_AS_BOOL_OR_FLAG(
"no-throw",
"nt", no_throw,
false);
6678 DOCTEST_PARSE_AS_BOOL_OR_FLAG(
"no-exitcode",
"ne", no_exitcode,
false);
6679 DOCTEST_PARSE_AS_BOOL_OR_FLAG(
"no-run",
"nr", no_run,
false);
6680 DOCTEST_PARSE_AS_BOOL_OR_FLAG(
"no-intro",
"ni", no_intro,
false);
6681 DOCTEST_PARSE_AS_BOOL_OR_FLAG(
"no-version",
"nv", no_version,
false);
6682 DOCTEST_PARSE_AS_BOOL_OR_FLAG(
"no-colors",
"nc", no_colors,
false);
6683 DOCTEST_PARSE_AS_BOOL_OR_FLAG(
"force-colors",
"fc", force_colors,
false);
6684 DOCTEST_PARSE_AS_BOOL_OR_FLAG(
"no-breaks",
"nb", no_breaks,
false);
6685 DOCTEST_PARSE_AS_BOOL_OR_FLAG(
"no-skip",
"ns", no_skip,
false);
6686 DOCTEST_PARSE_AS_BOOL_OR_FLAG(
"gnu-file-line",
"gfl", gnu_file_line, !
bool(
DOCTEST_MSVC));
6687 DOCTEST_PARSE_AS_BOOL_OR_FLAG(
"no-path-filenames",
"npf", no_path_in_filenames,
false);
6688 DOCTEST_PARSE_AS_BOOL_OR_FLAG(
"no-line-numbers",
"nln", no_line_numbers,
false);
6689 DOCTEST_PARSE_AS_BOOL_OR_FLAG(
"no-debug-output",
"ndo", no_debug_output,
false);
6690 DOCTEST_PARSE_AS_BOOL_OR_FLAG(
"no-skipped-summary",
"nss", no_skipped_summary,
false);
6691 DOCTEST_PARSE_AS_BOOL_OR_FLAG(
"no-time-in-output",
"ntio", no_time_in_output,
false);
6698 p->list_test_cases =
false;
6699 p->list_test_suites =
false;
6700 p->list_reporters =
false;
6702 if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"help") ||
6703 parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"h") ||
6704 parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"?")) {
6708 if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"version") ||
6709 parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"v")) {
6713 if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"count") ||
6714 parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"c")) {
6718 if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"list-test-cases") ||
6719 parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"ltc")) {
6720 p->list_test_cases =
true;
6723 if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"list-test-suites") ||
6724 parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"lts")) {
6725 p->list_test_suites =
true;
6728 if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"list-reporters") ||
6729 parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX
"lr")) {
6730 p->list_reporters =
true;
6736void Context::addFilter(
const char* filter,
const char* value) { setOption(filter, value); }
6739void Context::clearFilters() {
6740 for(
auto& curr : p->filters)
6745void Context::setOption(
const char* option,
bool value) {
6746 setOption(option, value ?
"true" :
"false");
6750void Context::setOption(
const char* option,
int value) {
6751 setOption(option,
toString(value).c_str());
6755void Context::setOption(
const char* option,
const char* value) {
6756 auto argv = String(
"-") + option +
"=" +
value;
6757 auto lvalue =
argv.c_str();
6758 parseArgs(1, &lvalue);
6762bool Context::shouldExit() {
return p->exit; }
6764void Context::setAsDefaultForAssertsOutOfTestCases() { g_cs = p; }
6766void Context::setAssertHandler(detail::assert_handler ah) { p->ah = ah; }
6768void Context::setCout(
std::ostream* out) { p->cout = out; }
6782 int_type overflow(int_type ch)
override {
6784 return traits_type::not_eof(ch);
6795 using namespace detail;
6803 g_no_colors = p->no_colors;
6807 if(p->cout ==
nullptr) {
6809 p->cout = &discardOut;
6810 }
else if(p->out.size()) {
6812 fstr.
open(p->out.c_str(), std::fstream::out);
6815#ifndef DOCTEST_CONFIG_NO_INCLUDE_IOSTREAM
6819 return EXIT_FAILURE;
6824 FatalConditionHandler::allocateAltStackMem();
6826 auto cleanup_and_return = [&]() {
6827 FatalConditionHandler::freeAltStackMem();
6837 for(
auto& curr : p->reporters_currently_used)
6839 p->reporters_currently_used.clear();
6841 if(p->numTestCasesFailed && !p->no_exitcode)
6842 return EXIT_FAILURE;
6843 return EXIT_SUCCESS;
6847 if(p->filters[8].empty())
6848 p->filters[8].push_back(
"console");
6851 for(
auto& curr : getReporters()) {
6852 if(matchesAny(curr.first.second.c_str(), p->filters[8],
false, p->case_sensitive))
6853 p->reporters_currently_used.push_back(curr.second(*g_cs));
6859 for(
auto& curr : getListeners())
6860 p->reporters_currently_used.insert(p->reporters_currently_used.
begin(), curr.
second(*g_cs));
6862#ifdef DOCTEST_PLATFORM_WINDOWS
6864 p->reporters_currently_used.push_back(
new DebugOutputWindowReporter(*g_cs));
6868 if(p->no_run || p->version || p->help || p->list_reporters) {
6869 DOCTEST_ITERATE_THROUGH_REPORTERS(report_query, QueryData());
6871 return cleanup_and_return();
6875 for(
auto& curr : getRegisteredTests())
6876 testArray.push_back(&curr);
6877 p->numTestCases = testArray.
size();
6880 if(!testArray.
empty()) {
6881 if(p->order_by.compare(
"file",
true) == 0) {
6883 }
else if(p->order_by.compare(
"suite",
true) == 0) {
6885 }
else if(p->order_by.compare(
"name",
true) == 0) {
6887 }
else if(p->order_by.compare(
"rand",
true) == 0) {
6891 const auto first = &testArray[0];
6892 for(
size_t i = testArray.
size() - 1; i > 0; --i) {
6895 const auto temp =
first[i];
6898 first[idxToSwap] = temp;
6900 }
else if(p->order_by.compare(
"none",
true) == 0) {
6908 bool query_mode = p->
count || p->list_test_cases || p->list_test_suites;
6912 DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_start,
DOCTEST_EMPTY);
6915 for(
auto& curr : testArray) {
6916 const auto& tc = *curr;
6918 bool skip_me =
false;
6919 if(tc.m_skip && !p->no_skip)
6922 if(!matchesAny(tc.m_file.c_str(), p->filters[0],
true, p->case_sensitive))
6924 if(matchesAny(tc.m_file.c_str(), p->filters[1],
false, p->case_sensitive))
6926 if(!matchesAny(tc.m_test_suite, p->filters[2],
true, p->case_sensitive))
6928 if(matchesAny(tc.m_test_suite, p->filters[3],
false, p->case_sensitive))
6930 if(!matchesAny(tc.m_name, p->filters[4],
true, p->case_sensitive))
6932 if(matchesAny(tc.m_name, p->filters[5],
false, p->case_sensitive))
6936 p->numTestCasesPassingFilters++;
6939 if((p->last < p->numTestCasesPassingFilters && p->first <= p->last) ||
6940 (p->first > p->numTestCasesPassingFilters))
6945 DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_skipped, tc);
6954 if(p->list_test_cases) {
6960 if(p->list_test_suites) {
6961 if((testSuitesPassingFilt.
count(tc.m_test_suite) == 0) && tc.m_test_suite[0] !=
'\0') {
6963 testSuitesPassingFilt.
insert(tc.m_test_suite);
6964 p->numTestSuitesPassingFilters++;
6971 p->currentTest = &tc;
6973 p->failure_flags = TestCaseFailureReason::None;
6977 p->numAssertsFailedCurrentTest_atomic = 0;
6978 p->numAssertsCurrentTest_atomic = 0;
6980 p->fullyTraversedSubcases.clear();
6982 DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_start, tc);
6986 bool run_test =
true;
6990 p->reachedLeaf =
false;
6992 p->subcaseStack.clear();
6993 p->currentSubcaseDepth = 0;
6995 p->shouldLogCurrentException =
true;
6998 p->stringifiedContexts.clear();
7000#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
7005 FatalConditionHandler fatalConditionHandler;
7008 fatalConditionHandler.reset();
7010#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
7011 }
catch(
const TestFailureException&) {
7012 p->failure_flags |= TestCaseFailureReason::AssertFailure;
7014 DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_exception,
7015 {translateActiveException(),
false});
7016 p->failure_flags |= TestCaseFailureReason::Exception;
7021 if(p->abort_after > 0 &&
7022 p->numAssertsFailed + p->numAssertsFailedCurrentTest_atomic >= p->abort_after) {
7024 p->failure_flags |= TestCaseFailureReason::TooManyFailedAsserts;
7027 if(!p->nextSubcaseStack.empty() && run_test)
7028 DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_reenter, tc);
7029 if(p->nextSubcaseStack.empty())
7033 p->finalizeTestCaseData();
7035 DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_end, *g_cs);
7037 p->currentTest =
nullptr;
7040 if(p->abort_after > 0 && p->numAssertsFailed >= p->abort_after)
7046 DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_end, *g_cs);
7049 qdata.run_stats = g_cs;
7050 qdata.data = queryResults.
data();
7051 qdata.num_data = unsigned(queryResults.
size());
7052 DOCTEST_ITERATE_THROUGH_REPORTERS(report_query, qdata);
7055 return cleanup_and_return();
7060int IReporter::get_num_active_contexts() {
return detail::g_infoContexts.size(); }
7061const IContextScope*
const* IReporter::get_active_contexts() {
7062 return get_num_active_contexts() ? &detail::g_infoContexts[0] :
nullptr;
7065int IReporter::get_num_stringified_contexts() {
return detail::g_cs->stringifiedContexts.size(); }
7066const String* IReporter::get_stringified_contexts() {
7067 return get_num_stringified_contexts() ? &detail::g_cs->stringifiedContexts[0] :
nullptr;
7071 void registerReporterImpl(
const char* name,
int priority, reporterCreatorFunc c,
bool isReporter) {
7073 getReporters().insert(reporterMap::value_type(reporterMap::key_type(priority, name), c));
7075 getListeners().insert(reporterMap::value_type(reporterMap::key_type(priority, name), c));
7083#ifdef DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
7098#ifdef DOCTEST_UNDEF_WIN32_LEAN_AND_MEAN
7099#undef WIN32_LEAN_AND_MEAN
7100#undef DOCTEST_UNDEF_WIN32_LEAN_AND_MEAN
7103#ifdef DOCTEST_UNDEF_NOMINMAX
7105#undef DOCTEST_UNDEF_NOMINMAX
table::Key< std::string > name
const char * c_str() const
StringContains(const String &str)
StringContains(Contains cntn)
bool check(const String &str)
bool checkWith(const String &other) const
Contains(const String &string)
Context(const Context &)=delete
Context(Context &&)=delete
Context & operator=(Context &&)=delete
void setOption(const char *option, const char *value)
void setCout(std::ostream *out)
void addFilter(const char *filter, const char *value)
void setAssertHandler(detail::assert_handler ah)
void setOption(const char *option, bool value)
Context(int argc=0, const char *const *argv=nullptr)
void setOption(const char *option, int value)
Context & operator=(const Context &)=delete
void applyCommandLine(int argc, const char *const *argv)
void setAsDefaultForAssertsOutOfTestCases()
size_type capacity() const
friend std::ostream & operator<<(std::ostream &s, const String &in)
const char * c_str() const
size_type rfind(char ch, size_type pos=npos) const
String substr(size_type pos, size_type cnt=npos) &&
size_type find(char ch, size_type pos=0) const
String substr(size_type pos, size_type cnt=npos) const &
int compare(const String &other, bool no_case=false) const
int compare(const char *other, bool no_case=false) const
ContextScope(const L &lambda)
ContextScope(const ContextScope &)=delete
ContextScope(ContextScope &&) noexcept=default
OCLINT destructor of virtual class.
ExceptionTranslator(String(*translateFunction)(T))
bool translate(String &res) const override
#define DOCTEST_FORBIT_EXPRESSION(rt, op)
#define DOCTEST_COMPILER(MAJOR, MINOR, PATCH)
#define DOCTEST_STRINGIFY(...)
#define DOCTEST_BREAK_INTO_DEBUGGER()
#define DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(w)
#define DOCTEST_SUPPRESS_COMMON_WARNINGS_POP
#define DOCTEST_VERSION_STR
#define DOCTEST_RELATIONAL_OP(name, op)
#define DOCTEST_CMP_LE(l, r)
#define DOCTEST_GCC_SUPPRESS_WARNING(w)
#define DOCTEST_INTERFACE_DECL
#define DOCTEST_CMP_NE(l, r)
#define DOCTEST_DEFINE_INTERFACE(name)
#define DOCTEST_MSVC_SUPPRESS_WARNING_POP
#define DOCTEST_CLANG_SUPPRESS_WARNING_POP
#define DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
#define DOCTEST_GCC_SUPPRESS_WARNING_POP
#define DOCTEST_CMP_GT(l, r)
#define DOCTEST_BINARY_RELATIONAL_OP(n, op)
#define DOCTEST_DEFINE_DECORATOR(name, type, def)
#define DOCTEST_GCC_SUPPRESS_WARNING_PUSH
#define DOCTEST_CMP_GE(l, r)
#define DOCTEST_ASSERT_IN_TESTS(decomp)
#define DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(op, op_str, op_macro)
#define DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH(w)
#define DOCTEST_REGISTER_REPORTER(name, priority, reporter)
#define DOCTEST_INTERFACE
#define DOCTEST_CONFIG_STRING_SIZE_TYPE
#define DOCTEST_DECLARE_INTERFACE(name)
#define DOCTEST_SUPPRESS_COMMON_WARNINGS_PUSH
#define DOCTEST_TEST_SUITE_END
#define DOCTEST_ASSERT_OUT_OF_TESTS(decomp)
#define DOCTEST_CONSTEXPR
#define DOCTEST_NO_SANITIZE_INTEGER
#define DOCTEST_CLANG_SUPPRESS_WARNING(w)
#define DOCTEST_MSVC_SUPPRESS_WARNING(w)
#define DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END
#define DOCTEST_CMP_LT(l, r)
#define DOCTEST_INTERFACE_DEF
#define DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN
#define DOCTEST_MSVC_SUPPRESS_WARNING_PUSH
#define DOCTEST_CONSTEXPR_FUNC
#define DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH(w)
#define DOCTEST_REF_WRAP(x)
#define DOCTEST_CMP_EQ(l, r)
T get_terminate(T... args)
std::ostream & operator<<(std::ostream &s, Color::Enum code)
@ ShouldHaveFailedButDidnt
@ DidntFailExactlyNumTimes
@ DT_CHECK_THROWS_WITH_AS
@ DT_REQUIRE_THROWS_WITH_AS
void filloss(std::ostream *stream, const T &in)
void registerReporterImpl(const char *name, int prio, reporterCreatorFunc c, bool isReporter)
bool checkIfShouldThrow(assertType::Enum at)
int setTestSuite(const TestSuite &ts)
IReporter *(*)(const ContextOptions &) reporterCreatorFunc
void failed_out_of_a_testing_context(const AssertData &ad)
void registerExceptionTranslatorImpl(const IExceptionTranslator *et)
int regTest(const TestCase &tc)
void(*)(const AssertData &) assert_handler
String stringifyBinaryExpr(const L &lhs, const char *op, const R &rhs)
String toStream(const T &in)
int instantiationHelper(const T &)
IReporter * reporterCreator(const ContextOptions &o)
bool decomp_assert(assertType::Enum at, const char *file, int line, const char *expr, const Result &result)
ContextScope< L > MakeContextScope(const L &lambda)
std::ostream * tlssPush()
bool eq(const L &lhs, const R &rhs)
doctest::detail::TestSuite & getCurrentTestSuite()
bool operator<(const String &lhs, const String &rhs)
bool operator>(const String &lhs, const String &rhs)
String toString(const Contains &in)
const char * assertString(assertType::Enum at)
const char * failureString(assertType::Enum at)
String operator+(const String &lhs, const String &rhs)
bool operator==(const String &lhs, const String &rhs)
int registerExceptionTranslator(String(*translateFunction)(T))
int registerReporter(const char *name, int priority, bool isReporter)
const ContextOptions * getContextOptions()
bool operator>=(const String &lhs, const String &rhs)
bool operator!=(const String &lhs, const String &rhs)
bool operator<=(const String &lhs, const String &rhs)
const char * skipPathFromFilename(const char *file)
line(points, frame=None, origin=afwImage.PARENT, symbs=False, ctype=None, size=0.5)
T set_terminate(T... args)
T setprecision(T... args)
Approx & scale(double newScale)
friend bool operator==(double lhs, const Approx &rhs)
Approx & epsilon(double newEpsilon)
friend bool operator!=(double lhs, const Approx &rhs)
friend bool operator!=(const Approx &lhs, double rhs)
friend bool operator<=(const Approx &lhs, double rhs)
Approx operator()(double value) const
friend bool operator<=(double lhs, const Approx &rhs)
friend bool operator==(const Approx &lhs, double rhs)
friend bool operator>=(const Approx &lhs, double rhs)
friend bool operator>=(double lhs, const Approx &rhs)
const char * m_exception_type
const TestCaseData * m_test_case
AssertData(assertType::Enum at, const char *file, int line, const char *expr, const char *exception_type, const StringContains &exception_string)
bool no_path_in_filenames
int subcase_filter_levels
int numAssertsFailedCurrentTest
int numAssertsCurrentTest
virtual void subcase_start(const SubcaseSignature &)=0
virtual void subcase_end()=0
virtual void log_message(const MessageData &)=0
virtual void test_case_exception(const TestCaseException &)=0
virtual void test_case_end(const CurrentTestCaseStats &)=0
virtual void test_case_reenter(const TestCaseData &)=0
virtual void log_assert(const AssertData &)=0
virtual void test_run_end(const TestRunStats &)=0
virtual void test_run_start()=0
virtual void test_case_skipped(const TestCaseData &)=0
virtual void report_query(const QueryData &)=0
virtual void test_case_start(const TestCaseData &)=0
IsNaN(F f, bool flip=false)
IsNaN< F > operator!() const
assertType::Enum m_severity
bool operator<(const SubcaseSignature &other) const
bool operator==(const SubcaseSignature &other) const
const char * m_description
const char * m_test_suite
unsigned numTestCasesFailed
unsigned numTestSuitesPassingFilters
unsigned numTestCasesPassingFilters
ContextScopeBase(ContextScopeBase &&other) noexcept
~ContextScopeBase() override=default
ContextScopeBase(const ContextScopeBase &)=delete
ContextScopeBase & operator=(const ContextScopeBase &)=delete
ContextScopeBase & operator=(ContextScopeBase &&)=delete
Expression_lhs(L &&in, assertType::Enum at)
ExpressionDecomposer(assertType::Enum at)
MessageBuilder & operator<<(const T &in)
MessageBuilder(MessageBuilder &&)=delete
MessageBuilder & operator=(MessageBuilder &&)=delete
MessageBuilder(const char *file, int line, assertType::Enum severity)
MessageBuilder & operator*(const T &in)
MessageBuilder(const MessageBuilder &)=delete
MessageBuilder & operator=(const MessageBuilder &)=delete
bool operator()(const L &, const R &) const
ResultBuilder(assertType::Enum at, const char *file, int line, const char *expr, const char *exception_type="", const String &exception_string="")
void translateException()
void setResult(const Result &res)
ResultBuilder(assertType::Enum at, const char *file, int line, const char *expr, const char *exception_type, const Contains &exception_string)
Result(bool passed, const String &decomposition=String())
static String convert(const T &in)
static String convert(const T &)
Subcase & operator=(const Subcase &)=delete
SubcaseSignature m_signature
Subcase(const String &name, const char *file, int line)
Subcase(const Subcase &)=delete
Subcase(Subcase &&)=delete
Subcase & operator=(Subcase &&)=delete
TestCase(funcType test, const char *file, unsigned line, const TestSuite &test_suite, const String &type=String(), int template_id=-1)
TestCase(const TestCase &other)
TestCase(TestCase &&)=delete
bool operator<(const TestCase &other) const
TestSuite & operator*(const T &in)
TestSuite & operator*(const char *in)
static void fill(std::ostream *stream, const T(&in)[N])
static void fill(std::ostream *stream, const char(&in)[N])
static void fill(std::ostream *stream, const void *in)
static void fill(std::ostream *stream, const T &in)
__underlying_type(T) type
py::scoped_interpreter guard
T uncaught_exception(T... args)