| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 1 | /* |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 2 | * Created by Phil on 22/10/2010. |
| 3 | * Copyright 2010 Two Blue Cubes Ltd |
| 4 | * |
| 5 | * Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 6 | * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 9 | #ifndef TWOBLUECUBES_CATCH_HPP_INCLUDED |
| 10 | #define TWOBLUECUBES_CATCH_HPP_INCLUDED |
| Phil Nash | 0f9c551 | 2012-06-02 23:12:42 +0100 | [diff] [blame] | 11 | |
| Phil Nash | fc63b02 | 2015-05-21 06:15:53 +0100 | [diff] [blame] | 12 | #ifdef __clang__ |
| 13 | # pragma clang system_header |
| 14 | #elif defined __GNUC__ |
| 15 | # pragma GCC system_header |
| 16 | #endif |
| 17 | |
| Phil Nash | 3bdc97d | 2014-05-19 18:57:14 +0100 | [diff] [blame] | 18 | #include "internal/catch_suppress_warnings.h" |
| Phil Nash | a695eb9 | 2012-08-13 07:46:10 +0100 | [diff] [blame] | 19 | |
| Phil Nash | db0421e | 2014-12-19 17:52:33 +0000 | [diff] [blame] | 20 | #if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER) |
| 21 | # define CATCH_IMPL |
| Phil Nash | f9df35b | 2014-03-10 18:02:18 +0000 | [diff] [blame] | 22 | #endif |
| 23 | |
| Phil Nash | db0421e | 2014-12-19 17:52:33 +0000 | [diff] [blame] | 24 | #ifdef CATCH_IMPL |
| Phil Nash | 9abb276 | 2014-03-06 21:53:34 +0000 | [diff] [blame] | 25 | # ifndef CLARA_CONFIG_MAIN |
| 26 | # define CLARA_CONFIG_MAIN_NOT_DEFINED |
| 27 | # define CLARA_CONFIG_MAIN |
| 28 | # endif |
| 29 | #endif |
| 30 | |
| Phil Nash | 5ec53b2 | 2012-05-10 07:58:48 +0100 | [diff] [blame] | 31 | #include "internal/catch_context.h" |
| Martin Hořeňovský | 33fd54a | 2017-07-27 11:55:30 +0200 | [diff] [blame] | 32 | #include "internal/catch_tag_alias_autoregistrar.h" |
| Phil Nash | 896a04f | 2011-01-05 21:16:54 +0000 | [diff] [blame] | 33 | #include "internal/catch_test_registry.hpp" |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 34 | #include "internal/catch_capture.hpp" |
| Phil Nash | c4a089c | 2013-12-03 18:52:41 +0000 | [diff] [blame] | 35 | #include "internal/catch_section.h" |
| Phil Nash | 9430a2c | 2011-04-20 15:40:40 +0100 | [diff] [blame] | 36 | #include "internal/catch_interfaces_exception.h" |
| Phil Nash | d7c203c | 2011-04-28 08:03:28 +0100 | [diff] [blame] | 37 | #include "internal/catch_approx.hpp" |
| Phil Nash | 1400127 | 2017-02-08 15:14:51 +0000 | [diff] [blame] | 38 | #include "internal/catch_matchers_string.h" |
| Phil Nash | 10dfca3 | 2017-02-21 16:05:04 +0000 | [diff] [blame] | 39 | #include "internal/catch_matchers_vector.h" |
| Phil Nash | 4dd3f68 | 2013-04-22 08:19:17 +0100 | [diff] [blame] | 40 | #include "internal/catch_compiler_capabilities.h" |
| Phil Nash | 1d210eb | 2014-06-30 07:33:17 +0100 | [diff] [blame] | 41 | #include "internal/catch_interfaces_tag_alias_registry.h" |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 42 | |
| Phil Nash | 0f9c551 | 2012-06-02 23:12:42 +0100 | [diff] [blame] | 43 | // These files are included here so the single_include script doesn't put them |
| 44 | // in the conditionally compiled sections |
| Phil Nash | ddfe963 | 2012-08-14 19:30:30 +0100 | [diff] [blame] | 45 | #include "internal/catch_test_case_info.h" |
| Phil Nash | 0f9c551 | 2012-06-02 23:12:42 +0100 | [diff] [blame] | 46 | #include "internal/catch_interfaces_runner.h" |
| 47 | |
| Phil Nash | 8350ef6 | 2011-08-12 18:52:10 +0100 | [diff] [blame] | 48 | #ifdef __OBJC__ |
| 49 | #include "internal/catch_objc.hpp" |
| 50 | #endif |
| 51 | |
| Phil Nash | db0421e | 2014-12-19 17:52:33 +0000 | [diff] [blame] | 52 | #ifdef CATCH_IMPL |
| Phil Nash | 1091ca8 | 2012-08-06 20:16:53 +0100 | [diff] [blame] | 53 | #include "internal/catch_impl.hpp" |
| Phil Nash | 9abb276 | 2014-03-06 21:53:34 +0000 | [diff] [blame] | 54 | #endif |
| Phil Nash | 89d1e6c | 2011-05-24 08:23:02 +0100 | [diff] [blame] | 55 | |
| 56 | #ifdef CATCH_CONFIG_MAIN |
| 57 | #include "internal/catch_default_main.hpp" |
| Phil Nash | 9abb276 | 2014-03-06 21:53:34 +0000 | [diff] [blame] | 58 | #endif |
| 59 | |
| 60 | |
| 61 | #ifdef CLARA_CONFIG_MAIN_NOT_DEFINED |
| 62 | # undef CLARA_CONFIG_MAIN |
| 63 | #endif |
| Phil Nash | 89d1e6c | 2011-05-24 08:23:02 +0100 | [diff] [blame] | 64 | |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 65 | ////// |
| 66 | |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 67 | // If this config identifier is defined then all CATCH macros are prefixed with CATCH_ |
| 68 | #ifdef CATCH_CONFIG_PREFIX_ALL |
| 69 | |
| Martin Hořeňovský | 7a8a020 | 2017-03-17 13:21:40 +0100 | [diff] [blame] | 70 | #if defined(CATCH_CONFIG_FAST_COMPILE) |
| Martin Hořeňovský | e1bca70 | 2017-04-25 20:20:46 +0200 | [diff] [blame] | 71 | #define CATCH_REQUIRE( ... ) INTERNAL_CATCH_TEST_NO_TRY( "CATCH_REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__ ) |
| 72 | #define CATCH_REQUIRE_FALSE( ... ) INTERNAL_CATCH_TEST_NO_TRY( "CATCH_REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) |
| Martin Hořeňovský | 7a8a020 | 2017-03-17 13:21:40 +0100 | [diff] [blame] | 73 | #else |
| Martin Hořeňovský | e1bca70 | 2017-04-25 20:20:46 +0200 | [diff] [blame] | 74 | #define CATCH_REQUIRE( ... ) INTERNAL_CATCH_TEST( "CATCH_REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__ ) |
| 75 | #define CATCH_REQUIRE_FALSE( ... ) INTERNAL_CATCH_TEST( "CATCH_REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) |
| Martin Hořeňovský | 7a8a020 | 2017-03-17 13:21:40 +0100 | [diff] [blame] | 76 | #endif |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 77 | |
| Martin Hořeňovský | e1bca70 | 2017-04-25 20:20:46 +0200 | [diff] [blame] | 78 | #define CATCH_REQUIRE_THROWS( ... ) INTERNAL_CATCH_THROWS( "CATCH_REQUIRE_THROWS", Catch::ResultDisposition::Normal, "", __VA_ARGS__ ) |
| Phil Nash | f3ec843 | 2017-03-21 13:22:39 +0000 | [diff] [blame] | 79 | #define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr ) |
| Martin Hořeňovský | 35c1301 | 2017-07-28 21:04:18 +0200 | [diff] [blame^] | 80 | #define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CATCH_REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr ) |
| 81 | #define CATCH_REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CATCH_REQUIRE_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::Normal, matcher, expr ) |
| Martin Hořeňovský | e1bca70 | 2017-04-25 20:20:46 +0200 | [diff] [blame] | 82 | #define CATCH_REQUIRE_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CATCH_REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, __VA_ARGS__ ) |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 83 | |
| Martin Hořeňovský | e1bca70 | 2017-04-25 20:20:46 +0200 | [diff] [blame] | 84 | #define CATCH_CHECK( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) |
| 85 | #define CATCH_CHECK_FALSE( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) |
| 86 | #define CATCH_CHECKED_IF( ... ) INTERNAL_CATCH_IF( "CATCH_CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) |
| 87 | #define CATCH_CHECKED_ELSE( ... ) INTERNAL_CATCH_ELSE( "CATCH_CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) |
| 88 | #define CATCH_CHECK_NOFAIL( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ ) |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 89 | |
| Martin Hořeňovský | e1bca70 | 2017-04-25 20:20:46 +0200 | [diff] [blame] | 90 | #define CATCH_CHECK_THROWS( ... ) INTERNAL_CATCH_THROWS( "CATCH_CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, "", __VA_ARGS__ ) |
| Phil Nash | f3ec843 | 2017-03-21 13:22:39 +0000 | [diff] [blame] | 91 | #define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr ) |
| Martin Hořeňovský | 35c1301 | 2017-07-28 21:04:18 +0200 | [diff] [blame^] | 92 | #define CATCH_CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CATCH_CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) |
| 93 | #define CATCH_CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CATCH_CHECK_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) |
| Martin Hořeňovský | e1bca70 | 2017-04-25 20:20:46 +0200 | [diff] [blame] | 94 | #define CATCH_CHECK_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CATCH_CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 95 | |
| Phil Nash | f3ec843 | 2017-03-21 13:22:39 +0000 | [diff] [blame] | 96 | #define CATCH_CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg ) |
| Martin Hořeňovský | 7a8a020 | 2017-03-17 13:21:40 +0100 | [diff] [blame] | 97 | |
| 98 | #if defined(CATCH_CONFIG_FAST_COMPILE) |
| Phil Nash | f3ec843 | 2017-03-21 13:22:39 +0000 | [diff] [blame] | 99 | #define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT_NO_TRY( "CATCH_REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg ) |
| Martin Hořeňovský | 7a8a020 | 2017-03-17 13:21:40 +0100 | [diff] [blame] | 100 | #else |
| Phil Nash | f3ec843 | 2017-03-21 13:22:39 +0000 | [diff] [blame] | 101 | #define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg ) |
| Martin Hořeňovský | 7a8a020 | 2017-03-17 13:21:40 +0100 | [diff] [blame] | 102 | #endif |
| 103 | |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 104 | |
| Phil Nash | f3ec843 | 2017-03-21 13:22:39 +0000 | [diff] [blame] | 105 | #define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( "CATCH_INFO", msg ) |
| 106 | #define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( "CATCH_WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg ) |
| 107 | #define CATCH_SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( "CATCH_INFO", msg ) |
| Martin Hořeňovský | 33ed177 | 2017-05-02 23:51:03 +0200 | [diff] [blame] | 108 | #define CATCH_CAPTURE( msg ) INTERNAL_CATCH_INFO( "CATCH_CAPTURE", #msg " := " << ::Catch::Detail::stringify(msg) ) |
| 109 | #define CATCH_SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( "CATCH_CAPTURE", #msg " := " << ::Catch::Detail::stringify(msg) ) |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 110 | |
| Martin Hořeňovský | 71df663 | 2017-04-25 12:41:30 +0200 | [diff] [blame] | 111 | #define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) |
| 112 | #define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) |
| 113 | #define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) |
| 114 | #define CATCH_REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) |
| 115 | #define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) |
| Martin Hořeňovský | 40130e5 | 2017-04-28 18:33:52 +0200 | [diff] [blame] | 116 | #define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ ) |
| Martin Hořeňovský | 71df663 | 2017-04-25 12:41:30 +0200 | [diff] [blame] | 117 | #define CATCH_FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) |
| 118 | #define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( "CATCH_SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) |
| 119 | |
| Phil Nash | f193698 | 2017-07-13 09:20:37 +0100 | [diff] [blame] | 120 | #define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE() |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 121 | |
| 122 | #define CATCH_REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) |
| 123 | |
| Phil Nash | 37186a1 | 2013-03-13 12:19:30 +0000 | [diff] [blame] | 124 | // "BDD-style" convenience wrappers |
| Phil Nash | 444f4dd | 2013-03-16 20:39:19 +0000 | [diff] [blame] | 125 | #define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( "Scenario: " __VA_ARGS__ ) |
| James Wilkinson | 63005a1 | 2014-07-10 10:22:20 +0100 | [diff] [blame] | 126 | #define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ ) |
| Phil Nash | f193698 | 2017-07-13 09:20:37 +0100 | [diff] [blame] | 127 | #define CATCH_GIVEN( desc ) CATCH_SECTION( std::string( "Given: ") + desc ) |
| 128 | #define CATCH_WHEN( desc ) CATCH_SECTION( std::string( " When: ") + desc ) |
| 129 | #define CATCH_AND_WHEN( desc ) CATCH_SECTION( std::string( " And: ") + desc ) |
| 130 | #define CATCH_THEN( desc ) CATCH_SECTION( std::string( " Then: ") + desc ) |
| 131 | #define CATCH_AND_THEN( desc ) CATCH_SECTION( std::string( " And: ") + desc ) |
| Phil Nash | 37186a1 | 2013-03-13 12:19:30 +0000 | [diff] [blame] | 132 | |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 133 | // If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required |
| 134 | #else |
| 135 | |
| Martin Hořeňovský | 7a8a020 | 2017-03-17 13:21:40 +0100 | [diff] [blame] | 136 | #if defined(CATCH_CONFIG_FAST_COMPILE) |
| Martin Hořeňovský | e1bca70 | 2017-04-25 20:20:46 +0200 | [diff] [blame] | 137 | #define REQUIRE( ... ) INTERNAL_CATCH_TEST_NO_TRY( "REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__ ) |
| 138 | #define REQUIRE_FALSE( ... ) INTERNAL_CATCH_TEST_NO_TRY( "REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) |
| Martin Hořeňovský | 7a8a020 | 2017-03-17 13:21:40 +0100 | [diff] [blame] | 139 | |
| 140 | #else |
| Martin Hořeňovský | e1bca70 | 2017-04-25 20:20:46 +0200 | [diff] [blame] | 141 | #define REQUIRE( ... ) INTERNAL_CATCH_TEST( "REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__ ) |
| 142 | #define REQUIRE_FALSE( ... ) INTERNAL_CATCH_TEST( "REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) |
| Martin Hořeňovský | 7a8a020 | 2017-03-17 13:21:40 +0100 | [diff] [blame] | 143 | #endif |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 144 | |
| Martin Hořeňovský | fae0fa4 | 2017-06-26 20:48:41 +0200 | [diff] [blame] | 145 | #define REQUIRE_THROWS( ... ) INTERNAL_CATCH_THROWS( "REQUIRE_THROWS", Catch::ResultDisposition::Normal, __VA_ARGS__ ) |
| Phil Nash | f3ec843 | 2017-03-21 13:22:39 +0000 | [diff] [blame] | 146 | #define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr ) |
| Martin Hořeňovský | fae0fa4 | 2017-06-26 20:48:41 +0200 | [diff] [blame] | 147 | #define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr ) |
| Martin Hořeňovský | 950cae9 | 2017-06-05 18:40:50 +0200 | [diff] [blame] | 148 | #define REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "REQUIRE_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::Normal, matcher, expr ) |
| Martin Hořeňovský | e1bca70 | 2017-04-25 20:20:46 +0200 | [diff] [blame] | 149 | #define REQUIRE_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, __VA_ARGS__ ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 150 | |
| Martin Hořeňovský | e1bca70 | 2017-04-25 20:20:46 +0200 | [diff] [blame] | 151 | #define CHECK( ... ) INTERNAL_CATCH_TEST( "CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) |
| 152 | #define CHECK_FALSE( ... ) INTERNAL_CATCH_TEST( "CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) |
| 153 | #define CHECKED_IF( ... ) INTERNAL_CATCH_IF( "CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) |
| 154 | #define CHECKED_ELSE( ... ) INTERNAL_CATCH_ELSE( "CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) |
| 155 | #define CHECK_NOFAIL( ... ) INTERNAL_CATCH_TEST( "CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 156 | |
| Martin Hořeňovský | fae0fa4 | 2017-06-26 20:48:41 +0200 | [diff] [blame] | 157 | #define CHECK_THROWS( ... ) INTERNAL_CATCH_THROWS( "CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) |
| Phil Nash | f3ec843 | 2017-03-21 13:22:39 +0000 | [diff] [blame] | 158 | #define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr ) |
| Martin Hořeňovský | fae0fa4 | 2017-06-26 20:48:41 +0200 | [diff] [blame] | 159 | #define CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) |
| Martin Hořeňovský | 950cae9 | 2017-06-05 18:40:50 +0200 | [diff] [blame] | 160 | #define CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CHECK_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) |
| Martin Hořeňovský | e1bca70 | 2017-04-25 20:20:46 +0200 | [diff] [blame] | 161 | #define CHECK_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 162 | |
| Phil Nash | f3ec843 | 2017-03-21 13:22:39 +0000 | [diff] [blame] | 163 | #define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg ) |
| Martin Hořeňovský | 7a8a020 | 2017-03-17 13:21:40 +0100 | [diff] [blame] | 164 | |
| 165 | #if defined(CATCH_CONFIG_FAST_COMPILE) |
| Phil Nash | f3ec843 | 2017-03-21 13:22:39 +0000 | [diff] [blame] | 166 | #define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT_NO_TRY( "REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg ) |
| Martin Hořeňovský | 7a8a020 | 2017-03-17 13:21:40 +0100 | [diff] [blame] | 167 | #else |
| Phil Nash | f3ec843 | 2017-03-21 13:22:39 +0000 | [diff] [blame] | 168 | #define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg ) |
| Martin Hořeňovský | 7a8a020 | 2017-03-17 13:21:40 +0100 | [diff] [blame] | 169 | #endif |
| 170 | |
| Phil Nash | eca5637 | 2012-03-04 11:14:21 +0000 | [diff] [blame] | 171 | |
| Phil Nash | f3ec843 | 2017-03-21 13:22:39 +0000 | [diff] [blame] | 172 | #define INFO( msg ) INTERNAL_CATCH_INFO( "INFO", msg ) |
| 173 | #define WARN( msg ) INTERNAL_CATCH_MSG( "WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg ) |
| 174 | #define SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( "INFO", msg ) |
| Martin Hořeňovský | 33ed177 | 2017-05-02 23:51:03 +0200 | [diff] [blame] | 175 | #define CAPTURE( msg ) INTERNAL_CATCH_INFO( "CAPTURE", #msg " := " << ::Catch::Detail::stringify(msg) ) |
| 176 | #define SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( "CAPTURE", #msg " := " << ::Catch::Detail::stringify(msg) ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 177 | |
| Phil Nash | 5dd0639 | 2017-03-08 15:40:20 +0000 | [diff] [blame] | 178 | #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) |
| 179 | #define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) |
| 180 | #define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) |
| 181 | #define REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) |
| 182 | #define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) |
| Phil Nash | f3ec843 | 2017-03-21 13:22:39 +0000 | [diff] [blame] | 183 | #define FAIL( ... ) INTERNAL_CATCH_MSG( "FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ ) |
| 184 | #define FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) |
| 185 | #define SUCCEED( ... ) INTERNAL_CATCH_MSG( "SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) |
| Phil Nash | f193698 | 2017-07-13 09:20:37 +0100 | [diff] [blame] | 186 | #define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE() |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 187 | |
| Phil Nash | 5cad9d5 | 2011-01-27 22:29:36 +0000 | [diff] [blame] | 188 | #define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) |
| 189 | |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 190 | #endif |
| 191 | |
| 192 | #define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 193 | |
| Phil Nash | 37186a1 | 2013-03-13 12:19:30 +0000 | [diff] [blame] | 194 | // "BDD-style" convenience wrappers |
| Phil Nash | 444f4dd | 2013-03-16 20:39:19 +0000 | [diff] [blame] | 195 | #define SCENARIO( ... ) TEST_CASE( "Scenario: " __VA_ARGS__ ) |
| James Wilkinson | 63005a1 | 2014-07-10 10:22:20 +0100 | [diff] [blame] | 196 | #define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ ) |
| Martin Hořeňovský | 71df663 | 2017-04-25 12:41:30 +0200 | [diff] [blame] | 197 | |
| Phil Nash | f193698 | 2017-07-13 09:20:37 +0100 | [diff] [blame] | 198 | #define GIVEN( desc ) SECTION( std::string(" Given: ") + desc ) |
| 199 | #define WHEN( desc ) SECTION( std::string(" When: ") + desc ) |
| 200 | #define AND_WHEN( desc ) SECTION( std::string("And when: ") + desc ) |
| 201 | #define THEN( desc ) SECTION( std::string(" Then: ") + desc ) |
| 202 | #define AND_THEN( desc ) SECTION( std::string(" And: ") + desc ) |
| Phil Nash | 37186a1 | 2013-03-13 12:19:30 +0000 | [diff] [blame] | 203 | |
| Phil Nash | 01db6c4 | 2011-04-04 07:56:44 +0100 | [diff] [blame] | 204 | using Catch::Detail::Approx; |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 205 | |
| Phil Nash | 3bdc97d | 2014-05-19 18:57:14 +0100 | [diff] [blame] | 206 | #include "internal/catch_reenable_warnings.h" |
| Phil Nash | a695eb9 | 2012-08-13 07:46:10 +0100 | [diff] [blame] | 207 | |
| Phil Nash | 73acd94 | 2011-02-16 19:02:09 +0000 | [diff] [blame] | 208 | #endif // TWOBLUECUBES_CATCH_HPP_INCLUDED |