You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

doctest_fwd.h 132KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706
  1. //
  2. // doctest.h - the lightest feature-rich C++ single-header testing framework for unit tests and TDD
  3. //
  4. // Copyright (c) 2016-2021 Viktor Kirilov
  5. //
  6. // Distributed under the MIT Software License
  7. // See accompanying file LICENSE.txt or copy at
  8. // https://opensource.org/licenses/MIT
  9. //
  10. // The documentation can be found at the library's page:
  11. // https://github.com/onqtam/doctest/blob/master/doc/markdown/readme.md
  12. //
  13. // =================================================================================================
  14. // =================================================================================================
  15. // =================================================================================================
  16. //
  17. // The library is heavily influenced by Catch - https://github.com/catchorg/Catch2
  18. // which uses the Boost Software License - Version 1.0
  19. // see here - https://github.com/catchorg/Catch2/blob/master/LICENSE.txt
  20. //
  21. // The concept of subcases (sections in Catch) and expression decomposition are from there.
  22. // Some parts of the code are taken directly:
  23. // - stringification - the detection of "ostream& operator<<(ostream&, const T&)" and StringMaker<>
  24. // - the Approx() helper class for floating point comparison
  25. // - colors in the console
  26. // - breaking into a debugger
  27. // - signal / SEH handling
  28. // - timer
  29. // - XmlWriter class - thanks to Phil Nash for allowing the direct reuse (AKA copy/paste)
  30. //
  31. // The expression decomposing templates are taken from lest - https://github.com/martinmoene/lest
  32. // which uses the Boost Software License - Version 1.0
  33. // see here - https://github.com/martinmoene/lest/blob/master/LICENSE.txt
  34. //
  35. // =================================================================================================
  36. // =================================================================================================
  37. // =================================================================================================
  38. #ifndef DOCTEST_LIBRARY_INCLUDED
  39. #define DOCTEST_LIBRARY_INCLUDED
  40. // =================================================================================================
  41. // == VERSION ======================================================================================
  42. // =================================================================================================
  43. #define DOCTEST_VERSION_MAJOR 2
  44. #define DOCTEST_VERSION_MINOR 4
  45. #define DOCTEST_VERSION_PATCH 6
  46. #define DOCTEST_VERSION_STR "2.4.6"
  47. #define DOCTEST_VERSION \
  48. (DOCTEST_VERSION_MAJOR * 10000 + DOCTEST_VERSION_MINOR * 100 + DOCTEST_VERSION_PATCH)
  49. // =================================================================================================
  50. // == COMPILER VERSION =============================================================================
  51. // =================================================================================================
  52. // ideas for the version stuff are taken from here: https://github.com/cxxstuff/cxx_detect
  53. #define DOCTEST_COMPILER(MAJOR, MINOR, PATCH) ((MAJOR)*10000000 + (MINOR)*100000 + (PATCH))
  54. // GCC/Clang and GCC/MSVC are mutually exclusive, but Clang/MSVC are not because of clang-cl...
  55. #if defined(_MSC_VER) && defined(_MSC_FULL_VER)
  56. #if _MSC_VER == _MSC_FULL_VER / 10000
  57. #define DOCTEST_MSVC DOCTEST_COMPILER(_MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 10000)
  58. #else // MSVC
  59. #define DOCTEST_MSVC \
  60. DOCTEST_COMPILER(_MSC_VER / 100, (_MSC_FULL_VER / 100000) % 100, _MSC_FULL_VER % 100000)
  61. #endif // MSVC
  62. #endif // MSVC
  63. #if defined(__clang__) && defined(__clang_minor__)
  64. #define DOCTEST_CLANG DOCTEST_COMPILER(__clang_major__, __clang_minor__, __clang_patchlevel__)
  65. #elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) && \
  66. !defined(__INTEL_COMPILER)
  67. #define DOCTEST_GCC DOCTEST_COMPILER(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
  68. #endif // GCC
  69. #ifndef DOCTEST_MSVC
  70. #define DOCTEST_MSVC 0
  71. #endif // DOCTEST_MSVC
  72. #ifndef DOCTEST_CLANG
  73. #define DOCTEST_CLANG 0
  74. #endif // DOCTEST_CLANG
  75. #ifndef DOCTEST_GCC
  76. #define DOCTEST_GCC 0
  77. #endif // DOCTEST_GCC
  78. // =================================================================================================
  79. // == COMPILER WARNINGS HELPERS ====================================================================
  80. // =================================================================================================
  81. #if DOCTEST_CLANG
  82. #define DOCTEST_PRAGMA_TO_STR(x) _Pragma(#x)
  83. #define DOCTEST_CLANG_SUPPRESS_WARNING_PUSH _Pragma("clang diagnostic push")
  84. #define DOCTEST_CLANG_SUPPRESS_WARNING(w) DOCTEST_PRAGMA_TO_STR(clang diagnostic ignored w)
  85. #define DOCTEST_CLANG_SUPPRESS_WARNING_POP _Pragma("clang diagnostic pop")
  86. #define DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH(w) \
  87. DOCTEST_CLANG_SUPPRESS_WARNING_PUSH DOCTEST_CLANG_SUPPRESS_WARNING(w)
  88. #else // DOCTEST_CLANG
  89. #define DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
  90. #define DOCTEST_CLANG_SUPPRESS_WARNING(w)
  91. #define DOCTEST_CLANG_SUPPRESS_WARNING_POP
  92. #define DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH(w)
  93. #endif // DOCTEST_CLANG
  94. #if DOCTEST_GCC
  95. #define DOCTEST_PRAGMA_TO_STR(x) _Pragma(#x)
  96. #define DOCTEST_GCC_SUPPRESS_WARNING_PUSH _Pragma("GCC diagnostic push")
  97. #define DOCTEST_GCC_SUPPRESS_WARNING(w) DOCTEST_PRAGMA_TO_STR(GCC diagnostic ignored w)
  98. #define DOCTEST_GCC_SUPPRESS_WARNING_POP _Pragma("GCC diagnostic pop")
  99. #define DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH(w) \
  100. DOCTEST_GCC_SUPPRESS_WARNING_PUSH DOCTEST_GCC_SUPPRESS_WARNING(w)
  101. #else // DOCTEST_GCC
  102. #define DOCTEST_GCC_SUPPRESS_WARNING_PUSH
  103. #define DOCTEST_GCC_SUPPRESS_WARNING(w)
  104. #define DOCTEST_GCC_SUPPRESS_WARNING_POP
  105. #define DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH(w)
  106. #endif // DOCTEST_GCC
  107. #if DOCTEST_MSVC
  108. #define DOCTEST_MSVC_SUPPRESS_WARNING_PUSH __pragma(warning(push))
  109. #define DOCTEST_MSVC_SUPPRESS_WARNING(w) __pragma(warning(disable : w))
  110. #define DOCTEST_MSVC_SUPPRESS_WARNING_POP __pragma(warning(pop))
  111. #define DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(w) \
  112. DOCTEST_MSVC_SUPPRESS_WARNING_PUSH DOCTEST_MSVC_SUPPRESS_WARNING(w)
  113. #else // DOCTEST_MSVC
  114. #define DOCTEST_MSVC_SUPPRESS_WARNING_PUSH
  115. #define DOCTEST_MSVC_SUPPRESS_WARNING(w)
  116. #define DOCTEST_MSVC_SUPPRESS_WARNING_POP
  117. #define DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(w)
  118. #endif // DOCTEST_MSVC
  119. // =================================================================================================
  120. // == COMPILER WARNINGS ============================================================================
  121. // =================================================================================================
  122. DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
  123. DOCTEST_CLANG_SUPPRESS_WARNING("-Wunknown-pragmas")
  124. DOCTEST_CLANG_SUPPRESS_WARNING("-Wnon-virtual-dtor")
  125. DOCTEST_CLANG_SUPPRESS_WARNING("-Wweak-vtables")
  126. DOCTEST_CLANG_SUPPRESS_WARNING("-Wpadded")
  127. DOCTEST_CLANG_SUPPRESS_WARNING("-Wdeprecated")
  128. DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes")
  129. DOCTEST_CLANG_SUPPRESS_WARNING("-Wunused-local-typedef")
  130. DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat")
  131. DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat-pedantic")
  132. DOCTEST_GCC_SUPPRESS_WARNING_PUSH
  133. DOCTEST_GCC_SUPPRESS_WARNING("-Wunknown-pragmas")
  134. DOCTEST_GCC_SUPPRESS_WARNING("-Wpragmas")
  135. DOCTEST_GCC_SUPPRESS_WARNING("-Weffc++")
  136. DOCTEST_GCC_SUPPRESS_WARNING("-Wstrict-overflow")
  137. DOCTEST_GCC_SUPPRESS_WARNING("-Wstrict-aliasing")
  138. DOCTEST_GCC_SUPPRESS_WARNING("-Wctor-dtor-privacy")
  139. DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations")
  140. DOCTEST_GCC_SUPPRESS_WARNING("-Wnon-virtual-dtor")
  141. DOCTEST_GCC_SUPPRESS_WARNING("-Wunused-local-typedefs")
  142. DOCTEST_GCC_SUPPRESS_WARNING("-Wuseless-cast")
  143. DOCTEST_GCC_SUPPRESS_WARNING("-Wnoexcept")
  144. DOCTEST_GCC_SUPPRESS_WARNING("-Wsign-promo")
  145. DOCTEST_MSVC_SUPPRESS_WARNING_PUSH
  146. DOCTEST_MSVC_SUPPRESS_WARNING(4616) // invalid compiler warning
  147. DOCTEST_MSVC_SUPPRESS_WARNING(4619) // invalid compiler warning
  148. DOCTEST_MSVC_SUPPRESS_WARNING(4996) // The compiler encountered a deprecated declaration
  149. DOCTEST_MSVC_SUPPRESS_WARNING(4706) // assignment within conditional expression
  150. DOCTEST_MSVC_SUPPRESS_WARNING(4512) // 'class' : assignment operator could not be generated
  151. DOCTEST_MSVC_SUPPRESS_WARNING(4127) // conditional expression is constant
  152. DOCTEST_MSVC_SUPPRESS_WARNING(4820) // padding
  153. DOCTEST_MSVC_SUPPRESS_WARNING(4625) // copy constructor was implicitly defined as deleted
  154. DOCTEST_MSVC_SUPPRESS_WARNING(4626) // assignment operator was implicitly defined as deleted
  155. DOCTEST_MSVC_SUPPRESS_WARNING(5027) // move assignment operator was implicitly defined as deleted
  156. DOCTEST_MSVC_SUPPRESS_WARNING(5026) // move constructor was implicitly defined as deleted
  157. DOCTEST_MSVC_SUPPRESS_WARNING(4623) // default constructor was implicitly defined as deleted
  158. DOCTEST_MSVC_SUPPRESS_WARNING(4640) // construction of local static object is not thread-safe
  159. // static analysis
  160. DOCTEST_MSVC_SUPPRESS_WARNING(26439) // This kind of function may not throw. Declare it 'noexcept'
  161. DOCTEST_MSVC_SUPPRESS_WARNING(26495) // Always initialize a member variable
  162. DOCTEST_MSVC_SUPPRESS_WARNING(26451) // Arithmetic overflow ...
  163. DOCTEST_MSVC_SUPPRESS_WARNING(26444) // Avoid unnamed objects with custom construction and dtr...
  164. DOCTEST_MSVC_SUPPRESS_WARNING(26812) // Prefer 'enum class' over 'enum'
  165. // 4548 - expression before comma has no effect; expected expression with side - effect
  166. // 4265 - class has virtual functions, but destructor is not virtual
  167. // 4986 - exception specification does not match previous declaration
  168. // 4350 - behavior change: 'member1' called instead of 'member2'
  169. // 4668 - 'x' is not defined as a preprocessor macro, replacing with '0' for '#if/#elif'
  170. // 4365 - conversion from 'int' to 'unsigned long', signed/unsigned mismatch
  171. // 4774 - format string expected in argument 'x' is not a string literal
  172. // 4820 - padding in structs
  173. // only 4 should be disabled globally:
  174. // - 4514 # unreferenced inline function has been removed
  175. // - 4571 # SEH related
  176. // - 4710 # function not inlined
  177. // - 4711 # function 'x' selected for automatic inline expansion
  178. #define DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN \
  179. DOCTEST_MSVC_SUPPRESS_WARNING_PUSH \
  180. DOCTEST_MSVC_SUPPRESS_WARNING(4548) \
  181. DOCTEST_MSVC_SUPPRESS_WARNING(4265) \
  182. DOCTEST_MSVC_SUPPRESS_WARNING(4986) \
  183. DOCTEST_MSVC_SUPPRESS_WARNING(4350) \
  184. DOCTEST_MSVC_SUPPRESS_WARNING(4668) \
  185. DOCTEST_MSVC_SUPPRESS_WARNING(4365) \
  186. DOCTEST_MSVC_SUPPRESS_WARNING(4774) \
  187. DOCTEST_MSVC_SUPPRESS_WARNING(4820) \
  188. DOCTEST_MSVC_SUPPRESS_WARNING(4625) \
  189. DOCTEST_MSVC_SUPPRESS_WARNING(4626) \
  190. DOCTEST_MSVC_SUPPRESS_WARNING(5027) \
  191. DOCTEST_MSVC_SUPPRESS_WARNING(5026) \
  192. DOCTEST_MSVC_SUPPRESS_WARNING(4623) \
  193. DOCTEST_MSVC_SUPPRESS_WARNING(5039) \
  194. DOCTEST_MSVC_SUPPRESS_WARNING(5045) \
  195. DOCTEST_MSVC_SUPPRESS_WARNING(5105)
  196. #define DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END DOCTEST_MSVC_SUPPRESS_WARNING_POP
  197. // =================================================================================================
  198. // == FEATURE DETECTION ============================================================================
  199. // =================================================================================================
  200. // general compiler feature support table: https://en.cppreference.com/w/cpp/compiler_support
  201. // MSVC C++11 feature support table: https://msdn.microsoft.com/en-us/library/hh567368.aspx
  202. // GCC C++11 feature support table: https://gcc.gnu.org/projects/cxx-status.html
  203. // MSVC version table:
  204. // https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B#Internal_version_numbering
  205. // MSVC++ 14.2 (16) _MSC_VER == 1920 (Visual Studio 2019)
  206. // MSVC++ 14.1 (15) _MSC_VER == 1910 (Visual Studio 2017)
  207. // MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015)
  208. // MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013)
  209. // MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012)
  210. // MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010)
  211. // MSVC++ 9.0 _MSC_VER == 1500 (Visual Studio 2008)
  212. // MSVC++ 8.0 _MSC_VER == 1400 (Visual Studio 2005)
  213. #if DOCTEST_MSVC && !defined(DOCTEST_CONFIG_WINDOWS_SEH)
  214. #define DOCTEST_CONFIG_WINDOWS_SEH
  215. #endif // MSVC
  216. #if defined(DOCTEST_CONFIG_NO_WINDOWS_SEH) && defined(DOCTEST_CONFIG_WINDOWS_SEH)
  217. #undef DOCTEST_CONFIG_WINDOWS_SEH
  218. #endif // DOCTEST_CONFIG_NO_WINDOWS_SEH
  219. #if !defined(_WIN32) && !defined(__QNX__) && !defined(DOCTEST_CONFIG_POSIX_SIGNALS) && \
  220. !defined(__EMSCRIPTEN__)
  221. #define DOCTEST_CONFIG_POSIX_SIGNALS
  222. #endif // _WIN32
  223. #if defined(DOCTEST_CONFIG_NO_POSIX_SIGNALS) && defined(DOCTEST_CONFIG_POSIX_SIGNALS)
  224. #undef DOCTEST_CONFIG_POSIX_SIGNALS
  225. #endif // DOCTEST_CONFIG_NO_POSIX_SIGNALS
  226. #ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
  227. #if !defined(__cpp_exceptions) && !defined(__EXCEPTIONS) && !defined(_CPPUNWIND)
  228. #define DOCTEST_CONFIG_NO_EXCEPTIONS
  229. #endif // no exceptions
  230. #endif // DOCTEST_CONFIG_NO_EXCEPTIONS
  231. #ifdef DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS
  232. #ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
  233. #define DOCTEST_CONFIG_NO_EXCEPTIONS
  234. #endif // DOCTEST_CONFIG_NO_EXCEPTIONS
  235. #endif // DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS
  236. #if defined(DOCTEST_CONFIG_NO_EXCEPTIONS) && !defined(DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS)
  237. #define DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS
  238. #endif // DOCTEST_CONFIG_NO_EXCEPTIONS && !DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS
  239. #if defined(DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN) && !defined(DOCTEST_CONFIG_IMPLEMENT)
  240. #define DOCTEST_CONFIG_IMPLEMENT
  241. #endif // DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
  242. #if defined(_WIN32) || defined(__CYGWIN__)
  243. #if DOCTEST_MSVC
  244. #define DOCTEST_SYMBOL_EXPORT __declspec(dllexport)
  245. #define DOCTEST_SYMBOL_IMPORT __declspec(dllimport)
  246. #else // MSVC
  247. #define DOCTEST_SYMBOL_EXPORT __attribute__((dllexport))
  248. #define DOCTEST_SYMBOL_IMPORT __attribute__((dllimport))
  249. #endif // MSVC
  250. #else // _WIN32
  251. #define DOCTEST_SYMBOL_EXPORT __attribute__((visibility("default")))
  252. #define DOCTEST_SYMBOL_IMPORT
  253. #endif // _WIN32
  254. #ifdef DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL
  255. #ifdef DOCTEST_CONFIG_IMPLEMENT
  256. #define DOCTEST_INTERFACE DOCTEST_SYMBOL_EXPORT
  257. #else // DOCTEST_CONFIG_IMPLEMENT
  258. #define DOCTEST_INTERFACE DOCTEST_SYMBOL_IMPORT
  259. #endif // DOCTEST_CONFIG_IMPLEMENT
  260. #else // DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL
  261. #define DOCTEST_INTERFACE
  262. #endif // DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL
  263. #define DOCTEST_EMPTY
  264. #if DOCTEST_MSVC
  265. #define DOCTEST_NOINLINE __declspec(noinline)
  266. #define DOCTEST_UNUSED
  267. #define DOCTEST_ALIGNMENT(x)
  268. #elif DOCTEST_CLANG && DOCTEST_CLANG < DOCTEST_COMPILER(3, 5, 0)
  269. #define DOCTEST_NOINLINE
  270. #define DOCTEST_UNUSED
  271. #define DOCTEST_ALIGNMENT(x)
  272. #else
  273. #define DOCTEST_NOINLINE __attribute__((noinline))
  274. #define DOCTEST_UNUSED __attribute__((unused))
  275. #define DOCTEST_ALIGNMENT(x) __attribute__((aligned(x)))
  276. #endif
  277. #ifndef DOCTEST_NORETURN
  278. #define DOCTEST_NORETURN [[noreturn]]
  279. #endif // DOCTEST_NORETURN
  280. #ifndef DOCTEST_NOEXCEPT
  281. #define DOCTEST_NOEXCEPT noexcept
  282. #endif // DOCTEST_NOEXCEPT
  283. // =================================================================================================
  284. // == FEATURE DETECTION END ========================================================================
  285. // =================================================================================================
  286. // internal macros for string concatenation and anonymous variable name generation
  287. #define DOCTEST_CAT_IMPL(s1, s2) s1##s2
  288. #define DOCTEST_CAT(s1, s2) DOCTEST_CAT_IMPL(s1, s2)
  289. #ifdef __COUNTER__ // not standard and may be missing for some compilers
  290. #define DOCTEST_ANONYMOUS(x) DOCTEST_CAT(x, __COUNTER__)
  291. #else // __COUNTER__
  292. #define DOCTEST_ANONYMOUS(x) DOCTEST_CAT(x, __LINE__)
  293. #endif // __COUNTER__
  294. #define DOCTEST_TOSTR(x) #x
  295. #ifndef DOCTEST_CONFIG_ASSERTION_PARAMETERS_BY_VALUE
  296. #define DOCTEST_REF_WRAP(x) x&
  297. #else // DOCTEST_CONFIG_ASSERTION_PARAMETERS_BY_VALUE
  298. #define DOCTEST_REF_WRAP(x) x
  299. #endif // DOCTEST_CONFIG_ASSERTION_PARAMETERS_BY_VALUE
  300. // not using __APPLE__ because... this is how Catch does it
  301. #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
  302. #define DOCTEST_PLATFORM_MAC
  303. #elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
  304. #define DOCTEST_PLATFORM_IPHONE
  305. #elif defined(_WIN32)
  306. #define DOCTEST_PLATFORM_WINDOWS
  307. #else // DOCTEST_PLATFORM
  308. #define DOCTEST_PLATFORM_LINUX
  309. #endif // DOCTEST_PLATFORM
  310. #define DOCTEST_GLOBAL_NO_WARNINGS(var) \
  311. DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wglobal-constructors") \
  312. DOCTEST_CLANG_SUPPRESS_WARNING("-Wunused-variable") \
  313. static const int var DOCTEST_UNUSED // NOLINT(fuchsia-statically-constructed-objects,cert-err58-cpp)
  314. #define DOCTEST_GLOBAL_NO_WARNINGS_END() DOCTEST_CLANG_SUPPRESS_WARNING_POP
  315. #ifndef DOCTEST_BREAK_INTO_DEBUGGER
  316. // should probably take a look at https://github.com/scottt/debugbreak
  317. #ifdef DOCTEST_PLATFORM_LINUX
  318. #if defined(__GNUC__) && (defined(__i386) || defined(__x86_64))
  319. // Break at the location of the failing check if possible
  320. #define DOCTEST_BREAK_INTO_DEBUGGER() __asm__("int $3\n" : :) // NOLINT (hicpp-no-assembler)
  321. #else
  322. #include <signal.h>
  323. #define DOCTEST_BREAK_INTO_DEBUGGER() raise(SIGTRAP)
  324. #endif
  325. #elif defined(DOCTEST_PLATFORM_MAC)
  326. #if defined(__x86_64) || defined(__x86_64__) || defined(__amd64__) || defined(__i386)
  327. #define DOCTEST_BREAK_INTO_DEBUGGER() __asm__("int $3\n" : :) // NOLINT (hicpp-no-assembler)
  328. #else
  329. #define DOCTEST_BREAK_INTO_DEBUGGER() __asm__("brk #0"); // NOLINT (hicpp-no-assembler)
  330. #endif
  331. #elif DOCTEST_MSVC
  332. #define DOCTEST_BREAK_INTO_DEBUGGER() __debugbreak()
  333. #elif defined(__MINGW32__)
  334. DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wredundant-decls")
  335. extern "C" __declspec(dllimport) void __stdcall DebugBreak();
  336. DOCTEST_GCC_SUPPRESS_WARNING_POP
  337. #define DOCTEST_BREAK_INTO_DEBUGGER() ::DebugBreak()
  338. #else // linux
  339. #define DOCTEST_BREAK_INTO_DEBUGGER() (static_cast<void>(0))
  340. #endif // linux
  341. #endif // DOCTEST_BREAK_INTO_DEBUGGER
  342. // this is kept here for backwards compatibility since the config option was changed
  343. #ifdef DOCTEST_CONFIG_USE_IOSFWD
  344. #define DOCTEST_CONFIG_USE_STD_HEADERS
  345. #endif // DOCTEST_CONFIG_USE_IOSFWD
  346. #ifdef DOCTEST_CONFIG_USE_STD_HEADERS
  347. #ifndef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
  348. #define DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
  349. #endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
  350. #include <iosfwd>
  351. #include <cstddef>
  352. #include <ostream>
  353. #else // DOCTEST_CONFIG_USE_STD_HEADERS
  354. #if DOCTEST_CLANG
  355. // to detect if libc++ is being used with clang (the _LIBCPP_VERSION identifier)
  356. #include <ciso646>
  357. #endif // clang
  358. #ifdef _LIBCPP_VERSION
  359. #define DOCTEST_STD_NAMESPACE_BEGIN _LIBCPP_BEGIN_NAMESPACE_STD
  360. #define DOCTEST_STD_NAMESPACE_END _LIBCPP_END_NAMESPACE_STD
  361. #else // _LIBCPP_VERSION
  362. #define DOCTEST_STD_NAMESPACE_BEGIN namespace std {
  363. #define DOCTEST_STD_NAMESPACE_END }
  364. #endif // _LIBCPP_VERSION
  365. // Forward declaring 'X' in namespace std is not permitted by the C++ Standard.
  366. DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4643)
  367. DOCTEST_STD_NAMESPACE_BEGIN // NOLINT (cert-dcl58-cpp)
  368. typedef decltype(nullptr) nullptr_t;
  369. template <class charT>
  370. struct char_traits;
  371. template <>
  372. struct char_traits<char>;
  373. template <class charT, class traits>
  374. class basic_ostream;
  375. typedef basic_ostream<char, char_traits<char>> ostream;
  376. template <class... Types>
  377. class tuple;
  378. #if DOCTEST_MSVC >= DOCTEST_COMPILER(19, 20, 0)
  379. // see this issue on why this is needed: https://github.com/onqtam/doctest/issues/183
  380. template <class _Ty>
  381. class allocator;
  382. template <class _Elem, class _Traits, class _Alloc>
  383. class basic_string;
  384. using string = basic_string<char, char_traits<char>, allocator<char>>;
  385. #endif // VS 2019
  386. DOCTEST_STD_NAMESPACE_END
  387. DOCTEST_MSVC_SUPPRESS_WARNING_POP
  388. #endif // DOCTEST_CONFIG_USE_STD_HEADERS
  389. #ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
  390. #include <type_traits>
  391. #endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
  392. namespace doctest {
  393. DOCTEST_INTERFACE extern bool is_running_in_test;
  394. // A 24 byte string class (can be as small as 17 for x64 and 13 for x86) that can hold strings with length
  395. // of up to 23 chars on the stack before going on the heap - the last byte of the buffer is used for:
  396. // - "is small" bit - the highest bit - if "0" then it is small - otherwise its "1" (128)
  397. // - if small - capacity left before going on the heap - using the lowest 5 bits
  398. // - if small - 2 bits are left unused - the second and third highest ones
  399. // - if small - acts as a null terminator if strlen() is 23 (24 including the null terminator)
  400. // and the "is small" bit remains "0" ("as well as the capacity left") so its OK
  401. // Idea taken from this lecture about the string implementation of facebook/folly - fbstring
  402. // https://www.youtube.com/watch?v=kPR8h4-qZdk
  403. // TODO:
  404. // - optimizations - like not deleting memory unnecessarily in operator= and etc.
  405. // - resize/reserve/clear
  406. // - substr
  407. // - replace
  408. // - back/front
  409. // - iterator stuff
  410. // - find & friends
  411. // - push_back/pop_back
  412. // - assign/insert/erase
  413. // - relational operators as free functions - taking const char* as one of the params
  414. class DOCTEST_INTERFACE String
  415. {
  416. static const unsigned len = 24; //!OCLINT avoid private static members
  417. static const unsigned last = len - 1; //!OCLINT avoid private static members
  418. struct view // len should be more than sizeof(view) - because of the final byte for flags
  419. {
  420. char* ptr;
  421. unsigned size;
  422. unsigned capacity;
  423. };
  424. union
  425. {
  426. char buf[len];
  427. view data;
  428. };
  429. bool isOnStack() const { return (buf[last] & 128) == 0; }
  430. void setOnHeap();
  431. void setLast(unsigned in = last);
  432. void copy(const String& other);
  433. public:
  434. String();
  435. ~String();
  436. // cppcheck-suppress noExplicitConstructor
  437. String(const char* in);
  438. String(const char* in, unsigned in_size);
  439. String(const String& other);
  440. String& operator=(const String& other);
  441. String& operator+=(const String& other);
  442. String operator+(const String& other) const;
  443. String(String&& other);
  444. String& operator=(String&& other);
  445. char operator[](unsigned i) const;
  446. char& operator[](unsigned i);
  447. // the only functions I'm willing to leave in the interface - available for inlining
  448. const char* c_str() const { return const_cast<String*>(this)->c_str(); } // NOLINT
  449. char* c_str() {
  450. if(isOnStack())
  451. return reinterpret_cast<char*>(buf);
  452. return data.ptr;
  453. }
  454. unsigned size() const;
  455. unsigned capacity() const;
  456. int compare(const char* other, bool no_case = false) const;
  457. int compare(const String& other, bool no_case = false) const;
  458. };
  459. DOCTEST_INTERFACE bool operator==(const String& lhs, const String& rhs);
  460. DOCTEST_INTERFACE bool operator!=(const String& lhs, const String& rhs);
  461. DOCTEST_INTERFACE bool operator<(const String& lhs, const String& rhs);
  462. DOCTEST_INTERFACE bool operator>(const String& lhs, const String& rhs);
  463. DOCTEST_INTERFACE bool operator<=(const String& lhs, const String& rhs);
  464. DOCTEST_INTERFACE bool operator>=(const String& lhs, const String& rhs);
  465. DOCTEST_INTERFACE std::ostream& operator<<(std::ostream& s, const String& in);
  466. namespace Color {
  467. enum Enum
  468. {
  469. None = 0,
  470. White,
  471. Red,
  472. Green,
  473. Blue,
  474. Cyan,
  475. Yellow,
  476. Grey,
  477. Bright = 0x10,
  478. BrightRed = Bright | Red,
  479. BrightGreen = Bright | Green,
  480. LightGrey = Bright | Grey,
  481. BrightWhite = Bright | White
  482. };
  483. DOCTEST_INTERFACE std::ostream& operator<<(std::ostream& s, Color::Enum code);
  484. } // namespace Color
  485. namespace assertType {
  486. enum Enum
  487. {
  488. // macro traits
  489. is_warn = 1,
  490. is_check = 2 * is_warn,
  491. is_require = 2 * is_check,
  492. is_normal = 2 * is_require,
  493. is_throws = 2 * is_normal,
  494. is_throws_as = 2 * is_throws,
  495. is_throws_with = 2 * is_throws_as,
  496. is_nothrow = 2 * is_throws_with,
  497. is_false = 2 * is_nothrow,
  498. is_unary = 2 * is_false, // not checked anywhere - used just to distinguish the types
  499. is_eq = 2 * is_unary,
  500. is_ne = 2 * is_eq,
  501. is_lt = 2 * is_ne,
  502. is_gt = 2 * is_lt,
  503. is_ge = 2 * is_gt,
  504. is_le = 2 * is_ge,
  505. // macro types
  506. DT_WARN = is_normal | is_warn,
  507. DT_CHECK = is_normal | is_check,
  508. DT_REQUIRE = is_normal | is_require,
  509. DT_WARN_FALSE = is_normal | is_false | is_warn,
  510. DT_CHECK_FALSE = is_normal | is_false | is_check,
  511. DT_REQUIRE_FALSE = is_normal | is_false | is_require,
  512. DT_WARN_THROWS = is_throws | is_warn,
  513. DT_CHECK_THROWS = is_throws | is_check,
  514. DT_REQUIRE_THROWS = is_throws | is_require,
  515. DT_WARN_THROWS_AS = is_throws_as | is_warn,
  516. DT_CHECK_THROWS_AS = is_throws_as | is_check,
  517. DT_REQUIRE_THROWS_AS = is_throws_as | is_require,
  518. DT_WARN_THROWS_WITH = is_throws_with | is_warn,
  519. DT_CHECK_THROWS_WITH = is_throws_with | is_check,
  520. DT_REQUIRE_THROWS_WITH = is_throws_with | is_require,
  521. DT_WARN_THROWS_WITH_AS = is_throws_with | is_throws_as | is_warn,
  522. DT_CHECK_THROWS_WITH_AS = is_throws_with | is_throws_as | is_check,
  523. DT_REQUIRE_THROWS_WITH_AS = is_throws_with | is_throws_as | is_require,
  524. DT_WARN_NOTHROW = is_nothrow | is_warn,
  525. DT_CHECK_NOTHROW = is_nothrow | is_check,
  526. DT_REQUIRE_NOTHROW = is_nothrow | is_require,
  527. DT_WARN_EQ = is_normal | is_eq | is_warn,
  528. DT_CHECK_EQ = is_normal | is_eq | is_check,
  529. DT_REQUIRE_EQ = is_normal | is_eq | is_require,
  530. DT_WARN_NE = is_normal | is_ne | is_warn,
  531. DT_CHECK_NE = is_normal | is_ne | is_check,
  532. DT_REQUIRE_NE = is_normal | is_ne | is_require,
  533. DT_WARN_GT = is_normal | is_gt | is_warn,
  534. DT_CHECK_GT = is_normal | is_gt | is_check,
  535. DT_REQUIRE_GT = is_normal | is_gt | is_require,
  536. DT_WARN_LT = is_normal | is_lt | is_warn,
  537. DT_CHECK_LT = is_normal | is_lt | is_check,
  538. DT_REQUIRE_LT = is_normal | is_lt | is_require,
  539. DT_WARN_GE = is_normal | is_ge | is_warn,
  540. DT_CHECK_GE = is_normal | is_ge | is_check,
  541. DT_REQUIRE_GE = is_normal | is_ge | is_require,
  542. DT_WARN_LE = is_normal | is_le | is_warn,
  543. DT_CHECK_LE = is_normal | is_le | is_check,
  544. DT_REQUIRE_LE = is_normal | is_le | is_require,
  545. DT_WARN_UNARY = is_normal | is_unary | is_warn,
  546. DT_CHECK_UNARY = is_normal | is_unary | is_check,
  547. DT_REQUIRE_UNARY = is_normal | is_unary | is_require,
  548. DT_WARN_UNARY_FALSE = is_normal | is_false | is_unary | is_warn,
  549. DT_CHECK_UNARY_FALSE = is_normal | is_false | is_unary | is_check,
  550. DT_REQUIRE_UNARY_FALSE = is_normal | is_false | is_unary | is_require,
  551. };
  552. } // namespace assertType
  553. DOCTEST_INTERFACE const char* assertString(assertType::Enum at);
  554. DOCTEST_INTERFACE const char* failureString(assertType::Enum at);
  555. DOCTEST_INTERFACE const char* skipPathFromFilename(const char* file);
  556. struct DOCTEST_INTERFACE TestCaseData
  557. {
  558. String m_file; // the file in which the test was registered (using String - see #350)
  559. unsigned m_line; // the line where the test was registered
  560. const char* m_name; // name of the test case
  561. const char* m_test_suite; // the test suite in which the test was added
  562. const char* m_description;
  563. bool m_skip;
  564. bool m_no_breaks;
  565. bool m_no_output;
  566. bool m_may_fail;
  567. bool m_should_fail;
  568. int m_expected_failures;
  569. double m_timeout;
  570. };
  571. struct DOCTEST_INTERFACE AssertData
  572. {
  573. // common - for all asserts
  574. const TestCaseData* m_test_case;
  575. assertType::Enum m_at;
  576. const char* m_file;
  577. int m_line;
  578. const char* m_expr;
  579. bool m_failed;
  580. // exception-related - for all asserts
  581. bool m_threw;
  582. String m_exception;
  583. // for normal asserts
  584. String m_decomp;
  585. // for specific exception-related asserts
  586. bool m_threw_as;
  587. const char* m_exception_type;
  588. const char* m_exception_string;
  589. };
  590. struct DOCTEST_INTERFACE MessageData
  591. {
  592. String m_string;
  593. const char* m_file;
  594. int m_line;
  595. assertType::Enum m_severity;
  596. };
  597. struct DOCTEST_INTERFACE SubcaseSignature
  598. {
  599. String m_name;
  600. const char* m_file;
  601. int m_line;
  602. bool operator<(const SubcaseSignature& other) const;
  603. };
  604. struct DOCTEST_INTERFACE IContextScope
  605. {
  606. IContextScope();
  607. virtual ~IContextScope();
  608. virtual void stringify(std::ostream*) const = 0;
  609. };
  610. namespace detail {
  611. struct DOCTEST_INTERFACE TestCase;
  612. } // namespace detail
  613. struct ContextOptions //!OCLINT too many fields
  614. {
  615. std::ostream* cout; // stdout stream - std::cout by default
  616. std::ostream* cerr; // stderr stream - std::cerr by default
  617. String binary_name; // the test binary name
  618. const detail::TestCase* currentTest = nullptr;
  619. // == parameters from the command line
  620. String out; // output filename
  621. String order_by; // how tests should be ordered
  622. unsigned rand_seed; // the seed for rand ordering
  623. unsigned first; // the first (matching) test to be executed
  624. unsigned last; // the last (matching) test to be executed
  625. int abort_after; // stop tests after this many failed assertions
  626. int subcase_filter_levels; // apply the subcase filters for the first N levels
  627. bool success; // include successful assertions in output
  628. bool case_sensitive; // if filtering should be case sensitive
  629. bool exit; // if the program should be exited after the tests are ran/whatever
  630. bool duration; // print the time duration of each test case
  631. bool no_throw; // to skip exceptions-related assertion macros
  632. bool no_exitcode; // if the framework should return 0 as the exitcode
  633. bool no_run; // to not run the tests at all (can be done with an "*" exclude)
  634. bool no_version; // to not print the version of the framework
  635. bool no_colors; // if output to the console should be colorized
  636. bool force_colors; // forces the use of colors even when a tty cannot be detected
  637. bool no_breaks; // to not break into the debugger
  638. bool no_skip; // don't skip test cases which are marked to be skipped
  639. bool gnu_file_line; // if line numbers should be surrounded with :x: and not (x):
  640. bool no_path_in_filenames; // if the path to files should be removed from the output
  641. bool no_line_numbers; // if source code line numbers should be omitted from the output
  642. bool no_debug_output; // no output in the debug console when a debugger is attached
  643. bool no_skipped_summary; // don't print "skipped" in the summary !!! UNDOCUMENTED !!!
  644. bool no_time_in_output; // omit any time/timestamps from output !!! UNDOCUMENTED !!!
  645. bool help; // to print the help
  646. bool version; // to print the version
  647. bool count; // if only the count of matching tests is to be retrieved
  648. bool list_test_cases; // to list all tests matching the filters
  649. bool list_test_suites; // to list all suites matching the filters
  650. bool list_reporters; // lists all registered reporters
  651. };
  652. namespace detail {
  653. template <bool CONDITION, typename TYPE = void>
  654. struct enable_if
  655. {};
  656. template <typename TYPE>
  657. struct enable_if<true, TYPE>
  658. { typedef TYPE type; };
  659. // clang-format off
  660. template<class T> struct remove_reference { typedef T type; };
  661. template<class T> struct remove_reference<T&> { typedef T type; };
  662. template<class T> struct remove_reference<T&&> { typedef T type; };
  663. template<typename T, typename U = T&&> U declval(int);
  664. template<typename T> T declval(long);
  665. template<typename T> auto declval() DOCTEST_NOEXCEPT -> decltype(declval<T>(0)) ;
  666. template<class T> struct is_lvalue_reference { const static bool value=false; };
  667. template<class T> struct is_lvalue_reference<T&> { const static bool value=true; };
  668. template <class T>
  669. inline T&& forward(typename remove_reference<T>::type& t) DOCTEST_NOEXCEPT
  670. {
  671. return static_cast<T&&>(t);
  672. }
  673. template <class T>
  674. inline T&& forward(typename remove_reference<T>::type&& t) DOCTEST_NOEXCEPT
  675. {
  676. static_assert(!is_lvalue_reference<T>::value,
  677. "Can not forward an rvalue as an lvalue.");
  678. return static_cast<T&&>(t);
  679. }
  680. template<class T> struct remove_const { typedef T type; };
  681. template<class T> struct remove_const<const T> { typedef T type; };
  682. #ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
  683. template<class T> struct is_enum : public std::is_enum<T> {};
  684. template<class T> struct underlying_type : public std::underlying_type<T> {};
  685. #else
  686. // Use compiler intrinsics
  687. template<class T> struct is_enum { constexpr static bool value = __is_enum(T); };
  688. template<class T> struct underlying_type { typedef __underlying_type(T) type; };
  689. #endif
  690. // clang-format on
  691. template <typename T>
  692. struct deferred_false
  693. // cppcheck-suppress unusedStructMember
  694. { static const bool value = false; };
  695. namespace has_insertion_operator_impl {
  696. std::ostream &os();
  697. template<class T>
  698. DOCTEST_REF_WRAP(T) val();
  699. template<class, class = void>
  700. struct check {
  701. static constexpr bool value = false;
  702. };
  703. template<class T>
  704. struct check<T, decltype(os() << val<T>(), void())> {
  705. static constexpr bool value = true;
  706. };
  707. } // namespace has_insertion_operator_impl
  708. template<class T>
  709. using has_insertion_operator = has_insertion_operator_impl::check<const T>;
  710. DOCTEST_INTERFACE void my_memcpy(void* dest, const void* src, unsigned num);
  711. DOCTEST_INTERFACE std::ostream* getTlsOss(); // returns a thread-local ostringstream
  712. DOCTEST_INTERFACE String getTlsOssResult();
  713. template <bool C>
  714. struct StringMakerBase
  715. {
  716. template <typename T>
  717. static String convert(const DOCTEST_REF_WRAP(T)) {
  718. return "{?}";
  719. }
  720. };
  721. template <>
  722. struct StringMakerBase<true>
  723. {
  724. template <typename T>
  725. static String convert(const DOCTEST_REF_WRAP(T) in) {
  726. *getTlsOss() << in;
  727. return getTlsOssResult();
  728. }
  729. };
  730. DOCTEST_INTERFACE String rawMemoryToString(const void* object, unsigned size);
  731. template <typename T>
  732. String rawMemoryToString(const DOCTEST_REF_WRAP(T) object) {
  733. return rawMemoryToString(&object, sizeof(object));
  734. }
  735. template <typename T>
  736. const char* type_to_string() {
  737. return "<>";
  738. }
  739. } // namespace detail
  740. template <typename T>
  741. struct StringMaker : public detail::StringMakerBase<detail::has_insertion_operator<T>::value>
  742. {};
  743. template <typename T>
  744. struct StringMaker<T*>
  745. {
  746. template <typename U>
  747. static String convert(U* p) {
  748. if(p)
  749. return detail::rawMemoryToString(p);
  750. return "NULL";
  751. }
  752. };
  753. template <typename R, typename C>
  754. struct StringMaker<R C::*>
  755. {
  756. static String convert(R C::*p) {
  757. if(p)
  758. return detail::rawMemoryToString(p);
  759. return "NULL";
  760. }
  761. };
  762. template <typename T, typename detail::enable_if<!detail::is_enum<T>::value, bool>::type = true>
  763. String toString(const DOCTEST_REF_WRAP(T) value) {
  764. return StringMaker<T>::convert(value);
  765. }
  766. #ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
  767. DOCTEST_INTERFACE String toString(char* in);
  768. DOCTEST_INTERFACE String toString(const char* in);
  769. #endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
  770. DOCTEST_INTERFACE String toString(bool in);
  771. DOCTEST_INTERFACE String toString(float in);
  772. DOCTEST_INTERFACE String toString(double in);
  773. DOCTEST_INTERFACE String toString(double long in);
  774. DOCTEST_INTERFACE String toString(char in);
  775. DOCTEST_INTERFACE String toString(char signed in);
  776. DOCTEST_INTERFACE String toString(char unsigned in);
  777. DOCTEST_INTERFACE String toString(int short in);
  778. DOCTEST_INTERFACE String toString(int short unsigned in);
  779. DOCTEST_INTERFACE String toString(int in);
  780. DOCTEST_INTERFACE String toString(int unsigned in);
  781. DOCTEST_INTERFACE String toString(int long in);
  782. DOCTEST_INTERFACE String toString(int long unsigned in);
  783. DOCTEST_INTERFACE String toString(int long long in);
  784. DOCTEST_INTERFACE String toString(int long long unsigned in);
  785. DOCTEST_INTERFACE String toString(std::nullptr_t in);
  786. template <typename T, typename detail::enable_if<detail::is_enum<T>::value, bool>::type = true>
  787. String toString(const DOCTEST_REF_WRAP(T) value) {
  788. typedef typename detail::underlying_type<T>::type UT;
  789. return toString(static_cast<UT>(value));
  790. }
  791. #if DOCTEST_MSVC >= DOCTEST_COMPILER(19, 20, 0)
  792. // see this issue on why this is needed: https://github.com/onqtam/doctest/issues/183
  793. DOCTEST_INTERFACE String toString(const std::string& in);
  794. #endif // VS 2019
  795. class DOCTEST_INTERFACE Approx
  796. {
  797. public:
  798. explicit Approx(double value);
  799. Approx operator()(double value) const;
  800. #ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
  801. template <typename T>
  802. explicit Approx(const T& value,
  803. typename detail::enable_if<std::is_constructible<double, T>::value>::type* =
  804. static_cast<T*>(nullptr)) {
  805. *this = Approx(static_cast<double>(value));
  806. }
  807. #endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
  808. Approx& epsilon(double newEpsilon);
  809. #ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
  810. template <typename T>
  811. typename detail::enable_if<std::is_constructible<double, T>::value, Approx&>::type epsilon(
  812. const T& newEpsilon) {
  813. m_epsilon = static_cast<double>(newEpsilon);
  814. return *this;
  815. }
  816. #endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
  817. Approx& scale(double newScale);
  818. #ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
  819. template <typename T>
  820. typename detail::enable_if<std::is_constructible<double, T>::value, Approx&>::type scale(
  821. const T& newScale) {
  822. m_scale = static_cast<double>(newScale);
  823. return *this;
  824. }
  825. #endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
  826. // clang-format off
  827. DOCTEST_INTERFACE friend bool operator==(double lhs, const Approx & rhs);
  828. DOCTEST_INTERFACE friend bool operator==(const Approx & lhs, double rhs);
  829. DOCTEST_INTERFACE friend bool operator!=(double lhs, const Approx & rhs);
  830. DOCTEST_INTERFACE friend bool operator!=(const Approx & lhs, double rhs);
  831. DOCTEST_INTERFACE friend bool operator<=(double lhs, const Approx & rhs);
  832. DOCTEST_INTERFACE friend bool operator<=(const Approx & lhs, double rhs);
  833. DOCTEST_INTERFACE friend bool operator>=(double lhs, const Approx & rhs);
  834. DOCTEST_INTERFACE friend bool operator>=(const Approx & lhs, double rhs);
  835. DOCTEST_INTERFACE friend bool operator< (double lhs, const Approx & rhs);
  836. DOCTEST_INTERFACE friend bool operator< (const Approx & lhs, double rhs);
  837. DOCTEST_INTERFACE friend bool operator> (double lhs, const Approx & rhs);
  838. DOCTEST_INTERFACE friend bool operator> (const Approx & lhs, double rhs);
  839. DOCTEST_INTERFACE friend String toString(const Approx& in);
  840. #ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
  841. #define DOCTEST_APPROX_PREFIX \
  842. template <typename T> friend typename detail::enable_if<std::is_constructible<double, T>::value, bool>::type
  843. DOCTEST_APPROX_PREFIX operator==(const T& lhs, const Approx& rhs) { return operator==(double(lhs), rhs); }
  844. DOCTEST_APPROX_PREFIX operator==(const Approx& lhs, const T& rhs) { return operator==(rhs, lhs); }
  845. DOCTEST_APPROX_PREFIX operator!=(const T& lhs, const Approx& rhs) { return !operator==(lhs, rhs); }
  846. DOCTEST_APPROX_PREFIX operator!=(const Approx& lhs, const T& rhs) { return !operator==(rhs, lhs); }
  847. DOCTEST_APPROX_PREFIX operator<=(const T& lhs, const Approx& rhs) { return double(lhs) < rhs.m_value || lhs == rhs; }
  848. DOCTEST_APPROX_PREFIX operator<=(const Approx& lhs, const T& rhs) { return lhs.m_value < double(rhs) || lhs == rhs; }
  849. DOCTEST_APPROX_PREFIX operator>=(const T& lhs, const Approx& rhs) { return double(lhs) > rhs.m_value || lhs == rhs; }
  850. DOCTEST_APPROX_PREFIX operator>=(const Approx& lhs, const T& rhs) { return lhs.m_value > double(rhs) || lhs == rhs; }
  851. DOCTEST_APPROX_PREFIX operator< (const T& lhs, const Approx& rhs) { return double(lhs) < rhs.m_value && lhs != rhs; }
  852. DOCTEST_APPROX_PREFIX operator< (const Approx& lhs, const T& rhs) { return lhs.m_value < double(rhs) && lhs != rhs; }
  853. DOCTEST_APPROX_PREFIX operator> (const T& lhs, const Approx& rhs) { return double(lhs) > rhs.m_value && lhs != rhs; }
  854. DOCTEST_APPROX_PREFIX operator> (const Approx& lhs, const T& rhs) { return lhs.m_value > double(rhs) && lhs != rhs; }
  855. #undef DOCTEST_APPROX_PREFIX
  856. #endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS
  857. // clang-format on
  858. private:
  859. double m_epsilon;
  860. double m_scale;
  861. double m_value;
  862. };
  863. DOCTEST_INTERFACE String toString(const Approx& in);
  864. DOCTEST_INTERFACE const ContextOptions* getContextOptions();
  865. #if !defined(DOCTEST_CONFIG_DISABLE)
  866. namespace detail {
  867. // clang-format off
  868. #ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
  869. template<class T> struct decay_array { typedef T type; };
  870. template<class T, unsigned N> struct decay_array<T[N]> { typedef T* type; };
  871. template<class T> struct decay_array<T[]> { typedef T* type; };
  872. template<class T> struct not_char_pointer { enum { value = 1 }; };
  873. template<> struct not_char_pointer<char*> { enum { value = 0 }; };
  874. template<> struct not_char_pointer<const char*> { enum { value = 0 }; };
  875. template<class T> struct can_use_op : public not_char_pointer<typename decay_array<T>::type> {};
  876. #endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
  877. // clang-format on
  878. struct DOCTEST_INTERFACE TestFailureException
  879. {
  880. };
  881. DOCTEST_INTERFACE bool checkIfShouldThrow(assertType::Enum at);
  882. #ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
  883. DOCTEST_NORETURN
  884. #endif // DOCTEST_CONFIG_NO_EXCEPTIONS
  885. DOCTEST_INTERFACE void throwException();
  886. struct DOCTEST_INTERFACE Subcase
  887. {
  888. SubcaseSignature m_signature;
  889. bool m_entered = false;
  890. Subcase(const String& name, const char* file, int line);
  891. ~Subcase();
  892. operator bool() const;
  893. };
  894. template <typename L, typename R>
  895. String stringifyBinaryExpr(const DOCTEST_REF_WRAP(L) lhs, const char* op,
  896. const DOCTEST_REF_WRAP(R) rhs) {
  897. // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
  898. return toString(lhs) + op + toString(rhs);
  899. }
  900. #if DOCTEST_CLANG && DOCTEST_CLANG < DOCTEST_COMPILER(3, 6, 0)
  901. DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wunused-comparison")
  902. #endif
  903. // This will check if there is any way it could find a operator like member or friend and uses it.
  904. // If not it doesn't find the operator or if the operator at global scope is defined after
  905. // this template, the template won't be instantiated due to SFINAE. Once the template is not
  906. // instantiated it can look for global operator using normal conversions.
  907. #define SFINAE_OP(ret,op) decltype(doctest::detail::declval<L>() op doctest::detail::declval<R>(),static_cast<ret>(0))
  908. #define DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(op, op_str, op_macro) \
  909. template <typename R> \
  910. DOCTEST_NOINLINE SFINAE_OP(Result,op) operator op(R&& rhs) { \
  911. bool res = op_macro(doctest::detail::forward<L>(lhs), doctest::detail::forward<R>(rhs)); \
  912. if(m_at & assertType::is_false) \
  913. res = !res; \
  914. if(!res || doctest::getContextOptions()->success) \
  915. return Result(res, stringifyBinaryExpr(lhs, op_str, rhs)); \
  916. return Result(res); \
  917. }
  918. // more checks could be added - like in Catch:
  919. // https://github.com/catchorg/Catch2/pull/1480/files
  920. // https://github.com/catchorg/Catch2/pull/1481/files
  921. #define DOCTEST_FORBIT_EXPRESSION(rt, op) \
  922. template <typename R> \
  923. rt& operator op(const R&) { \
  924. static_assert(deferred_false<R>::value, \
  925. "Expression Too Complex Please Rewrite As Binary Comparison!"); \
  926. return *this; \
  927. }
  928. struct DOCTEST_INTERFACE Result
  929. {
  930. bool m_passed;
  931. String m_decomp;
  932. Result(bool passed, const String& decomposition = String());
  933. // forbidding some expressions based on this table: https://en.cppreference.com/w/cpp/language/operator_precedence
  934. DOCTEST_FORBIT_EXPRESSION(Result, &)
  935. DOCTEST_FORBIT_EXPRESSION(Result, ^)
  936. DOCTEST_FORBIT_EXPRESSION(Result, |)
  937. DOCTEST_FORBIT_EXPRESSION(Result, &&)
  938. DOCTEST_FORBIT_EXPRESSION(Result, ||)
  939. DOCTEST_FORBIT_EXPRESSION(Result, ==)
  940. DOCTEST_FORBIT_EXPRESSION(Result, !=)
  941. DOCTEST_FORBIT_EXPRESSION(Result, <)
  942. DOCTEST_FORBIT_EXPRESSION(Result, >)
  943. DOCTEST_FORBIT_EXPRESSION(Result, <=)
  944. DOCTEST_FORBIT_EXPRESSION(Result, >=)
  945. DOCTEST_FORBIT_EXPRESSION(Result, =)
  946. DOCTEST_FORBIT_EXPRESSION(Result, +=)
  947. DOCTEST_FORBIT_EXPRESSION(Result, -=)
  948. DOCTEST_FORBIT_EXPRESSION(Result, *=)
  949. DOCTEST_FORBIT_EXPRESSION(Result, /=)
  950. DOCTEST_FORBIT_EXPRESSION(Result, %=)
  951. DOCTEST_FORBIT_EXPRESSION(Result, <<=)
  952. DOCTEST_FORBIT_EXPRESSION(Result, >>=)
  953. DOCTEST_FORBIT_EXPRESSION(Result, &=)
  954. DOCTEST_FORBIT_EXPRESSION(Result, ^=)
  955. DOCTEST_FORBIT_EXPRESSION(Result, |=)
  956. };
  957. #ifndef DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION
  958. DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
  959. DOCTEST_CLANG_SUPPRESS_WARNING("-Wsign-conversion")
  960. DOCTEST_CLANG_SUPPRESS_WARNING("-Wsign-compare")
  961. //DOCTEST_CLANG_SUPPRESS_WARNING("-Wdouble-promotion")
  962. //DOCTEST_CLANG_SUPPRESS_WARNING("-Wconversion")
  963. //DOCTEST_CLANG_SUPPRESS_WARNING("-Wfloat-equal")
  964. DOCTEST_GCC_SUPPRESS_WARNING_PUSH
  965. DOCTEST_GCC_SUPPRESS_WARNING("-Wsign-conversion")
  966. DOCTEST_GCC_SUPPRESS_WARNING("-Wsign-compare")
  967. //DOCTEST_GCC_SUPPRESS_WARNING("-Wdouble-promotion")
  968. //DOCTEST_GCC_SUPPRESS_WARNING("-Wconversion")
  969. //DOCTEST_GCC_SUPPRESS_WARNING("-Wfloat-equal")
  970. DOCTEST_MSVC_SUPPRESS_WARNING_PUSH
  971. // https://stackoverflow.com/questions/39479163 what's the difference between 4018 and 4389
  972. DOCTEST_MSVC_SUPPRESS_WARNING(4388) // signed/unsigned mismatch
  973. DOCTEST_MSVC_SUPPRESS_WARNING(4389) // 'operator' : signed/unsigned mismatch
  974. DOCTEST_MSVC_SUPPRESS_WARNING(4018) // 'expression' : signed/unsigned mismatch
  975. //DOCTEST_MSVC_SUPPRESS_WARNING(4805) // 'operation' : unsafe mix of type 'type' and type 'type' in operation
  976. #endif // DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION
  977. // clang-format off
  978. #ifndef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
  979. #define DOCTEST_COMPARISON_RETURN_TYPE bool
  980. #else // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
  981. #define DOCTEST_COMPARISON_RETURN_TYPE typename enable_if<can_use_op<L>::value || can_use_op<R>::value, bool>::type
  982. // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
  983. inline bool eq(const char* lhs, const char* rhs) { return String(lhs) == String(rhs); }
  984. inline bool ne(const char* lhs, const char* rhs) { return String(lhs) != String(rhs); }
  985. inline bool lt(const char* lhs, const char* rhs) { return String(lhs) < String(rhs); }
  986. inline bool gt(const char* lhs, const char* rhs) { return String(lhs) > String(rhs); }
  987. inline bool le(const char* lhs, const char* rhs) { return String(lhs) <= String(rhs); }
  988. inline bool ge(const char* lhs, const char* rhs) { return String(lhs) >= String(rhs); }
  989. #endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
  990. // clang-format on
  991. #define DOCTEST_RELATIONAL_OP(name, op) \
  992. template <typename L, typename R> \
  993. DOCTEST_COMPARISON_RETURN_TYPE name(const DOCTEST_REF_WRAP(L) lhs, \
  994. const DOCTEST_REF_WRAP(R) rhs) { \
  995. return lhs op rhs; \
  996. }
  997. DOCTEST_RELATIONAL_OP(eq, ==)
  998. DOCTEST_RELATIONAL_OP(ne, !=)
  999. DOCTEST_RELATIONAL_OP(lt, <)
  1000. DOCTEST_RELATIONAL_OP(gt, >)
  1001. DOCTEST_RELATIONAL_OP(le, <=)
  1002. DOCTEST_RELATIONAL_OP(ge, >=)
  1003. #ifndef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
  1004. #define DOCTEST_CMP_EQ(l, r) l == r
  1005. #define DOCTEST_CMP_NE(l, r) l != r
  1006. #define DOCTEST_CMP_GT(l, r) l > r
  1007. #define DOCTEST_CMP_LT(l, r) l < r
  1008. #define DOCTEST_CMP_GE(l, r) l >= r
  1009. #define DOCTEST_CMP_LE(l, r) l <= r
  1010. #else // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
  1011. #define DOCTEST_CMP_EQ(l, r) eq(l, r)
  1012. #define DOCTEST_CMP_NE(l, r) ne(l, r)
  1013. #define DOCTEST_CMP_GT(l, r) gt(l, r)
  1014. #define DOCTEST_CMP_LT(l, r) lt(l, r)
  1015. #define DOCTEST_CMP_GE(l, r) ge(l, r)
  1016. #define DOCTEST_CMP_LE(l, r) le(l, r)
  1017. #endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
  1018. template <typename L>
  1019. // cppcheck-suppress copyCtorAndEqOperator
  1020. struct Expression_lhs
  1021. {
  1022. L lhs;
  1023. assertType::Enum m_at;
  1024. explicit Expression_lhs(L&& in, assertType::Enum at)
  1025. : lhs(doctest::detail::forward<L>(in))
  1026. , m_at(at) {}
  1027. DOCTEST_NOINLINE operator Result() {
  1028. // this is needed only foc MSVC 2015:
  1029. // https://ci.appveyor.com/project/onqtam/doctest/builds/38181202
  1030. DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4800) // 'int': forcing value to bool
  1031. bool res = static_cast<bool>(lhs);
  1032. DOCTEST_MSVC_SUPPRESS_WARNING_POP
  1033. if(m_at & assertType::is_false) //!OCLINT bitwise operator in conditional
  1034. res = !res;
  1035. if(!res || getContextOptions()->success)
  1036. return Result(res, toString(lhs));
  1037. return Result(res);
  1038. }
  1039. /* This is required for user-defined conversions from Expression_lhs to L */
  1040. //operator L() const { return lhs; }
  1041. operator L() const { return lhs; }
  1042. // clang-format off
  1043. DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(==, " == ", DOCTEST_CMP_EQ) //!OCLINT bitwise operator in conditional
  1044. DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(!=, " != ", DOCTEST_CMP_NE) //!OCLINT bitwise operator in conditional
  1045. DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(>, " > ", DOCTEST_CMP_GT) //!OCLINT bitwise operator in conditional
  1046. DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(<, " < ", DOCTEST_CMP_LT) //!OCLINT bitwise operator in conditional
  1047. DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(>=, " >= ", DOCTEST_CMP_GE) //!OCLINT bitwise operator in conditional
  1048. DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(<=, " <= ", DOCTEST_CMP_LE) //!OCLINT bitwise operator in conditional
  1049. // clang-format on
  1050. // forbidding some expressions based on this table: https://en.cppreference.com/w/cpp/language/operator_precedence
  1051. DOCTEST_FORBIT_EXPRESSION(Expression_lhs, &)
  1052. DOCTEST_FORBIT_EXPRESSION(Expression_lhs, ^)
  1053. DOCTEST_FORBIT_EXPRESSION(Expression_lhs, |)
  1054. DOCTEST_FORBIT_EXPRESSION(Expression_lhs, &&)
  1055. DOCTEST_FORBIT_EXPRESSION(Expression_lhs, ||)
  1056. DOCTEST_FORBIT_EXPRESSION(Expression_lhs, =)
  1057. DOCTEST_FORBIT_EXPRESSION(Expression_lhs, +=)
  1058. DOCTEST_FORBIT_EXPRESSION(Expression_lhs, -=)
  1059. DOCTEST_FORBIT_EXPRESSION(Expression_lhs, *=)
  1060. DOCTEST_FORBIT_EXPRESSION(Expression_lhs, /=)
  1061. DOCTEST_FORBIT_EXPRESSION(Expression_lhs, %=)
  1062. DOCTEST_FORBIT_EXPRESSION(Expression_lhs, <<=)
  1063. DOCTEST_FORBIT_EXPRESSION(Expression_lhs, >>=)
  1064. DOCTEST_FORBIT_EXPRESSION(Expression_lhs, &=)
  1065. DOCTEST_FORBIT_EXPRESSION(Expression_lhs, ^=)
  1066. DOCTEST_FORBIT_EXPRESSION(Expression_lhs, |=)
  1067. // these 2 are unfortunate because they should be allowed - they have higher precedence over the comparisons, but the
  1068. // ExpressionDecomposer class uses the left shift operator to capture the left operand of the binary expression...
  1069. DOCTEST_FORBIT_EXPRESSION(Expression_lhs, <<)
  1070. DOCTEST_FORBIT_EXPRESSION(Expression_lhs, >>)
  1071. };
  1072. #ifndef DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION
  1073. DOCTEST_CLANG_SUPPRESS_WARNING_POP
  1074. DOCTEST_MSVC_SUPPRESS_WARNING_POP
  1075. DOCTEST_GCC_SUPPRESS_WARNING_POP
  1076. #endif // DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION
  1077. #if DOCTEST_CLANG && DOCTEST_CLANG < DOCTEST_COMPILER(3, 6, 0)
  1078. DOCTEST_CLANG_SUPPRESS_WARNING_POP
  1079. #endif
  1080. struct DOCTEST_INTERFACE ExpressionDecomposer
  1081. {
  1082. assertType::Enum m_at;
  1083. ExpressionDecomposer(assertType::Enum at);
  1084. // The right operator for capturing expressions is "<=" instead of "<<" (based on the operator precedence table)
  1085. // but then there will be warnings from GCC about "-Wparentheses" and since "_Pragma()" is problematic this will stay for now...
  1086. // https://github.com/catchorg/Catch2/issues/870
  1087. // https://github.com/catchorg/Catch2/issues/565
  1088. template <typename L>
  1089. Expression_lhs<L> operator<<(L &&operand) {
  1090. return Expression_lhs<L>(doctest::detail::forward<L>(operand), m_at);
  1091. }
  1092. };
  1093. struct DOCTEST_INTERFACE TestSuite
  1094. {
  1095. const char* m_test_suite;
  1096. const char* m_description;
  1097. bool m_skip;
  1098. bool m_no_breaks;
  1099. bool m_no_output;
  1100. bool m_may_fail;
  1101. bool m_should_fail;
  1102. int m_expected_failures;
  1103. double m_timeout;
  1104. TestSuite& operator*(const char* in);
  1105. template <typename T>
  1106. TestSuite& operator*(const T& in) {
  1107. in.fill(*this);
  1108. return *this;
  1109. }
  1110. };
  1111. typedef void (*funcType)();
  1112. struct DOCTEST_INTERFACE TestCase : public TestCaseData
  1113. {
  1114. funcType m_test; // a function pointer to the test case
  1115. const char* m_type; // for templated test cases - gets appended to the real name
  1116. int m_template_id; // an ID used to distinguish between the different versions of a templated test case
  1117. String m_full_name; // contains the name (only for templated test cases!) + the template type
  1118. TestCase(funcType test, const char* file, unsigned line, const TestSuite& test_suite,
  1119. const char* type = "", int template_id = -1);
  1120. TestCase(const TestCase& other);
  1121. DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(26434) // hides a non-virtual function
  1122. TestCase& operator=(const TestCase& other);
  1123. DOCTEST_MSVC_SUPPRESS_WARNING_POP
  1124. TestCase& operator*(const char* in);
  1125. template <typename T>
  1126. TestCase& operator*(const T& in) {
  1127. in.fill(*this);
  1128. return *this;
  1129. }
  1130. bool operator<(const TestCase& other) const;
  1131. };
  1132. // forward declarations of functions used by the macros
  1133. DOCTEST_INTERFACE int regTest(const TestCase& tc);
  1134. DOCTEST_INTERFACE int setTestSuite(const TestSuite& ts);
  1135. DOCTEST_INTERFACE bool isDebuggerActive();
  1136. template<typename T>
  1137. int instantiationHelper(const T&) { return 0; }
  1138. namespace binaryAssertComparison {
  1139. enum Enum
  1140. {
  1141. eq = 0,
  1142. ne,
  1143. gt,
  1144. lt,
  1145. ge,
  1146. le
  1147. };
  1148. } // namespace binaryAssertComparison
  1149. // clang-format off
  1150. template <int, class L, class R> struct RelationalComparator { bool operator()(const DOCTEST_REF_WRAP(L), const DOCTEST_REF_WRAP(R) ) const { return false; } };
  1151. #define DOCTEST_BINARY_RELATIONAL_OP(n, op) \
  1152. 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); } };
  1153. // clang-format on
  1154. DOCTEST_BINARY_RELATIONAL_OP(0, doctest::detail::eq)
  1155. DOCTEST_BINARY_RELATIONAL_OP(1, doctest::detail::ne)
  1156. DOCTEST_BINARY_RELATIONAL_OP(2, doctest::detail::gt)
  1157. DOCTEST_BINARY_RELATIONAL_OP(3, doctest::detail::lt)
  1158. DOCTEST_BINARY_RELATIONAL_OP(4, doctest::detail::ge)
  1159. DOCTEST_BINARY_RELATIONAL_OP(5, doctest::detail::le)
  1160. struct DOCTEST_INTERFACE ResultBuilder : public AssertData
  1161. {
  1162. ResultBuilder(assertType::Enum at, const char* file, int line, const char* expr,
  1163. const char* exception_type = "", const char* exception_string = "");
  1164. void setResult(const Result& res);
  1165. template <int comparison, typename L, typename R>
  1166. DOCTEST_NOINLINE void binary_assert(const DOCTEST_REF_WRAP(L) lhs,
  1167. const DOCTEST_REF_WRAP(R) rhs) {
  1168. m_failed = !RelationalComparator<comparison, L, R>()(lhs, rhs);
  1169. if(m_failed || getContextOptions()->success)
  1170. m_decomp = stringifyBinaryExpr(lhs, ", ", rhs);
  1171. }
  1172. template <typename L>
  1173. DOCTEST_NOINLINE void unary_assert(const DOCTEST_REF_WRAP(L) val) {
  1174. m_failed = !val;
  1175. if(m_at & assertType::is_false) //!OCLINT bitwise operator in conditional
  1176. m_failed = !m_failed;
  1177. if(m_failed || getContextOptions()->success)
  1178. m_decomp = toString(val);
  1179. }
  1180. void translateException();
  1181. bool log();
  1182. void react() const;
  1183. };
  1184. namespace assertAction {
  1185. enum Enum
  1186. {
  1187. nothing = 0,
  1188. dbgbreak = 1,
  1189. shouldthrow = 2
  1190. };
  1191. } // namespace assertAction
  1192. DOCTEST_INTERFACE void failed_out_of_a_testing_context(const AssertData& ad);
  1193. DOCTEST_INTERFACE void decomp_assert(assertType::Enum at, const char* file, int line,
  1194. const char* expr, Result result);
  1195. #define DOCTEST_ASSERT_OUT_OF_TESTS(decomp) \
  1196. do { \
  1197. if(!is_running_in_test) { \
  1198. if(failed) { \
  1199. ResultBuilder rb(at, file, line, expr); \
  1200. rb.m_failed = failed; \
  1201. rb.m_decomp = decomp; \
  1202. failed_out_of_a_testing_context(rb); \
  1203. if(isDebuggerActive() && !getContextOptions()->no_breaks) \
  1204. DOCTEST_BREAK_INTO_DEBUGGER(); \
  1205. if(checkIfShouldThrow(at)) \
  1206. throwException(); \
  1207. } \
  1208. return; \
  1209. } \
  1210. } while(false)
  1211. #define DOCTEST_ASSERT_IN_TESTS(decomp) \
  1212. ResultBuilder rb(at, file, line, expr); \
  1213. rb.m_failed = failed; \
  1214. if(rb.m_failed || getContextOptions()->success) \
  1215. rb.m_decomp = decomp; \
  1216. if(rb.log()) \
  1217. DOCTEST_BREAK_INTO_DEBUGGER(); \
  1218. if(rb.m_failed && checkIfShouldThrow(at)) \
  1219. throwException()
  1220. template <int comparison, typename L, typename R>
  1221. DOCTEST_NOINLINE void binary_assert(assertType::Enum at, const char* file, int line,
  1222. const char* expr, const DOCTEST_REF_WRAP(L) lhs,
  1223. const DOCTEST_REF_WRAP(R) rhs) {
  1224. bool failed = !RelationalComparator<comparison, L, R>()(lhs, rhs);
  1225. // ###################################################################################
  1226. // IF THE DEBUGGER BREAKS HERE - GO 1 LEVEL UP IN THE CALLSTACK FOR THE FAILING ASSERT
  1227. // THIS IS THE EFFECT OF HAVING 'DOCTEST_CONFIG_SUPER_FAST_ASSERTS' DEFINED
  1228. // ###################################################################################
  1229. DOCTEST_ASSERT_OUT_OF_TESTS(stringifyBinaryExpr(lhs, ", ", rhs));
  1230. DOCTEST_ASSERT_IN_TESTS(stringifyBinaryExpr(lhs, ", ", rhs));
  1231. }
  1232. template <typename L>
  1233. DOCTEST_NOINLINE void unary_assert(assertType::Enum at, const char* file, int line,
  1234. const char* expr, const DOCTEST_REF_WRAP(L) val) {
  1235. bool failed = !val;
  1236. if(at & assertType::is_false) //!OCLINT bitwise operator in conditional
  1237. failed = !failed;
  1238. // ###################################################################################
  1239. // IF THE DEBUGGER BREAKS HERE - GO 1 LEVEL UP IN THE CALLSTACK FOR THE FAILING ASSERT
  1240. // THIS IS THE EFFECT OF HAVING 'DOCTEST_CONFIG_SUPER_FAST_ASSERTS' DEFINED
  1241. // ###################################################################################
  1242. DOCTEST_ASSERT_OUT_OF_TESTS(toString(val));
  1243. DOCTEST_ASSERT_IN_TESTS(toString(val));
  1244. }
  1245. struct DOCTEST_INTERFACE IExceptionTranslator
  1246. {
  1247. IExceptionTranslator();
  1248. virtual ~IExceptionTranslator();
  1249. virtual bool translate(String&) const = 0;
  1250. };
  1251. template <typename T>
  1252. class ExceptionTranslator : public IExceptionTranslator //!OCLINT destructor of virtual class
  1253. {
  1254. public:
  1255. explicit ExceptionTranslator(String (*translateFunction)(T))
  1256. : m_translateFunction(translateFunction) {}
  1257. bool translate(String& res) const override {
  1258. #ifndef DOCTEST_CONFIG_NO_EXCEPTIONS
  1259. try {
  1260. throw; // lgtm [cpp/rethrow-no-exception]
  1261. // cppcheck-suppress catchExceptionByValue
  1262. } catch(T ex) { // NOLINT
  1263. res = m_translateFunction(ex); //!OCLINT parameter reassignment
  1264. return true;
  1265. } catch(...) {} //!OCLINT - empty catch statement
  1266. #endif // DOCTEST_CONFIG_NO_EXCEPTIONS
  1267. static_cast<void>(res); // to silence -Wunused-parameter
  1268. return false;
  1269. }
  1270. private:
  1271. String (*m_translateFunction)(T);
  1272. };
  1273. DOCTEST_INTERFACE void registerExceptionTranslatorImpl(const IExceptionTranslator* et);
  1274. template <bool C>
  1275. struct StringStreamBase
  1276. {
  1277. template <typename T>
  1278. static void convert(std::ostream* s, const T& in) {
  1279. *s << toString(in);
  1280. }
  1281. // always treat char* as a string in this context - no matter
  1282. // if DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING is defined
  1283. static void convert(std::ostream* s, const char* in) { *s << String(in); }
  1284. };
  1285. template <>
  1286. struct StringStreamBase<true>
  1287. {
  1288. template <typename T>
  1289. static void convert(std::ostream* s, const T& in) {
  1290. *s << in;
  1291. }
  1292. };
  1293. template <typename T>
  1294. struct StringStream : public StringStreamBase<has_insertion_operator<T>::value>
  1295. {};
  1296. template <typename T>
  1297. void toStream(std::ostream* s, const T& value) {
  1298. StringStream<T>::convert(s, value);
  1299. }
  1300. #ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
  1301. DOCTEST_INTERFACE void toStream(std::ostream* s, char* in);
  1302. DOCTEST_INTERFACE void toStream(std::ostream* s, const char* in);
  1303. #endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
  1304. DOCTEST_INTERFACE void toStream(std::ostream* s, bool in);
  1305. DOCTEST_INTERFACE void toStream(std::ostream* s, float in);
  1306. DOCTEST_INTERFACE void toStream(std::ostream* s, double in);
  1307. DOCTEST_INTERFACE void toStream(std::ostream* s, double long in);
  1308. DOCTEST_INTERFACE void toStream(std::ostream* s, char in);
  1309. DOCTEST_INTERFACE void toStream(std::ostream* s, char signed in);
  1310. DOCTEST_INTERFACE void toStream(std::ostream* s, char unsigned in);
  1311. DOCTEST_INTERFACE void toStream(std::ostream* s, int short in);
  1312. DOCTEST_INTERFACE void toStream(std::ostream* s, int short unsigned in);
  1313. DOCTEST_INTERFACE void toStream(std::ostream* s, int in);
  1314. DOCTEST_INTERFACE void toStream(std::ostream* s, int unsigned in);
  1315. DOCTEST_INTERFACE void toStream(std::ostream* s, int long in);
  1316. DOCTEST_INTERFACE void toStream(std::ostream* s, int long unsigned in);
  1317. DOCTEST_INTERFACE void toStream(std::ostream* s, int long long in);
  1318. DOCTEST_INTERFACE void toStream(std::ostream* s, int long long unsigned in);
  1319. // ContextScope base class used to allow implementing methods of ContextScope
  1320. // that don't depend on the template parameter in doctest.cpp.
  1321. class DOCTEST_INTERFACE ContextScopeBase : public IContextScope {
  1322. protected:
  1323. ContextScopeBase();
  1324. void destroy();
  1325. };
  1326. template <typename L> class ContextScope : public ContextScopeBase
  1327. {
  1328. const L lambda_;
  1329. public:
  1330. explicit ContextScope(const L &lambda) : lambda_(lambda) {}
  1331. ContextScope(ContextScope &&other) : lambda_(other.lambda_) {}
  1332. void stringify(std::ostream* s) const override { lambda_(s); }
  1333. ~ContextScope() override { destroy(); }
  1334. };
  1335. struct DOCTEST_INTERFACE MessageBuilder : public MessageData
  1336. {
  1337. std::ostream* m_stream;
  1338. MessageBuilder(const char* file, int line, assertType::Enum severity);
  1339. MessageBuilder() = delete;
  1340. ~MessageBuilder();
  1341. // the preferred way of chaining parameters for stringification
  1342. template <typename T>
  1343. MessageBuilder& operator,(const T& in) {
  1344. toStream(m_stream, in);
  1345. return *this;
  1346. }
  1347. // kept here just for backwards-compatibility - the comma operator should be preferred now
  1348. template <typename T>
  1349. MessageBuilder& operator<<(const T& in) { return this->operator,(in); }
  1350. // the `,` operator has the lowest operator precedence - if `<<` is used by the user then
  1351. // the `,` operator will be called last which is not what we want and thus the `*` operator
  1352. // is used first (has higher operator precedence compared to `<<`) so that we guarantee that
  1353. // an operator of the MessageBuilder class is called first before the rest of the parameters
  1354. template <typename T>
  1355. MessageBuilder& operator*(const T& in) { return this->operator,(in); }
  1356. bool log();
  1357. void react();
  1358. };
  1359. template <typename L>
  1360. ContextScope<L> MakeContextScope(const L &lambda) {
  1361. return ContextScope<L>(lambda);
  1362. }
  1363. } // namespace detail
  1364. #define DOCTEST_DEFINE_DECORATOR(name, type, def) \
  1365. struct name \
  1366. { \
  1367. type data; \
  1368. name(type in = def) \
  1369. : data(in) {} \
  1370. void fill(detail::TestCase& state) const { state.DOCTEST_CAT(m_, name) = data; } \
  1371. void fill(detail::TestSuite& state) const { state.DOCTEST_CAT(m_, name) = data; } \
  1372. }
  1373. DOCTEST_DEFINE_DECORATOR(test_suite, const char*, "");
  1374. DOCTEST_DEFINE_DECORATOR(description, const char*, "");
  1375. DOCTEST_DEFINE_DECORATOR(skip, bool, true);
  1376. DOCTEST_DEFINE_DECORATOR(no_breaks, bool, true);
  1377. DOCTEST_DEFINE_DECORATOR(no_output, bool, true);
  1378. DOCTEST_DEFINE_DECORATOR(timeout, double, 0);
  1379. DOCTEST_DEFINE_DECORATOR(may_fail, bool, true);
  1380. DOCTEST_DEFINE_DECORATOR(should_fail, bool, true);
  1381. DOCTEST_DEFINE_DECORATOR(expected_failures, int, 0);
  1382. template <typename T>
  1383. int registerExceptionTranslator(String (*translateFunction)(T)) {
  1384. DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wexit-time-destructors")
  1385. static detail::ExceptionTranslator<T> exceptionTranslator(translateFunction);
  1386. DOCTEST_CLANG_SUPPRESS_WARNING_POP
  1387. detail::registerExceptionTranslatorImpl(&exceptionTranslator);
  1388. return 0;
  1389. }
  1390. } // namespace doctest
  1391. // in a separate namespace outside of doctest because the DOCTEST_TEST_SUITE macro
  1392. // introduces an anonymous namespace in which getCurrentTestSuite gets overridden
  1393. namespace doctest_detail_test_suite_ns {
  1394. DOCTEST_INTERFACE doctest::detail::TestSuite& getCurrentTestSuite();
  1395. } // namespace doctest_detail_test_suite_ns
  1396. namespace doctest {
  1397. #else // DOCTEST_CONFIG_DISABLE
  1398. template <typename T>
  1399. int registerExceptionTranslator(String (*)(T)) {
  1400. return 0;
  1401. }
  1402. #endif // DOCTEST_CONFIG_DISABLE
  1403. namespace detail {
  1404. typedef void (*assert_handler)(const AssertData&);
  1405. struct ContextState;
  1406. } // namespace detail
  1407. class DOCTEST_INTERFACE Context
  1408. {
  1409. detail::ContextState* p;
  1410. void parseArgs(int argc, const char* const* argv, bool withDefaults = false);
  1411. public:
  1412. explicit Context(int argc = 0, const char* const* argv = nullptr);
  1413. ~Context();
  1414. void applyCommandLine(int argc, const char* const* argv);
  1415. void addFilter(const char* filter, const char* value);
  1416. void clearFilters();
  1417. void setOption(const char* option, int value);
  1418. void setOption(const char* option, const char* value);
  1419. bool shouldExit();
  1420. void setAsDefaultForAssertsOutOfTestCases();
  1421. void setAssertHandler(detail::assert_handler ah);
  1422. int run();
  1423. };
  1424. namespace TestCaseFailureReason {
  1425. enum Enum
  1426. {
  1427. None = 0,
  1428. AssertFailure = 1, // an assertion has failed in the test case
  1429. Exception = 2, // test case threw an exception
  1430. Crash = 4, // a crash...
  1431. TooManyFailedAsserts = 8, // the abort-after option
  1432. Timeout = 16, // see the timeout decorator
  1433. ShouldHaveFailedButDidnt = 32, // see the should_fail decorator
  1434. ShouldHaveFailedAndDid = 64, // see the should_fail decorator
  1435. DidntFailExactlyNumTimes = 128, // see the expected_failures decorator
  1436. FailedExactlyNumTimes = 256, // see the expected_failures decorator
  1437. CouldHaveFailedAndDid = 512 // see the may_fail decorator
  1438. };
  1439. } // namespace TestCaseFailureReason
  1440. struct DOCTEST_INTERFACE CurrentTestCaseStats
  1441. {
  1442. int numAssertsCurrentTest;
  1443. int numAssertsFailedCurrentTest;
  1444. double seconds;
  1445. int failure_flags; // use TestCaseFailureReason::Enum
  1446. };
  1447. struct DOCTEST_INTERFACE TestCaseException
  1448. {
  1449. String error_string;
  1450. bool is_crash;
  1451. };
  1452. struct DOCTEST_INTERFACE TestRunStats
  1453. {
  1454. unsigned numTestCases;
  1455. unsigned numTestCasesPassingFilters;
  1456. unsigned numTestSuitesPassingFilters;
  1457. unsigned numTestCasesFailed;
  1458. int numAsserts;
  1459. int numAssertsFailed;
  1460. };
  1461. struct QueryData
  1462. {
  1463. const TestRunStats* run_stats = nullptr;
  1464. const TestCaseData** data = nullptr;
  1465. unsigned num_data = 0;
  1466. };
  1467. struct DOCTEST_INTERFACE IReporter
  1468. {
  1469. // The constructor has to accept "const ContextOptions&" as a single argument
  1470. // which has most of the options for the run + a pointer to the stdout stream
  1471. // Reporter(const ContextOptions& in)
  1472. // called when a query should be reported (listing test cases, printing the version, etc.)
  1473. virtual void report_query(const QueryData&) = 0;
  1474. // called when the whole test run starts
  1475. virtual void test_run_start() = 0;
  1476. // called when the whole test run ends (caching a pointer to the input doesn't make sense here)
  1477. virtual void test_run_end(const TestRunStats&) = 0;
  1478. // called when a test case is started (safe to cache a pointer to the input)
  1479. virtual void test_case_start(const TestCaseData&) = 0;
  1480. // called when a test case is reentered because of unfinished subcases (safe to cache a pointer to the input)
  1481. virtual void test_case_reenter(const TestCaseData&) = 0;
  1482. // called when a test case has ended
  1483. virtual void test_case_end(const CurrentTestCaseStats&) = 0;
  1484. // called when an exception is thrown from the test case (or it crashes)
  1485. virtual void test_case_exception(const TestCaseException&) = 0;
  1486. // called whenever a subcase is entered (don't cache pointers to the input)
  1487. virtual void subcase_start(const SubcaseSignature&) = 0;
  1488. // called whenever a subcase is exited (don't cache pointers to the input)
  1489. virtual void subcase_end() = 0;
  1490. // called for each assert (don't cache pointers to the input)
  1491. virtual void log_assert(const AssertData&) = 0;
  1492. // called for each message (don't cache pointers to the input)
  1493. virtual void log_message(const MessageData&) = 0;
  1494. // called when a test case is skipped either because it doesn't pass the filters, has a skip decorator
  1495. // or isn't in the execution range (between first and last) (safe to cache a pointer to the input)
  1496. virtual void test_case_skipped(const TestCaseData&) = 0;
  1497. // doctest will not be managing the lifetimes of reporters given to it but this would still be nice to have
  1498. virtual ~IReporter();
  1499. // can obtain all currently active contexts and stringify them if one wishes to do so
  1500. static int get_num_active_contexts();
  1501. static const IContextScope* const* get_active_contexts();
  1502. // can iterate through contexts which have been stringified automatically in their destructors when an exception has been thrown
  1503. static int get_num_stringified_contexts();
  1504. static const String* get_stringified_contexts();
  1505. };
  1506. namespace detail {
  1507. typedef IReporter* (*reporterCreatorFunc)(const ContextOptions&);
  1508. DOCTEST_INTERFACE void registerReporterImpl(const char* name, int prio, reporterCreatorFunc c, bool isReporter);
  1509. template <typename Reporter>
  1510. IReporter* reporterCreator(const ContextOptions& o) {
  1511. return new Reporter(o);
  1512. }
  1513. } // namespace detail
  1514. template <typename Reporter>
  1515. int registerReporter(const char* name, int priority, bool isReporter) {
  1516. detail::registerReporterImpl(name, priority, detail::reporterCreator<Reporter>, isReporter);
  1517. return 0;
  1518. }
  1519. } // namespace doctest
  1520. // if registering is not disabled
  1521. #if !defined(DOCTEST_CONFIG_DISABLE)
  1522. // common code in asserts - for convenience
  1523. #define DOCTEST_ASSERT_LOG_AND_REACT(b) \
  1524. if(b.log()) \
  1525. DOCTEST_BREAK_INTO_DEBUGGER(); \
  1526. b.react()
  1527. #ifdef DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS
  1528. #define DOCTEST_WRAP_IN_TRY(x) x;
  1529. #else // DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS
  1530. #define DOCTEST_WRAP_IN_TRY(x) \
  1531. try { \
  1532. x; \
  1533. } catch(...) { _DOCTEST_RB.translateException(); }
  1534. #endif // DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS
  1535. #ifdef DOCTEST_CONFIG_VOID_CAST_EXPRESSIONS
  1536. #define DOCTEST_CAST_TO_VOID(...) \
  1537. DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wuseless-cast") \
  1538. static_cast<void>(__VA_ARGS__); \
  1539. DOCTEST_GCC_SUPPRESS_WARNING_POP
  1540. #else // DOCTEST_CONFIG_VOID_CAST_EXPRESSIONS
  1541. #define DOCTEST_CAST_TO_VOID(...) __VA_ARGS__;
  1542. #endif // DOCTEST_CONFIG_VOID_CAST_EXPRESSIONS
  1543. // registers the test by initializing a dummy var with a function
  1544. #define DOCTEST_REGISTER_FUNCTION(global_prefix, f, decorators) \
  1545. global_prefix DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_VAR_)) = \
  1546. doctest::detail::regTest( \
  1547. doctest::detail::TestCase( \
  1548. f, __FILE__, __LINE__, \
  1549. doctest_detail_test_suite_ns::getCurrentTestSuite()) * \
  1550. decorators); \
  1551. DOCTEST_GLOBAL_NO_WARNINGS_END()
  1552. #define DOCTEST_IMPLEMENT_FIXTURE(der, base, func, decorators) \
  1553. namespace { \
  1554. struct der : public base \
  1555. { \
  1556. void f(); \
  1557. }; \
  1558. static void func() { \
  1559. der v; \
  1560. v.f(); \
  1561. } \
  1562. DOCTEST_REGISTER_FUNCTION(DOCTEST_EMPTY, func, decorators) \
  1563. } \
  1564. inline DOCTEST_NOINLINE void der::f()
  1565. #define DOCTEST_CREATE_AND_REGISTER_FUNCTION(f, decorators) \
  1566. static void f(); \
  1567. DOCTEST_REGISTER_FUNCTION(DOCTEST_EMPTY, f, decorators) \
  1568. static void f()
  1569. #define DOCTEST_CREATE_AND_REGISTER_FUNCTION_IN_CLASS(f, proxy, decorators) \
  1570. static doctest::detail::funcType proxy() { return f; } \
  1571. DOCTEST_REGISTER_FUNCTION(inline const, proxy(), decorators) \
  1572. static void f()
  1573. // for registering tests
  1574. #define DOCTEST_TEST_CASE(decorators) \
  1575. DOCTEST_CREATE_AND_REGISTER_FUNCTION(DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), decorators)
  1576. // for registering tests in classes - requires C++17 for inline variables!
  1577. #if __cplusplus >= 201703L || (DOCTEST_MSVC >= DOCTEST_COMPILER(19, 12, 0) && _MSVC_LANG >= 201703L)
  1578. #define DOCTEST_TEST_CASE_CLASS(decorators) \
  1579. DOCTEST_CREATE_AND_REGISTER_FUNCTION_IN_CLASS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), \
  1580. DOCTEST_ANONYMOUS(_DOCTEST_ANON_PROXY_), \
  1581. decorators)
  1582. #else // DOCTEST_TEST_CASE_CLASS
  1583. #define DOCTEST_TEST_CASE_CLASS(...) \
  1584. TEST_CASES_CAN_BE_REGISTERED_IN_CLASSES_ONLY_IN_CPP17_MODE_OR_WITH_VS_2017_OR_NEWER
  1585. #endif // DOCTEST_TEST_CASE_CLASS
  1586. // for registering tests with a fixture
  1587. #define DOCTEST_TEST_CASE_FIXTURE(c, decorators) \
  1588. DOCTEST_IMPLEMENT_FIXTURE(DOCTEST_ANONYMOUS(_DOCTEST_ANON_CLASS_), c, \
  1589. DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), decorators)
  1590. // for converting types to strings without the <typeinfo> header and demangling
  1591. #define DOCTEST_TYPE_TO_STRING_IMPL(...) \
  1592. template <> \
  1593. inline const char* type_to_string<__VA_ARGS__>() { \
  1594. return "<" #__VA_ARGS__ ">"; \
  1595. }
  1596. #define DOCTEST_TYPE_TO_STRING(...) \
  1597. namespace doctest { namespace detail { \
  1598. DOCTEST_TYPE_TO_STRING_IMPL(__VA_ARGS__) \
  1599. } \
  1600. } \
  1601. typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
  1602. #define DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, iter, func) \
  1603. template <typename T> \
  1604. static void func(); \
  1605. namespace { \
  1606. template <typename Tuple> \
  1607. struct iter; \
  1608. template <typename Type, typename... Rest> \
  1609. struct iter<std::tuple<Type, Rest...>> \
  1610. { \
  1611. iter(const char* file, unsigned line, int index) { \
  1612. doctest::detail::regTest(doctest::detail::TestCase(func<Type>, file, line, \
  1613. doctest_detail_test_suite_ns::getCurrentTestSuite(), \
  1614. doctest::detail::type_to_string<Type>(), \
  1615. int(line) * 1000 + index) \
  1616. * dec); \
  1617. iter<std::tuple<Rest...>>(file, line, index + 1); \
  1618. } \
  1619. }; \
  1620. template <> \
  1621. struct iter<std::tuple<>> \
  1622. { \
  1623. iter(const char*, unsigned, int) {} \
  1624. }; \
  1625. } \
  1626. template <typename T> \
  1627. static void func()
  1628. #define DOCTEST_TEST_CASE_TEMPLATE_DEFINE(dec, T, id) \
  1629. DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, DOCTEST_CAT(id, ITERATOR), \
  1630. DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_))
  1631. #define DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(id, anon, ...) \
  1632. DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_CAT(anon, DUMMY)) = \
  1633. doctest::detail::instantiationHelper(DOCTEST_CAT(id, ITERATOR)<__VA_ARGS__>(__FILE__, __LINE__, 0));\
  1634. DOCTEST_GLOBAL_NO_WARNINGS_END()
  1635. #define DOCTEST_TEST_CASE_TEMPLATE_INVOKE(id, ...) \
  1636. DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(id, DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_), std::tuple<__VA_ARGS__>) \
  1637. typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
  1638. #define DOCTEST_TEST_CASE_TEMPLATE_APPLY(id, ...) \
  1639. DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(id, DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_), __VA_ARGS__) \
  1640. typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
  1641. #define DOCTEST_TEST_CASE_TEMPLATE_IMPL(dec, T, anon, ...) \
  1642. DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, DOCTEST_CAT(anon, ITERATOR), anon); \
  1643. DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(anon, anon, std::tuple<__VA_ARGS__>) \
  1644. template <typename T> \
  1645. static void anon()
  1646. #define DOCTEST_TEST_CASE_TEMPLATE(dec, T, ...) \
  1647. DOCTEST_TEST_CASE_TEMPLATE_IMPL(dec, T, DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_), __VA_ARGS__)
  1648. // for subcases
  1649. #define DOCTEST_SUBCASE(name) \
  1650. if(const doctest::detail::Subcase & DOCTEST_ANONYMOUS(_DOCTEST_ANON_SUBCASE_) DOCTEST_UNUSED = \
  1651. doctest::detail::Subcase(name, __FILE__, __LINE__))
  1652. // for grouping tests in test suites by using code blocks
  1653. #define DOCTEST_TEST_SUITE_IMPL(decorators, ns_name) \
  1654. namespace ns_name { namespace doctest_detail_test_suite_ns { \
  1655. static DOCTEST_NOINLINE doctest::detail::TestSuite& getCurrentTestSuite() { \
  1656. DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4640) \
  1657. DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wexit-time-destructors") \
  1658. DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wmissing-field-initializers") \
  1659. static doctest::detail::TestSuite data{}; \
  1660. static bool inited = false; \
  1661. DOCTEST_MSVC_SUPPRESS_WARNING_POP \
  1662. DOCTEST_CLANG_SUPPRESS_WARNING_POP \
  1663. DOCTEST_GCC_SUPPRESS_WARNING_POP \
  1664. if(!inited) { \
  1665. data* decorators; \
  1666. inited = true; \
  1667. } \
  1668. return data; \
  1669. } \
  1670. } \
  1671. } \
  1672. namespace ns_name
  1673. #define DOCTEST_TEST_SUITE(decorators) \
  1674. DOCTEST_TEST_SUITE_IMPL(decorators, DOCTEST_ANONYMOUS(_DOCTEST_ANON_SUITE_))
  1675. // for starting a testsuite block
  1676. #define DOCTEST_TEST_SUITE_BEGIN(decorators) \
  1677. DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_VAR_)) = \
  1678. doctest::detail::setTestSuite(doctest::detail::TestSuite() * decorators); \
  1679. DOCTEST_GLOBAL_NO_WARNINGS_END() \
  1680. typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
  1681. // for ending a testsuite block
  1682. #define DOCTEST_TEST_SUITE_END \
  1683. DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_VAR_)) = \
  1684. doctest::detail::setTestSuite(doctest::detail::TestSuite() * ""); \
  1685. DOCTEST_GLOBAL_NO_WARNINGS_END() \
  1686. typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
  1687. // for registering exception translators
  1688. #define DOCTEST_REGISTER_EXCEPTION_TRANSLATOR_IMPL(translatorName, signature) \
  1689. inline doctest::String translatorName(signature); \
  1690. DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_TRANSLATOR_)) = \
  1691. doctest::registerExceptionTranslator(translatorName); \
  1692. DOCTEST_GLOBAL_NO_WARNINGS_END() \
  1693. doctest::String translatorName(signature)
  1694. #define DOCTEST_REGISTER_EXCEPTION_TRANSLATOR(signature) \
  1695. DOCTEST_REGISTER_EXCEPTION_TRANSLATOR_IMPL(DOCTEST_ANONYMOUS(_DOCTEST_ANON_TRANSLATOR_), \
  1696. signature)
  1697. // for registering reporters
  1698. #define DOCTEST_REGISTER_REPORTER(name, priority, reporter) \
  1699. DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_REPORTER_)) = \
  1700. doctest::registerReporter<reporter>(name, priority, true); \
  1701. DOCTEST_GLOBAL_NO_WARNINGS_END() typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
  1702. // for registering listeners
  1703. #define DOCTEST_REGISTER_LISTENER(name, priority, reporter) \
  1704. DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(_DOCTEST_ANON_REPORTER_)) = \
  1705. doctest::registerReporter<reporter>(name, priority, false); \
  1706. DOCTEST_GLOBAL_NO_WARNINGS_END() typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
  1707. // for logging
  1708. #define DOCTEST_INFO(...) \
  1709. DOCTEST_INFO_IMPL(DOCTEST_ANONYMOUS(_DOCTEST_CAPTURE_), DOCTEST_ANONYMOUS(_DOCTEST_CAPTURE_), \
  1710. __VA_ARGS__)
  1711. #define DOCTEST_INFO_IMPL(mb_name, s_name, ...) \
  1712. auto DOCTEST_ANONYMOUS(_DOCTEST_CAPTURE_) = doctest::detail::MakeContextScope( \
  1713. [&](std::ostream* s_name) { \
  1714. doctest::detail::MessageBuilder mb_name(__FILE__, __LINE__, doctest::assertType::is_warn); \
  1715. mb_name.m_stream = s_name; \
  1716. mb_name * __VA_ARGS__; \
  1717. })
  1718. #define DOCTEST_CAPTURE(x) DOCTEST_INFO(#x " := ", x)
  1719. #define DOCTEST_ADD_AT_IMPL(type, file, line, mb, ...) \
  1720. do { \
  1721. doctest::detail::MessageBuilder mb(file, line, doctest::assertType::type); \
  1722. mb * __VA_ARGS__; \
  1723. DOCTEST_ASSERT_LOG_AND_REACT(mb); \
  1724. } while(false)
  1725. // clang-format off
  1726. #define DOCTEST_ADD_MESSAGE_AT(file, line, ...) DOCTEST_ADD_AT_IMPL(is_warn, file, line, DOCTEST_ANONYMOUS(_DOCTEST_MESSAGE_), __VA_ARGS__)
  1727. #define DOCTEST_ADD_FAIL_CHECK_AT(file, line, ...) DOCTEST_ADD_AT_IMPL(is_check, file, line, DOCTEST_ANONYMOUS(_DOCTEST_MESSAGE_), __VA_ARGS__)
  1728. #define DOCTEST_ADD_FAIL_AT(file, line, ...) DOCTEST_ADD_AT_IMPL(is_require, file, line, DOCTEST_ANONYMOUS(_DOCTEST_MESSAGE_), __VA_ARGS__)
  1729. // clang-format on
  1730. #define DOCTEST_MESSAGE(...) DOCTEST_ADD_MESSAGE_AT(__FILE__, __LINE__, __VA_ARGS__)
  1731. #define DOCTEST_FAIL_CHECK(...) DOCTEST_ADD_FAIL_CHECK_AT(__FILE__, __LINE__, __VA_ARGS__)
  1732. #define DOCTEST_FAIL(...) DOCTEST_ADD_FAIL_AT(__FILE__, __LINE__, __VA_ARGS__)
  1733. #define DOCTEST_TO_LVALUE(...) __VA_ARGS__ // Not removed to keep backwards compatibility.
  1734. #ifndef DOCTEST_CONFIG_SUPER_FAST_ASSERTS
  1735. #define DOCTEST_ASSERT_IMPLEMENT_2(assert_type, ...) \
  1736. DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Woverloaded-shift-op-parentheses") \
  1737. doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \
  1738. __LINE__, #__VA_ARGS__); \
  1739. DOCTEST_WRAP_IN_TRY(_DOCTEST_RB.setResult( \
  1740. doctest::detail::ExpressionDecomposer(doctest::assertType::assert_type) \
  1741. << __VA_ARGS__)) \
  1742. DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB) \
  1743. DOCTEST_CLANG_SUPPRESS_WARNING_POP
  1744. #define DOCTEST_ASSERT_IMPLEMENT_1(assert_type, ...) \
  1745. do { \
  1746. DOCTEST_ASSERT_IMPLEMENT_2(assert_type, __VA_ARGS__); \
  1747. } while(false)
  1748. #else // DOCTEST_CONFIG_SUPER_FAST_ASSERTS
  1749. // necessary for <ASSERT>_MESSAGE
  1750. #define DOCTEST_ASSERT_IMPLEMENT_2 DOCTEST_ASSERT_IMPLEMENT_1
  1751. #define DOCTEST_ASSERT_IMPLEMENT_1(assert_type, ...) \
  1752. DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Woverloaded-shift-op-parentheses") \
  1753. doctest::detail::decomp_assert( \
  1754. doctest::assertType::assert_type, __FILE__, __LINE__, #__VA_ARGS__, \
  1755. doctest::detail::ExpressionDecomposer(doctest::assertType::assert_type) \
  1756. << __VA_ARGS__) DOCTEST_CLANG_SUPPRESS_WARNING_POP
  1757. #endif // DOCTEST_CONFIG_SUPER_FAST_ASSERTS
  1758. #define DOCTEST_WARN(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_WARN, __VA_ARGS__)
  1759. #define DOCTEST_CHECK(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_CHECK, __VA_ARGS__)
  1760. #define DOCTEST_REQUIRE(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_REQUIRE, __VA_ARGS__)
  1761. #define DOCTEST_WARN_FALSE(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_WARN_FALSE, __VA_ARGS__)
  1762. #define DOCTEST_CHECK_FALSE(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_CHECK_FALSE, __VA_ARGS__)
  1763. #define DOCTEST_REQUIRE_FALSE(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_REQUIRE_FALSE, __VA_ARGS__)
  1764. // clang-format off
  1765. #define DOCTEST_WARN_MESSAGE(cond, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_ASSERT_IMPLEMENT_2(DT_WARN, cond); } while(false)
  1766. #define DOCTEST_CHECK_MESSAGE(cond, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_ASSERT_IMPLEMENT_2(DT_CHECK, cond); } while(false)
  1767. #define DOCTEST_REQUIRE_MESSAGE(cond, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_ASSERT_IMPLEMENT_2(DT_REQUIRE, cond); } while(false)
  1768. #define DOCTEST_WARN_FALSE_MESSAGE(cond, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_ASSERT_IMPLEMENT_2(DT_WARN_FALSE, cond); } while(false)
  1769. #define DOCTEST_CHECK_FALSE_MESSAGE(cond, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_ASSERT_IMPLEMENT_2(DT_CHECK_FALSE, cond); } while(false)
  1770. #define DOCTEST_REQUIRE_FALSE_MESSAGE(cond, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_ASSERT_IMPLEMENT_2(DT_REQUIRE_FALSE, cond); } while(false)
  1771. // clang-format on
  1772. #define DOCTEST_ASSERT_THROWS_AS(expr, assert_type, message, ...) \
  1773. do { \
  1774. if(!doctest::getContextOptions()->no_throw) { \
  1775. doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \
  1776. __LINE__, #expr, #__VA_ARGS__, message); \
  1777. try { \
  1778. DOCTEST_CAST_TO_VOID(expr) \
  1779. } catch(const typename doctest::detail::remove_const< \
  1780. typename doctest::detail::remove_reference<__VA_ARGS__>::type>::type&) { \
  1781. _DOCTEST_RB.translateException(); \
  1782. _DOCTEST_RB.m_threw_as = true; \
  1783. } catch(...) { _DOCTEST_RB.translateException(); } \
  1784. DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \
  1785. } \
  1786. } while(false)
  1787. #define DOCTEST_ASSERT_THROWS_WITH(expr, expr_str, assert_type, ...) \
  1788. do { \
  1789. if(!doctest::getContextOptions()->no_throw) { \
  1790. doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \
  1791. __LINE__, expr_str, "", __VA_ARGS__); \
  1792. try { \
  1793. DOCTEST_CAST_TO_VOID(expr) \
  1794. } catch(...) { _DOCTEST_RB.translateException(); } \
  1795. DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \
  1796. } \
  1797. } while(false)
  1798. #define DOCTEST_ASSERT_NOTHROW(assert_type, ...) \
  1799. do { \
  1800. doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \
  1801. __LINE__, #__VA_ARGS__); \
  1802. try { \
  1803. DOCTEST_CAST_TO_VOID(__VA_ARGS__) \
  1804. } catch(...) { _DOCTEST_RB.translateException(); } \
  1805. DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \
  1806. } while(false)
  1807. // clang-format off
  1808. #define DOCTEST_WARN_THROWS(...) DOCTEST_ASSERT_THROWS_WITH((__VA_ARGS__), #__VA_ARGS__, DT_WARN_THROWS, "")
  1809. #define DOCTEST_CHECK_THROWS(...) DOCTEST_ASSERT_THROWS_WITH((__VA_ARGS__), #__VA_ARGS__, DT_CHECK_THROWS, "")
  1810. #define DOCTEST_REQUIRE_THROWS(...) DOCTEST_ASSERT_THROWS_WITH((__VA_ARGS__), #__VA_ARGS__, DT_REQUIRE_THROWS, "")
  1811. #define DOCTEST_WARN_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_WARN_THROWS_AS, "", __VA_ARGS__)
  1812. #define DOCTEST_CHECK_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_CHECK_THROWS_AS, "", __VA_ARGS__)
  1813. #define DOCTEST_REQUIRE_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_REQUIRE_THROWS_AS, "", __VA_ARGS__)
  1814. #define DOCTEST_WARN_THROWS_WITH(expr, ...) DOCTEST_ASSERT_THROWS_WITH(expr, #expr, DT_WARN_THROWS_WITH, __VA_ARGS__)
  1815. #define DOCTEST_CHECK_THROWS_WITH(expr, ...) DOCTEST_ASSERT_THROWS_WITH(expr, #expr, DT_CHECK_THROWS_WITH, __VA_ARGS__)
  1816. #define DOCTEST_REQUIRE_THROWS_WITH(expr, ...) DOCTEST_ASSERT_THROWS_WITH(expr, #expr, DT_REQUIRE_THROWS_WITH, __VA_ARGS__)
  1817. #define DOCTEST_WARN_THROWS_WITH_AS(expr, message, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_WARN_THROWS_WITH_AS, message, __VA_ARGS__)
  1818. #define DOCTEST_CHECK_THROWS_WITH_AS(expr, message, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_CHECK_THROWS_WITH_AS, message, __VA_ARGS__)
  1819. #define DOCTEST_REQUIRE_THROWS_WITH_AS(expr, message, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_REQUIRE_THROWS_WITH_AS, message, __VA_ARGS__)
  1820. #define DOCTEST_WARN_NOTHROW(...) DOCTEST_ASSERT_NOTHROW(DT_WARN_NOTHROW, __VA_ARGS__)
  1821. #define DOCTEST_CHECK_NOTHROW(...) DOCTEST_ASSERT_NOTHROW(DT_CHECK_NOTHROW, __VA_ARGS__)
  1822. #define DOCTEST_REQUIRE_NOTHROW(...) DOCTEST_ASSERT_NOTHROW(DT_REQUIRE_NOTHROW, __VA_ARGS__)
  1823. #define DOCTEST_WARN_THROWS_MESSAGE(expr, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_WARN_THROWS(expr); } while(false)
  1824. #define DOCTEST_CHECK_THROWS_MESSAGE(expr, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_CHECK_THROWS(expr); } while(false)
  1825. #define DOCTEST_REQUIRE_THROWS_MESSAGE(expr, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_REQUIRE_THROWS(expr); } while(false)
  1826. #define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_WARN_THROWS_AS(expr, ex); } while(false)
  1827. #define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_CHECK_THROWS_AS(expr, ex); } while(false)
  1828. #define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_REQUIRE_THROWS_AS(expr, ex); } while(false)
  1829. #define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, with, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_WARN_THROWS_WITH(expr, with); } while(false)
  1830. #define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, with, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_CHECK_THROWS_WITH(expr, with); } while(false)
  1831. #define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, with, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_REQUIRE_THROWS_WITH(expr, with); } while(false)
  1832. #define DOCTEST_WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_WARN_THROWS_WITH_AS(expr, with, ex); } while(false)
  1833. #define DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_CHECK_THROWS_WITH_AS(expr, with, ex); } while(false)
  1834. #define DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_REQUIRE_THROWS_WITH_AS(expr, with, ex); } while(false)
  1835. #define DOCTEST_WARN_NOTHROW_MESSAGE(expr, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_WARN_NOTHROW(expr); } while(false)
  1836. #define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_CHECK_NOTHROW(expr); } while(false)
  1837. #define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, ...) do { DOCTEST_INFO(__VA_ARGS__); DOCTEST_REQUIRE_NOTHROW(expr); } while(false)
  1838. // clang-format on
  1839. #ifndef DOCTEST_CONFIG_SUPER_FAST_ASSERTS
  1840. #define DOCTEST_BINARY_ASSERT(assert_type, comp, ...) \
  1841. do { \
  1842. doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \
  1843. __LINE__, #__VA_ARGS__); \
  1844. DOCTEST_WRAP_IN_TRY( \
  1845. _DOCTEST_RB.binary_assert<doctest::detail::binaryAssertComparison::comp>( \
  1846. __VA_ARGS__)) \
  1847. DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \
  1848. } while(false)
  1849. #define DOCTEST_UNARY_ASSERT(assert_type, ...) \
  1850. do { \
  1851. doctest::detail::ResultBuilder _DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \
  1852. __LINE__, #__VA_ARGS__); \
  1853. DOCTEST_WRAP_IN_TRY(_DOCTEST_RB.unary_assert(__VA_ARGS__)) \
  1854. DOCTEST_ASSERT_LOG_AND_REACT(_DOCTEST_RB); \
  1855. } while(false)
  1856. #else // DOCTEST_CONFIG_SUPER_FAST_ASSERTS
  1857. #define DOCTEST_BINARY_ASSERT(assert_type, comparison, ...) \
  1858. doctest::detail::binary_assert<doctest::detail::binaryAssertComparison::comparison>( \
  1859. doctest::assertType::assert_type, __FILE__, __LINE__, #__VA_ARGS__, __VA_ARGS__)
  1860. #define DOCTEST_UNARY_ASSERT(assert_type, ...) \
  1861. doctest::detail::unary_assert(doctest::assertType::assert_type, __FILE__, __LINE__, \
  1862. #__VA_ARGS__, __VA_ARGS__)
  1863. #endif // DOCTEST_CONFIG_SUPER_FAST_ASSERTS
  1864. #define DOCTEST_WARN_EQ(...) DOCTEST_BINARY_ASSERT(DT_WARN_EQ, eq, __VA_ARGS__)
  1865. #define DOCTEST_CHECK_EQ(...) DOCTEST_BINARY_ASSERT(DT_CHECK_EQ, eq, __VA_ARGS__)
  1866. #define DOCTEST_REQUIRE_EQ(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_EQ, eq, __VA_ARGS__)
  1867. #define DOCTEST_WARN_NE(...) DOCTEST_BINARY_ASSERT(DT_WARN_NE, ne, __VA_ARGS__)
  1868. #define DOCTEST_CHECK_NE(...) DOCTEST_BINARY_ASSERT(DT_CHECK_NE, ne, __VA_ARGS__)
  1869. #define DOCTEST_REQUIRE_NE(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_NE, ne, __VA_ARGS__)
  1870. #define DOCTEST_WARN_GT(...) DOCTEST_BINARY_ASSERT(DT_WARN_GT, gt, __VA_ARGS__)
  1871. #define DOCTEST_CHECK_GT(...) DOCTEST_BINARY_ASSERT(DT_CHECK_GT, gt, __VA_ARGS__)
  1872. #define DOCTEST_REQUIRE_GT(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_GT, gt, __VA_ARGS__)
  1873. #define DOCTEST_WARN_LT(...) DOCTEST_BINARY_ASSERT(DT_WARN_LT, lt, __VA_ARGS__)
  1874. #define DOCTEST_CHECK_LT(...) DOCTEST_BINARY_ASSERT(DT_CHECK_LT, lt, __VA_ARGS__)
  1875. #define DOCTEST_REQUIRE_LT(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_LT, lt, __VA_ARGS__)
  1876. #define DOCTEST_WARN_GE(...) DOCTEST_BINARY_ASSERT(DT_WARN_GE, ge, __VA_ARGS__)
  1877. #define DOCTEST_CHECK_GE(...) DOCTEST_BINARY_ASSERT(DT_CHECK_GE, ge, __VA_ARGS__)
  1878. #define DOCTEST_REQUIRE_GE(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_GE, ge, __VA_ARGS__)
  1879. #define DOCTEST_WARN_LE(...) DOCTEST_BINARY_ASSERT(DT_WARN_LE, le, __VA_ARGS__)
  1880. #define DOCTEST_CHECK_LE(...) DOCTEST_BINARY_ASSERT(DT_CHECK_LE, le, __VA_ARGS__)
  1881. #define DOCTEST_REQUIRE_LE(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_LE, le, __VA_ARGS__)
  1882. #define DOCTEST_WARN_UNARY(...) DOCTEST_UNARY_ASSERT(DT_WARN_UNARY, __VA_ARGS__)
  1883. #define DOCTEST_CHECK_UNARY(...) DOCTEST_UNARY_ASSERT(DT_CHECK_UNARY, __VA_ARGS__)
  1884. #define DOCTEST_REQUIRE_UNARY(...) DOCTEST_UNARY_ASSERT(DT_REQUIRE_UNARY, __VA_ARGS__)
  1885. #define DOCTEST_WARN_UNARY_FALSE(...) DOCTEST_UNARY_ASSERT(DT_WARN_UNARY_FALSE, __VA_ARGS__)
  1886. #define DOCTEST_CHECK_UNARY_FALSE(...) DOCTEST_UNARY_ASSERT(DT_CHECK_UNARY_FALSE, __VA_ARGS__)
  1887. #define DOCTEST_REQUIRE_UNARY_FALSE(...) DOCTEST_UNARY_ASSERT(DT_REQUIRE_UNARY_FALSE, __VA_ARGS__)
  1888. #ifdef DOCTEST_CONFIG_NO_EXCEPTIONS
  1889. #undef DOCTEST_WARN_THROWS
  1890. #undef DOCTEST_CHECK_THROWS
  1891. #undef DOCTEST_REQUIRE_THROWS
  1892. #undef DOCTEST_WARN_THROWS_AS
  1893. #undef DOCTEST_CHECK_THROWS_AS
  1894. #undef DOCTEST_REQUIRE_THROWS_AS
  1895. #undef DOCTEST_WARN_THROWS_WITH
  1896. #undef DOCTEST_CHECK_THROWS_WITH
  1897. #undef DOCTEST_REQUIRE_THROWS_WITH
  1898. #undef DOCTEST_WARN_THROWS_WITH_AS
  1899. #undef DOCTEST_CHECK_THROWS_WITH_AS
  1900. #undef DOCTEST_REQUIRE_THROWS_WITH_AS
  1901. #undef DOCTEST_WARN_NOTHROW
  1902. #undef DOCTEST_CHECK_NOTHROW
  1903. #undef DOCTEST_REQUIRE_NOTHROW
  1904. #undef DOCTEST_WARN_THROWS_MESSAGE
  1905. #undef DOCTEST_CHECK_THROWS_MESSAGE
  1906. #undef DOCTEST_REQUIRE_THROWS_MESSAGE
  1907. #undef DOCTEST_WARN_THROWS_AS_MESSAGE
  1908. #undef DOCTEST_CHECK_THROWS_AS_MESSAGE
  1909. #undef DOCTEST_REQUIRE_THROWS_AS_MESSAGE
  1910. #undef DOCTEST_WARN_THROWS_WITH_MESSAGE
  1911. #undef DOCTEST_CHECK_THROWS_WITH_MESSAGE
  1912. #undef DOCTEST_REQUIRE_THROWS_WITH_MESSAGE
  1913. #undef DOCTEST_WARN_THROWS_WITH_AS_MESSAGE
  1914. #undef DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE
  1915. #undef DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE
  1916. #undef DOCTEST_WARN_NOTHROW_MESSAGE
  1917. #undef DOCTEST_CHECK_NOTHROW_MESSAGE
  1918. #undef DOCTEST_REQUIRE_NOTHROW_MESSAGE
  1919. #ifdef DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS
  1920. #define DOCTEST_WARN_THROWS(...) (static_cast<void>(0))
  1921. #define DOCTEST_CHECK_THROWS(...) (static_cast<void>(0))
  1922. #define DOCTEST_REQUIRE_THROWS(...) (static_cast<void>(0))
  1923. #define DOCTEST_WARN_THROWS_AS(expr, ...) (static_cast<void>(0))
  1924. #define DOCTEST_CHECK_THROWS_AS(expr, ...) (static_cast<void>(0))
  1925. #define DOCTEST_REQUIRE_THROWS_AS(expr, ...) (static_cast<void>(0))
  1926. #define DOCTEST_WARN_THROWS_WITH(expr, ...) (static_cast<void>(0))
  1927. #define DOCTEST_CHECK_THROWS_WITH(expr, ...) (static_cast<void>(0))
  1928. #define DOCTEST_REQUIRE_THROWS_WITH(expr, ...) (static_cast<void>(0))
  1929. #define DOCTEST_WARN_THROWS_WITH_AS(expr, with, ...) (static_cast<void>(0))
  1930. #define DOCTEST_CHECK_THROWS_WITH_AS(expr, with, ...) (static_cast<void>(0))
  1931. #define DOCTEST_REQUIRE_THROWS_WITH_AS(expr, with, ...) (static_cast<void>(0))
  1932. #define DOCTEST_WARN_NOTHROW(...) (static_cast<void>(0))
  1933. #define DOCTEST_CHECK_NOTHROW(...) (static_cast<void>(0))
  1934. #define DOCTEST_REQUIRE_NOTHROW(...) (static_cast<void>(0))
  1935. #define DOCTEST_WARN_THROWS_MESSAGE(expr, ...) (static_cast<void>(0))
  1936. #define DOCTEST_CHECK_THROWS_MESSAGE(expr, ...) (static_cast<void>(0))
  1937. #define DOCTEST_REQUIRE_THROWS_MESSAGE(expr, ...) (static_cast<void>(0))
  1938. #define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, ...) (static_cast<void>(0))
  1939. #define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, ...) (static_cast<void>(0))
  1940. #define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, ...) (static_cast<void>(0))
  1941. #define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, with, ...) (static_cast<void>(0))
  1942. #define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, with, ...) (static_cast<void>(0))
  1943. #define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, with, ...) (static_cast<void>(0))
  1944. #define DOCTEST_WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) (static_cast<void>(0))
  1945. #define DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) (static_cast<void>(0))
  1946. #define DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) (static_cast<void>(0))
  1947. #define DOCTEST_WARN_NOTHROW_MESSAGE(expr, ...) (static_cast<void>(0))
  1948. #define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, ...) (static_cast<void>(0))
  1949. #define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, ...) (static_cast<void>(0))
  1950. #else // DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS
  1951. #undef DOCTEST_REQUIRE
  1952. #undef DOCTEST_REQUIRE_FALSE
  1953. #undef DOCTEST_REQUIRE_MESSAGE
  1954. #undef DOCTEST_REQUIRE_FALSE_MESSAGE
  1955. #undef DOCTEST_REQUIRE_EQ
  1956. #undef DOCTEST_REQUIRE_NE
  1957. #undef DOCTEST_REQUIRE_GT
  1958. #undef DOCTEST_REQUIRE_LT
  1959. #undef DOCTEST_REQUIRE_GE
  1960. #undef DOCTEST_REQUIRE_LE
  1961. #undef DOCTEST_REQUIRE_UNARY
  1962. #undef DOCTEST_REQUIRE_UNARY_FALSE
  1963. #endif // DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS
  1964. #endif // DOCTEST_CONFIG_NO_EXCEPTIONS
  1965. // =================================================================================================
  1966. // == WHAT FOLLOWS IS VERSIONS OF THE MACROS THAT DO NOT DO ANY REGISTERING! ==
  1967. // == THIS CAN BE ENABLED BY DEFINING DOCTEST_CONFIG_DISABLE GLOBALLY! ==
  1968. // =================================================================================================
  1969. #else // DOCTEST_CONFIG_DISABLE
  1970. #define DOCTEST_IMPLEMENT_FIXTURE(der, base, func, name) \
  1971. namespace { \
  1972. template <typename DOCTEST_UNUSED_TEMPLATE_TYPE> \
  1973. struct der : public base \
  1974. { void f(); }; \
  1975. } \
  1976. template <typename DOCTEST_UNUSED_TEMPLATE_TYPE> \
  1977. inline void der<DOCTEST_UNUSED_TEMPLATE_TYPE>::f()
  1978. #define DOCTEST_CREATE_AND_REGISTER_FUNCTION(f, name) \
  1979. template <typename DOCTEST_UNUSED_TEMPLATE_TYPE> \
  1980. static inline void f()
  1981. // for registering tests
  1982. #define DOCTEST_TEST_CASE(name) \
  1983. DOCTEST_CREATE_AND_REGISTER_FUNCTION(DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), name)
  1984. // for registering tests in classes
  1985. #define DOCTEST_TEST_CASE_CLASS(name) \
  1986. DOCTEST_CREATE_AND_REGISTER_FUNCTION(DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), name)
  1987. // for registering tests with a fixture
  1988. #define DOCTEST_TEST_CASE_FIXTURE(x, name) \
  1989. DOCTEST_IMPLEMENT_FIXTURE(DOCTEST_ANONYMOUS(_DOCTEST_ANON_CLASS_), x, \
  1990. DOCTEST_ANONYMOUS(_DOCTEST_ANON_FUNC_), name)
  1991. // for converting types to strings without the <typeinfo> header and demangling
  1992. #define DOCTEST_TYPE_TO_STRING(...) typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
  1993. #define DOCTEST_TYPE_TO_STRING_IMPL(...)
  1994. // for typed tests
  1995. #define DOCTEST_TEST_CASE_TEMPLATE(name, type, ...) \
  1996. template <typename type> \
  1997. inline void DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_)()
  1998. #define DOCTEST_TEST_CASE_TEMPLATE_DEFINE(name, type, id) \
  1999. template <typename type> \
  2000. inline void DOCTEST_ANONYMOUS(_DOCTEST_ANON_TMP_)()
  2001. #define DOCTEST_TEST_CASE_TEMPLATE_INVOKE(id, ...) \
  2002. typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
  2003. #define DOCTEST_TEST_CASE_TEMPLATE_APPLY(id, ...) \
  2004. typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
  2005. // for subcases
  2006. #define DOCTEST_SUBCASE(name)
  2007. // for a testsuite block
  2008. #define DOCTEST_TEST_SUITE(name) namespace
  2009. // for starting a testsuite block
  2010. #define DOCTEST_TEST_SUITE_BEGIN(name) typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
  2011. // for ending a testsuite block
  2012. #define DOCTEST_TEST_SUITE_END typedef int DOCTEST_ANONYMOUS(_DOCTEST_ANON_FOR_SEMICOLON_)
  2013. #define DOCTEST_REGISTER_EXCEPTION_TRANSLATOR(signature) \
  2014. template <typename DOCTEST_UNUSED_TEMPLATE_TYPE> \
  2015. static inline doctest::String DOCTEST_ANONYMOUS(_DOCTEST_ANON_TRANSLATOR_)(signature)
  2016. #define DOCTEST_REGISTER_REPORTER(name, priority, reporter)
  2017. #define DOCTEST_REGISTER_LISTENER(name, priority, reporter)
  2018. #define DOCTEST_INFO(...) (static_cast<void>(0))
  2019. #define DOCTEST_CAPTURE(x) (static_cast<void>(0))
  2020. #define DOCTEST_ADD_MESSAGE_AT(file, line, ...) (static_cast<void>(0))
  2021. #define DOCTEST_ADD_FAIL_CHECK_AT(file, line, ...) (static_cast<void>(0))
  2022. #define DOCTEST_ADD_FAIL_AT(file, line, ...) (static_cast<void>(0))
  2023. #define DOCTEST_MESSAGE(...) (static_cast<void>(0))
  2024. #define DOCTEST_FAIL_CHECK(...) (static_cast<void>(0))
  2025. #define DOCTEST_FAIL(...) (static_cast<void>(0))
  2026. #define DOCTEST_WARN(...) (static_cast<void>(0))
  2027. #define DOCTEST_CHECK(...) (static_cast<void>(0))
  2028. #define DOCTEST_REQUIRE(...) (static_cast<void>(0))
  2029. #define DOCTEST_WARN_FALSE(...) (static_cast<void>(0))
  2030. #define DOCTEST_CHECK_FALSE(...) (static_cast<void>(0))
  2031. #define DOCTEST_REQUIRE_FALSE(...) (static_cast<void>(0))
  2032. #define DOCTEST_WARN_MESSAGE(cond, ...) (static_cast<void>(0))
  2033. #define DOCTEST_CHECK_MESSAGE(cond, ...) (static_cast<void>(0))
  2034. #define DOCTEST_REQUIRE_MESSAGE(cond, ...) (static_cast<void>(0))
  2035. #define DOCTEST_WARN_FALSE_MESSAGE(cond, ...) (static_cast<void>(0))
  2036. #define DOCTEST_CHECK_FALSE_MESSAGE(cond, ...) (static_cast<void>(0))
  2037. #define DOCTEST_REQUIRE_FALSE_MESSAGE(cond, ...) (static_cast<void>(0))
  2038. #define DOCTEST_WARN_THROWS(...) (static_cast<void>(0))
  2039. #define DOCTEST_CHECK_THROWS(...) (static_cast<void>(0))
  2040. #define DOCTEST_REQUIRE_THROWS(...) (static_cast<void>(0))
  2041. #define DOCTEST_WARN_THROWS_AS(expr, ...) (static_cast<void>(0))
  2042. #define DOCTEST_CHECK_THROWS_AS(expr, ...) (static_cast<void>(0))
  2043. #define DOCTEST_REQUIRE_THROWS_AS(expr, ...) (static_cast<void>(0))
  2044. #define DOCTEST_WARN_THROWS_WITH(expr, ...) (static_cast<void>(0))
  2045. #define DOCTEST_CHECK_THROWS_WITH(expr, ...) (static_cast<void>(0))
  2046. #define DOCTEST_REQUIRE_THROWS_WITH(expr, ...) (static_cast<void>(0))
  2047. #define DOCTEST_WARN_THROWS_WITH_AS(expr, with, ...) (static_cast<void>(0))
  2048. #define DOCTEST_CHECK_THROWS_WITH_AS(expr, with, ...) (static_cast<void>(0))
  2049. #define DOCTEST_REQUIRE_THROWS_WITH_AS(expr, with, ...) (static_cast<void>(0))
  2050. #define DOCTEST_WARN_NOTHROW(...) (static_cast<void>(0))
  2051. #define DOCTEST_CHECK_NOTHROW(...) (static_cast<void>(0))
  2052. #define DOCTEST_REQUIRE_NOTHROW(...) (static_cast<void>(0))
  2053. #define DOCTEST_WARN_THROWS_MESSAGE(expr, ...) (static_cast<void>(0))
  2054. #define DOCTEST_CHECK_THROWS_MESSAGE(expr, ...) (static_cast<void>(0))
  2055. #define DOCTEST_REQUIRE_THROWS_MESSAGE(expr, ...) (static_cast<void>(0))
  2056. #define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, ...) (static_cast<void>(0))
  2057. #define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, ...) (static_cast<void>(0))
  2058. #define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, ...) (static_cast<void>(0))
  2059. #define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, with, ...) (static_cast<void>(0))
  2060. #define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, with, ...) (static_cast<void>(0))
  2061. #define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, with, ...) (static_cast<void>(0))
  2062. #define DOCTEST_WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) (static_cast<void>(0))
  2063. #define DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) (static_cast<void>(0))
  2064. #define DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) (static_cast<void>(0))
  2065. #define DOCTEST_WARN_NOTHROW_MESSAGE(expr, ...) (static_cast<void>(0))
  2066. #define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, ...) (static_cast<void>(0))
  2067. #define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, ...) (static_cast<void>(0))
  2068. #define DOCTEST_WARN_EQ(...) (static_cast<void>(0))
  2069. #define DOCTEST_CHECK_EQ(...) (static_cast<void>(0))
  2070. #define DOCTEST_REQUIRE_EQ(...) (static_cast<void>(0))
  2071. #define DOCTEST_WARN_NE(...) (static_cast<void>(0))
  2072. #define DOCTEST_CHECK_NE(...) (static_cast<void>(0))
  2073. #define DOCTEST_REQUIRE_NE(...) (static_cast<void>(0))
  2074. #define DOCTEST_WARN_GT(...) (static_cast<void>(0))
  2075. #define DOCTEST_CHECK_GT(...) (static_cast<void>(0))
  2076. #define DOCTEST_REQUIRE_GT(...) (static_cast<void>(0))
  2077. #define DOCTEST_WARN_LT(...) (static_cast<void>(0))
  2078. #define DOCTEST_CHECK_LT(...) (static_cast<void>(0))
  2079. #define DOCTEST_REQUIRE_LT(...) (static_cast<void>(0))
  2080. #define DOCTEST_WARN_GE(...) (static_cast<void>(0))
  2081. #define DOCTEST_CHECK_GE(...) (static_cast<void>(0))
  2082. #define DOCTEST_REQUIRE_GE(...) (static_cast<void>(0))
  2083. #define DOCTEST_WARN_LE(...) (static_cast<void>(0))
  2084. #define DOCTEST_CHECK_LE(...) (static_cast<void>(0))
  2085. #define DOCTEST_REQUIRE_LE(...) (static_cast<void>(0))
  2086. #define DOCTEST_WARN_UNARY(...) (static_cast<void>(0))
  2087. #define DOCTEST_CHECK_UNARY(...) (static_cast<void>(0))
  2088. #define DOCTEST_REQUIRE_UNARY(...) (static_cast<void>(0))
  2089. #define DOCTEST_WARN_UNARY_FALSE(...) (static_cast<void>(0))
  2090. #define DOCTEST_CHECK_UNARY_FALSE(...) (static_cast<void>(0))
  2091. #define DOCTEST_REQUIRE_UNARY_FALSE(...) (static_cast<void>(0))
  2092. #endif // DOCTEST_CONFIG_DISABLE
  2093. // clang-format off
  2094. // KEPT FOR BACKWARDS COMPATIBILITY - FORWARDING TO THE RIGHT MACROS
  2095. #define DOCTEST_FAST_WARN_EQ DOCTEST_WARN_EQ
  2096. #define DOCTEST_FAST_CHECK_EQ DOCTEST_CHECK_EQ
  2097. #define DOCTEST_FAST_REQUIRE_EQ DOCTEST_REQUIRE_EQ
  2098. #define DOCTEST_FAST_WARN_NE DOCTEST_WARN_NE
  2099. #define DOCTEST_FAST_CHECK_NE DOCTEST_CHECK_NE
  2100. #define DOCTEST_FAST_REQUIRE_NE DOCTEST_REQUIRE_NE
  2101. #define DOCTEST_FAST_WARN_GT DOCTEST_WARN_GT
  2102. #define DOCTEST_FAST_CHECK_GT DOCTEST_CHECK_GT
  2103. #define DOCTEST_FAST_REQUIRE_GT DOCTEST_REQUIRE_GT
  2104. #define DOCTEST_FAST_WARN_LT DOCTEST_WARN_LT
  2105. #define DOCTEST_FAST_CHECK_LT DOCTEST_CHECK_LT
  2106. #define DOCTEST_FAST_REQUIRE_LT DOCTEST_REQUIRE_LT
  2107. #define DOCTEST_FAST_WARN_GE DOCTEST_WARN_GE
  2108. #define DOCTEST_FAST_CHECK_GE DOCTEST_CHECK_GE
  2109. #define DOCTEST_FAST_REQUIRE_GE DOCTEST_REQUIRE_GE
  2110. #define DOCTEST_FAST_WARN_LE DOCTEST_WARN_LE
  2111. #define DOCTEST_FAST_CHECK_LE DOCTEST_CHECK_LE
  2112. #define DOCTEST_FAST_REQUIRE_LE DOCTEST_REQUIRE_LE
  2113. #define DOCTEST_FAST_WARN_UNARY DOCTEST_WARN_UNARY
  2114. #define DOCTEST_FAST_CHECK_UNARY DOCTEST_CHECK_UNARY
  2115. #define DOCTEST_FAST_REQUIRE_UNARY DOCTEST_REQUIRE_UNARY
  2116. #define DOCTEST_FAST_WARN_UNARY_FALSE DOCTEST_WARN_UNARY_FALSE
  2117. #define DOCTEST_FAST_CHECK_UNARY_FALSE DOCTEST_CHECK_UNARY_FALSE
  2118. #define DOCTEST_FAST_REQUIRE_UNARY_FALSE DOCTEST_REQUIRE_UNARY_FALSE
  2119. #define DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE(id, ...) DOCTEST_TEST_CASE_TEMPLATE_INVOKE(id,__VA_ARGS__)
  2120. // clang-format on
  2121. // BDD style macros
  2122. // clang-format off
  2123. #define DOCTEST_SCENARIO(name) DOCTEST_TEST_CASE(" Scenario: " name)
  2124. #define DOCTEST_SCENARIO_CLASS(name) DOCTEST_TEST_CASE_CLASS(" Scenario: " name)
  2125. #define DOCTEST_SCENARIO_TEMPLATE(name, T, ...) DOCTEST_TEST_CASE_TEMPLATE(" Scenario: " name, T, __VA_ARGS__)
  2126. #define DOCTEST_SCENARIO_TEMPLATE_DEFINE(name, T, id) DOCTEST_TEST_CASE_TEMPLATE_DEFINE(" Scenario: " name, T, id)
  2127. #define DOCTEST_GIVEN(name) DOCTEST_SUBCASE(" Given: " name)
  2128. #define DOCTEST_WHEN(name) DOCTEST_SUBCASE(" When: " name)
  2129. #define DOCTEST_AND_WHEN(name) DOCTEST_SUBCASE("And when: " name)
  2130. #define DOCTEST_THEN(name) DOCTEST_SUBCASE(" Then: " name)
  2131. #define DOCTEST_AND_THEN(name) DOCTEST_SUBCASE(" And: " name)
  2132. // clang-format on
  2133. // == SHORT VERSIONS OF THE MACROS
  2134. #if !defined(DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES)
  2135. #define TEST_CASE(name) DOCTEST_TEST_CASE(name)
  2136. #define TEST_CASE_CLASS(name) DOCTEST_TEST_CASE_CLASS(name)
  2137. #define TEST_CASE_FIXTURE(x, name) DOCTEST_TEST_CASE_FIXTURE(x, name)
  2138. #define TYPE_TO_STRING(...) DOCTEST_TYPE_TO_STRING(__VA_ARGS__)
  2139. #define TEST_CASE_TEMPLATE(name, T, ...) DOCTEST_TEST_CASE_TEMPLATE(name, T, __VA_ARGS__)
  2140. #define TEST_CASE_TEMPLATE_DEFINE(name, T, id) DOCTEST_TEST_CASE_TEMPLATE_DEFINE(name, T, id)
  2141. #define TEST_CASE_TEMPLATE_INVOKE(id, ...) DOCTEST_TEST_CASE_TEMPLATE_INVOKE(id, __VA_ARGS__)
  2142. #define TEST_CASE_TEMPLATE_APPLY(id, ...) DOCTEST_TEST_CASE_TEMPLATE_APPLY(id, __VA_ARGS__)
  2143. #define SUBCASE(name) DOCTEST_SUBCASE(name)
  2144. #define TEST_SUITE(decorators) DOCTEST_TEST_SUITE(decorators)
  2145. #define TEST_SUITE_BEGIN(name) DOCTEST_TEST_SUITE_BEGIN(name)
  2146. #define TEST_SUITE_END DOCTEST_TEST_SUITE_END
  2147. #define REGISTER_EXCEPTION_TRANSLATOR(signature) DOCTEST_REGISTER_EXCEPTION_TRANSLATOR(signature)
  2148. #define REGISTER_REPORTER(name, priority, reporter) DOCTEST_REGISTER_REPORTER(name, priority, reporter)
  2149. #define REGISTER_LISTENER(name, priority, reporter) DOCTEST_REGISTER_LISTENER(name, priority, reporter)
  2150. #define INFO(...) DOCTEST_INFO(__VA_ARGS__)
  2151. #define CAPTURE(x) DOCTEST_CAPTURE(x)
  2152. #define ADD_MESSAGE_AT(file, line, ...) DOCTEST_ADD_MESSAGE_AT(file, line, __VA_ARGS__)
  2153. #define ADD_FAIL_CHECK_AT(file, line, ...) DOCTEST_ADD_FAIL_CHECK_AT(file, line, __VA_ARGS__)
  2154. #define ADD_FAIL_AT(file, line, ...) DOCTEST_ADD_FAIL_AT(file, line, __VA_ARGS__)
  2155. #define MESSAGE(...) DOCTEST_MESSAGE(__VA_ARGS__)
  2156. #define FAIL_CHECK(...) DOCTEST_FAIL_CHECK(__VA_ARGS__)
  2157. #define FAIL(...) DOCTEST_FAIL(__VA_ARGS__)
  2158. #define TO_LVALUE(...) DOCTEST_TO_LVALUE(__VA_ARGS__)
  2159. #define WARN(...) DOCTEST_WARN(__VA_ARGS__)
  2160. #define WARN_FALSE(...) DOCTEST_WARN_FALSE(__VA_ARGS__)
  2161. #define WARN_THROWS(...) DOCTEST_WARN_THROWS(__VA_ARGS__)
  2162. #define WARN_THROWS_AS(expr, ...) DOCTEST_WARN_THROWS_AS(expr, __VA_ARGS__)
  2163. #define WARN_THROWS_WITH(expr, ...) DOCTEST_WARN_THROWS_WITH(expr, __VA_ARGS__)
  2164. #define WARN_THROWS_WITH_AS(expr, with, ...) DOCTEST_WARN_THROWS_WITH_AS(expr, with, __VA_ARGS__)
  2165. #define WARN_NOTHROW(...) DOCTEST_WARN_NOTHROW(__VA_ARGS__)
  2166. #define CHECK(...) DOCTEST_CHECK(__VA_ARGS__)
  2167. #define CHECK_FALSE(...) DOCTEST_CHECK_FALSE(__VA_ARGS__)
  2168. #define CHECK_THROWS(...) DOCTEST_CHECK_THROWS(__VA_ARGS__)
  2169. #define CHECK_THROWS_AS(expr, ...) DOCTEST_CHECK_THROWS_AS(expr, __VA_ARGS__)
  2170. #define CHECK_THROWS_WITH(expr, ...) DOCTEST_CHECK_THROWS_WITH(expr, __VA_ARGS__)
  2171. #define CHECK_THROWS_WITH_AS(expr, with, ...) DOCTEST_CHECK_THROWS_WITH_AS(expr, with, __VA_ARGS__)
  2172. #define CHECK_NOTHROW(...) DOCTEST_CHECK_NOTHROW(__VA_ARGS__)
  2173. #define REQUIRE(...) DOCTEST_REQUIRE(__VA_ARGS__)
  2174. #define REQUIRE_FALSE(...) DOCTEST_REQUIRE_FALSE(__VA_ARGS__)
  2175. #define REQUIRE_THROWS(...) DOCTEST_REQUIRE_THROWS(__VA_ARGS__)
  2176. #define REQUIRE_THROWS_AS(expr, ...) DOCTEST_REQUIRE_THROWS_AS(expr, __VA_ARGS__)
  2177. #define REQUIRE_THROWS_WITH(expr, ...) DOCTEST_REQUIRE_THROWS_WITH(expr, __VA_ARGS__)
  2178. #define REQUIRE_THROWS_WITH_AS(expr, with, ...) DOCTEST_REQUIRE_THROWS_WITH_AS(expr, with, __VA_ARGS__)
  2179. #define REQUIRE_NOTHROW(...) DOCTEST_REQUIRE_NOTHROW(__VA_ARGS__)
  2180. #define WARN_MESSAGE(cond, ...) DOCTEST_WARN_MESSAGE(cond, __VA_ARGS__)
  2181. #define WARN_FALSE_MESSAGE(cond, ...) DOCTEST_WARN_FALSE_MESSAGE(cond, __VA_ARGS__)
  2182. #define WARN_THROWS_MESSAGE(expr, ...) DOCTEST_WARN_THROWS_MESSAGE(expr, __VA_ARGS__)
  2183. #define WARN_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, __VA_ARGS__)
  2184. #define WARN_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, with, __VA_ARGS__)
  2185. #define WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, __VA_ARGS__)
  2186. #define WARN_NOTHROW_MESSAGE(expr, ...) DOCTEST_WARN_NOTHROW_MESSAGE(expr, __VA_ARGS__)
  2187. #define CHECK_MESSAGE(cond, ...) DOCTEST_CHECK_MESSAGE(cond, __VA_ARGS__)
  2188. #define CHECK_FALSE_MESSAGE(cond, ...) DOCTEST_CHECK_FALSE_MESSAGE(cond, __VA_ARGS__)
  2189. #define CHECK_THROWS_MESSAGE(expr, ...) DOCTEST_CHECK_THROWS_MESSAGE(expr, __VA_ARGS__)
  2190. #define CHECK_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, __VA_ARGS__)
  2191. #define CHECK_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, with, __VA_ARGS__)
  2192. #define CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, __VA_ARGS__)
  2193. #define CHECK_NOTHROW_MESSAGE(expr, ...) DOCTEST_CHECK_NOTHROW_MESSAGE(expr, __VA_ARGS__)
  2194. #define REQUIRE_MESSAGE(cond, ...) DOCTEST_REQUIRE_MESSAGE(cond, __VA_ARGS__)
  2195. #define REQUIRE_FALSE_MESSAGE(cond, ...) DOCTEST_REQUIRE_FALSE_MESSAGE(cond, __VA_ARGS__)
  2196. #define REQUIRE_THROWS_MESSAGE(expr, ...) DOCTEST_REQUIRE_THROWS_MESSAGE(expr, __VA_ARGS__)
  2197. #define REQUIRE_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, __VA_ARGS__)
  2198. #define REQUIRE_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, with, __VA_ARGS__)
  2199. #define REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, __VA_ARGS__)
  2200. #define REQUIRE_NOTHROW_MESSAGE(expr, ...) DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, __VA_ARGS__)
  2201. #define SCENARIO(name) DOCTEST_SCENARIO(name)
  2202. #define SCENARIO_CLASS(name) DOCTEST_SCENARIO_CLASS(name)
  2203. #define SCENARIO_TEMPLATE(name, T, ...) DOCTEST_SCENARIO_TEMPLATE(name, T, __VA_ARGS__)
  2204. #define SCENARIO_TEMPLATE_DEFINE(name, T, id) DOCTEST_SCENARIO_TEMPLATE_DEFINE(name, T, id)
  2205. #define GIVEN(name) DOCTEST_GIVEN(name)
  2206. #define WHEN(name) DOCTEST_WHEN(name)
  2207. #define AND_WHEN(name) DOCTEST_AND_WHEN(name)
  2208. #define THEN(name) DOCTEST_THEN(name)
  2209. #define AND_THEN(name) DOCTEST_AND_THEN(name)
  2210. #define WARN_EQ(...) DOCTEST_WARN_EQ(__VA_ARGS__)
  2211. #define CHECK_EQ(...) DOCTEST_CHECK_EQ(__VA_ARGS__)
  2212. #define REQUIRE_EQ(...) DOCTEST_REQUIRE_EQ(__VA_ARGS__)
  2213. #define WARN_NE(...) DOCTEST_WARN_NE(__VA_ARGS__)
  2214. #define CHECK_NE(...) DOCTEST_CHECK_NE(__VA_ARGS__)
  2215. #define REQUIRE_NE(...) DOCTEST_REQUIRE_NE(__VA_ARGS__)
  2216. #define WARN_GT(...) DOCTEST_WARN_GT(__VA_ARGS__)
  2217. #define CHECK_GT(...) DOCTEST_CHECK_GT(__VA_ARGS__)
  2218. #define REQUIRE_GT(...) DOCTEST_REQUIRE_GT(__VA_ARGS__)
  2219. #define WARN_LT(...) DOCTEST_WARN_LT(__VA_ARGS__)
  2220. #define CHECK_LT(...) DOCTEST_CHECK_LT(__VA_ARGS__)
  2221. #define REQUIRE_LT(...) DOCTEST_REQUIRE_LT(__VA_ARGS__)
  2222. #define WARN_GE(...) DOCTEST_WARN_GE(__VA_ARGS__)
  2223. #define CHECK_GE(...) DOCTEST_CHECK_GE(__VA_ARGS__)
  2224. #define REQUIRE_GE(...) DOCTEST_REQUIRE_GE(__VA_ARGS__)
  2225. #define WARN_LE(...) DOCTEST_WARN_LE(__VA_ARGS__)
  2226. #define CHECK_LE(...) DOCTEST_CHECK_LE(__VA_ARGS__)
  2227. #define REQUIRE_LE(...) DOCTEST_REQUIRE_LE(__VA_ARGS__)
  2228. #define WARN_UNARY(...) DOCTEST_WARN_UNARY(__VA_ARGS__)
  2229. #define CHECK_UNARY(...) DOCTEST_CHECK_UNARY(__VA_ARGS__)
  2230. #define REQUIRE_UNARY(...) DOCTEST_REQUIRE_UNARY(__VA_ARGS__)
  2231. #define WARN_UNARY_FALSE(...) DOCTEST_WARN_UNARY_FALSE(__VA_ARGS__)
  2232. #define CHECK_UNARY_FALSE(...) DOCTEST_CHECK_UNARY_FALSE(__VA_ARGS__)
  2233. #define REQUIRE_UNARY_FALSE(...) DOCTEST_REQUIRE_UNARY_FALSE(__VA_ARGS__)
  2234. // KEPT FOR BACKWARDS COMPATIBILITY
  2235. #define FAST_WARN_EQ(...) DOCTEST_FAST_WARN_EQ(__VA_ARGS__)
  2236. #define FAST_CHECK_EQ(...) DOCTEST_FAST_CHECK_EQ(__VA_ARGS__)
  2237. #define FAST_REQUIRE_EQ(...) DOCTEST_FAST_REQUIRE_EQ(__VA_ARGS__)
  2238. #define FAST_WARN_NE(...) DOCTEST_FAST_WARN_NE(__VA_ARGS__)
  2239. #define FAST_CHECK_NE(...) DOCTEST_FAST_CHECK_NE(__VA_ARGS__)
  2240. #define FAST_REQUIRE_NE(...) DOCTEST_FAST_REQUIRE_NE(__VA_ARGS__)
  2241. #define FAST_WARN_GT(...) DOCTEST_FAST_WARN_GT(__VA_ARGS__)
  2242. #define FAST_CHECK_GT(...) DOCTEST_FAST_CHECK_GT(__VA_ARGS__)
  2243. #define FAST_REQUIRE_GT(...) DOCTEST_FAST_REQUIRE_GT(__VA_ARGS__)
  2244. #define FAST_WARN_LT(...) DOCTEST_FAST_WARN_LT(__VA_ARGS__)
  2245. #define FAST_CHECK_LT(...) DOCTEST_FAST_CHECK_LT(__VA_ARGS__)
  2246. #define FAST_REQUIRE_LT(...) DOCTEST_FAST_REQUIRE_LT(__VA_ARGS__)
  2247. #define FAST_WARN_GE(...) DOCTEST_FAST_WARN_GE(__VA_ARGS__)
  2248. #define FAST_CHECK_GE(...) DOCTEST_FAST_CHECK_GE(__VA_ARGS__)
  2249. #define FAST_REQUIRE_GE(...) DOCTEST_FAST_REQUIRE_GE(__VA_ARGS__)
  2250. #define FAST_WARN_LE(...) DOCTEST_FAST_WARN_LE(__VA_ARGS__)
  2251. #define FAST_CHECK_LE(...) DOCTEST_FAST_CHECK_LE(__VA_ARGS__)
  2252. #define FAST_REQUIRE_LE(...) DOCTEST_FAST_REQUIRE_LE(__VA_ARGS__)
  2253. #define FAST_WARN_UNARY(...) DOCTEST_FAST_WARN_UNARY(__VA_ARGS__)
  2254. #define FAST_CHECK_UNARY(...) DOCTEST_FAST_CHECK_UNARY(__VA_ARGS__)
  2255. #define FAST_REQUIRE_UNARY(...) DOCTEST_FAST_REQUIRE_UNARY(__VA_ARGS__)
  2256. #define FAST_WARN_UNARY_FALSE(...) DOCTEST_FAST_WARN_UNARY_FALSE(__VA_ARGS__)
  2257. #define FAST_CHECK_UNARY_FALSE(...) DOCTEST_FAST_CHECK_UNARY_FALSE(__VA_ARGS__)
  2258. #define FAST_REQUIRE_UNARY_FALSE(...) DOCTEST_FAST_REQUIRE_UNARY_FALSE(__VA_ARGS__)
  2259. #define TEST_CASE_TEMPLATE_INSTANTIATE(id, ...) DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE(id, __VA_ARGS__)
  2260. #endif // DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES
  2261. #if !defined(DOCTEST_CONFIG_DISABLE)
  2262. // this is here to clear the 'current test suite' for the current translation unit - at the top
  2263. DOCTEST_TEST_SUITE_END();
  2264. // add stringification for primitive/fundamental types
  2265. namespace doctest { namespace detail {
  2266. DOCTEST_TYPE_TO_STRING_IMPL(bool)
  2267. DOCTEST_TYPE_TO_STRING_IMPL(float)
  2268. DOCTEST_TYPE_TO_STRING_IMPL(double)
  2269. DOCTEST_TYPE_TO_STRING_IMPL(long double)
  2270. DOCTEST_TYPE_TO_STRING_IMPL(char)
  2271. DOCTEST_TYPE_TO_STRING_IMPL(signed char)
  2272. DOCTEST_TYPE_TO_STRING_IMPL(unsigned char)
  2273. #if !DOCTEST_MSVC || defined(_NATIVE_WCHAR_T_DEFINED)
  2274. DOCTEST_TYPE_TO_STRING_IMPL(wchar_t)
  2275. #endif // not MSVC or wchar_t support enabled
  2276. DOCTEST_TYPE_TO_STRING_IMPL(short int)
  2277. DOCTEST_TYPE_TO_STRING_IMPL(unsigned short int)
  2278. DOCTEST_TYPE_TO_STRING_IMPL(int)
  2279. DOCTEST_TYPE_TO_STRING_IMPL(unsigned int)
  2280. DOCTEST_TYPE_TO_STRING_IMPL(long int)
  2281. DOCTEST_TYPE_TO_STRING_IMPL(unsigned long int)
  2282. DOCTEST_TYPE_TO_STRING_IMPL(long long int)
  2283. DOCTEST_TYPE_TO_STRING_IMPL(unsigned long long int)
  2284. }} // namespace doctest::detail
  2285. #endif // DOCTEST_CONFIG_DISABLE
  2286. DOCTEST_CLANG_SUPPRESS_WARNING_POP
  2287. DOCTEST_MSVC_SUPPRESS_WARNING_POP
  2288. DOCTEST_GCC_SUPPRESS_WARNING_POP
  2289. #endif // DOCTEST_LIBRARY_INCLUDED