| 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 | 1091ca8 | 2012-08-06 20:16:53 +0100 | [diff] [blame] | 31 | #include "internal/catch_notimplemented_exception.h" |
| Phil Nash | 5ec53b2 | 2012-05-10 07:58:48 +0100 | [diff] [blame] | 32 | #include "internal/catch_context.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 | 5cad9d5 | 2011-01-27 22:29:36 +0000 | [diff] [blame] | 36 | #include "internal/catch_generators.hpp" |
| Phil Nash | 9430a2c | 2011-04-20 15:40:40 +0100 | [diff] [blame] | 37 | #include "internal/catch_interfaces_exception.h" |
| Phil Nash | d7c203c | 2011-04-28 08:03:28 +0100 | [diff] [blame] | 38 | #include "internal/catch_approx.hpp" |
| Phil Nash | 1400127 | 2017-02-08 15:14:51 +0000 | [diff] [blame^] | 39 | #include "internal/catch_matchers_string.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 | |
| Phil Nash | b2ef998 | 2012-11-10 10:35:09 +0000 | [diff] [blame] | 70 | #define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE" ) |
| Phil Nash | be9fe76 | 2014-05-29 08:00:20 +0100 | [diff] [blame] | 71 | #define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, "CATCH_REQUIRE_FALSE" ) |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 72 | |
| Phil Nash | 85de743 | 2015-07-13 06:34:41 +0100 | [diff] [blame] | 73 | #define CATCH_REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "", "CATCH_REQUIRE_THROWS" ) |
| Phil Nash | 1af13db | 2012-11-10 10:20:08 +0000 | [diff] [blame] | 74 | #define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THROWS_AS" ) |
| Phil Nash | 7286892 | 2015-07-15 23:02:25 +0100 | [diff] [blame] | 75 | #define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, matcher, "CATCH_REQUIRE_THROWS_WITH" ) |
| Phil Nash | 1af13db | 2012-11-10 10:20:08 +0000 | [diff] [blame] | 76 | #define CATCH_REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_NOTHROW" ) |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 77 | |
| Phil Nash | b2ef998 | 2012-11-10 10:35:09 +0000 | [diff] [blame] | 78 | #define CATCH_CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK" ) |
| Phil Nash | be9fe76 | 2014-05-29 08:00:20 +0100 | [diff] [blame] | 79 | #define CATCH_CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, "CATCH_CHECK_FALSE" ) |
| Phil Nash | b2ef998 | 2012-11-10 10:35:09 +0000 | [diff] [blame] | 80 | #define CATCH_CHECKED_IF( expr ) INTERNAL_CATCH_IF( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECKED_IF" ) |
| 81 | #define CATCH_CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECKED_ELSE" ) |
| Phil Nash | 7717c29 | 2012-11-13 09:45:29 +0000 | [diff] [blame] | 82 | #define CATCH_CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, "CATCH_CHECK_NOFAIL" ) |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 83 | |
| Kevin Ushey | 7d2668f | 2016-04-21 18:26:17 -0700 | [diff] [blame] | 84 | #define CATCH_CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "", "CATCH_CHECK_THROWS" ) |
| Phil Nash | 1af13db | 2012-11-10 10:20:08 +0000 | [diff] [blame] | 85 | #define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THROWS_AS" ) |
| Phil Nash | 7286892 | 2015-07-15 23:02:25 +0100 | [diff] [blame] | 86 | #define CATCH_CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, matcher, "CATCH_CHECK_THROWS_WITH" ) |
| Phil Nash | 1af13db | 2012-11-10 10:20:08 +0000 | [diff] [blame] | 87 | #define CATCH_CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_NOTHROW" ) |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 88 | |
| jbo-ableton | e12fc4a | 2015-07-27 00:25:56 +0200 | [diff] [blame] | 89 | #define CATCH_CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CATCH_CHECK_THAT" ) |
| Phil Nash | 1af13db | 2012-11-10 10:20:08 +0000 | [diff] [blame] | 90 | #define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::Normal, "CATCH_REQUIRE_THAT" ) |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 91 | |
| Phil Nash | 207b27b | 2013-02-02 19:58:04 +0000 | [diff] [blame] | 92 | #define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( msg, "CATCH_INFO" ) |
| Phil Nash | 274ed3e | 2013-12-12 23:02:31 +0000 | [diff] [blame] | 93 | #define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "CATCH_WARN", msg ) |
| Phil Nash | b5fd5a6 | 2013-06-28 17:09:57 +0100 | [diff] [blame] | 94 | #define CATCH_SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( msg, "CATCH_INFO" ) |
| Phil Nash | 207b27b | 2013-02-02 19:58:04 +0000 | [diff] [blame] | 95 | #define CATCH_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CATCH_CAPTURE" ) |
| Phil Nash | b5fd5a6 | 2013-06-28 17:09:57 +0100 | [diff] [blame] | 96 | #define CATCH_SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CATCH_CAPTURE" ) |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 97 | |
| Phil Nash | c0b6980 | 2013-03-16 20:18:52 +0000 | [diff] [blame] | 98 | #ifdef CATCH_CONFIG_VARIADIC_MACROS |
| 99 | #define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) |
| Phil Nash | 597ed1f | 2013-05-14 19:31:21 +0100 | [diff] [blame] | 100 | #define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) |
| Phil Nash | c0b6980 | 2013-03-16 20:18:52 +0000 | [diff] [blame] | 101 | #define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) |
| Phil Nash | aca16a0 | 2016-01-22 07:50:10 +0000 | [diff] [blame] | 102 | #define CATCH_REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) |
| Phil Nash | c0b6980 | 2013-03-16 20:18:52 +0000 | [diff] [blame] | 103 | #define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) |
| Phil Nash | 274ed3e | 2013-12-12 23:02:31 +0000 | [diff] [blame] | 104 | #define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", __VA_ARGS__ ) |
| Phil Nash | 557b3bd | 2013-12-14 23:16:03 +0000 | [diff] [blame] | 105 | #define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", __VA_ARGS__ ) |
| Phil Nash | c0b6980 | 2013-03-16 20:18:52 +0000 | [diff] [blame] | 106 | #else |
| 107 | #define CATCH_TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description ) |
| Phil Nash | 597ed1f | 2013-05-14 19:31:21 +0100 | [diff] [blame] | 108 | #define CATCH_TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description ) |
| Phil Nash | c0b6980 | 2013-03-16 20:18:52 +0000 | [diff] [blame] | 109 | #define CATCH_METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description ) |
| Phil Nash | 0e64973 | 2015-11-20 16:54:07 +0000 | [diff] [blame] | 110 | #define CATCH_REGISTER_TEST_CASE( function, name, description ) INTERNAL_CATCH_REGISTER_TESTCASE( function, name, description ) |
| Phil Nash | c0b6980 | 2013-03-16 20:18:52 +0000 | [diff] [blame] | 111 | #define CATCH_SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description ) |
| Phil Nash | 274ed3e | 2013-12-12 23:02:31 +0000 | [diff] [blame] | 112 | #define CATCH_FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", msg ) |
| Phil Nash | 557b3bd | 2013-12-14 23:16:03 +0000 | [diff] [blame] | 113 | #define CATCH_SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", msg ) |
| Phil Nash | c0b6980 | 2013-03-16 20:18:52 +0000 | [diff] [blame] | 114 | #endif |
| 115 | #define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" ) |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 116 | |
| 117 | #define CATCH_REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) |
| Phil Nash | 8255acf | 2012-11-30 19:29:03 +0000 | [diff] [blame] | 118 | #define CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 119 | |
| 120 | #define CATCH_GENERATE( expr) INTERNAL_CATCH_GENERATE( expr ) |
| 121 | |
| Phil Nash | 37186a1 | 2013-03-13 12:19:30 +0000 | [diff] [blame] | 122 | // "BDD-style" convenience wrappers |
| Phil Nash | 444f4dd | 2013-03-16 20:39:19 +0000 | [diff] [blame] | 123 | #ifdef CATCH_CONFIG_VARIADIC_MACROS |
| 124 | #define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( "Scenario: " __VA_ARGS__ ) |
| James Wilkinson | 63005a1 | 2014-07-10 10:22:20 +0100 | [diff] [blame] | 125 | #define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ ) |
| Phil Nash | 444f4dd | 2013-03-16 20:39:19 +0000 | [diff] [blame] | 126 | #else |
| Phil Nash | 37186a1 | 2013-03-13 12:19:30 +0000 | [diff] [blame] | 127 | #define CATCH_SCENARIO( name, tags ) CATCH_TEST_CASE( "Scenario: " name, tags ) |
| James Wilkinson | 63005a1 | 2014-07-10 10:22:20 +0100 | [diff] [blame] | 128 | #define CATCH_SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags ) |
| Phil Nash | 444f4dd | 2013-03-16 20:39:19 +0000 | [diff] [blame] | 129 | #endif |
| Phil Nash | 6de135c | 2015-07-22 18:07:28 +0100 | [diff] [blame] | 130 | #define CATCH_GIVEN( desc ) CATCH_SECTION( std::string( "Given: ") + desc, "" ) |
| 131 | #define CATCH_WHEN( desc ) CATCH_SECTION( std::string( " When: ") + desc, "" ) |
| 132 | #define CATCH_AND_WHEN( desc ) CATCH_SECTION( std::string( " And: ") + desc, "" ) |
| 133 | #define CATCH_THEN( desc ) CATCH_SECTION( std::string( " Then: ") + desc, "" ) |
| 134 | #define CATCH_AND_THEN( desc ) CATCH_SECTION( std::string( " And: ") + desc, "" ) |
| Phil Nash | 37186a1 | 2013-03-13 12:19:30 +0000 | [diff] [blame] | 135 | |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 136 | // If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required |
| 137 | #else |
| 138 | |
| Phil Nash | b2ef998 | 2012-11-10 10:35:09 +0000 | [diff] [blame] | 139 | #define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal, "REQUIRE" ) |
| Phil Nash | be9fe76 | 2014-05-29 08:00:20 +0100 | [diff] [blame] | 140 | #define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, "REQUIRE_FALSE" ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 141 | |
| Phil Nash | 85de743 | 2015-07-13 06:34:41 +0100 | [diff] [blame] | 142 | #define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, "", "REQUIRE_THROWS" ) |
| Phil Nash | 1af13db | 2012-11-10 10:20:08 +0000 | [diff] [blame] | 143 | #define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::Normal, "REQUIRE_THROWS_AS" ) |
| Phil Nash | 7286892 | 2015-07-15 23:02:25 +0100 | [diff] [blame] | 144 | #define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::Normal, matcher, "REQUIRE_THROWS_WITH" ) |
| Phil Nash | 1af13db | 2012-11-10 10:20:08 +0000 | [diff] [blame] | 145 | #define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::Normal, "REQUIRE_NOTHROW" ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 146 | |
| Phil Nash | b2ef998 | 2012-11-10 10:35:09 +0000 | [diff] [blame] | 147 | #define CHECK( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK" ) |
| Phil Nash | be9fe76 | 2014-05-29 08:00:20 +0100 | [diff] [blame] | 148 | #define CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, "CHECK_FALSE" ) |
| Phil Nash | b2ef998 | 2012-11-10 10:35:09 +0000 | [diff] [blame] | 149 | #define CHECKED_IF( expr ) INTERNAL_CATCH_IF( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_IF" ) |
| 150 | #define CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECKED_ELSE" ) |
| Phil Nash | d539da9 | 2012-11-13 09:44:52 +0000 | [diff] [blame] | 151 | #define CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( expr, Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, "CHECK_NOFAIL" ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 152 | |
| Phil Nash | 85de743 | 2015-07-13 06:34:41 +0100 | [diff] [blame] | 153 | #define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, "", "CHECK_THROWS" ) |
| Phil Nash | 1af13db | 2012-11-10 10:20:08 +0000 | [diff] [blame] | 154 | #define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THROWS_AS" ) |
| Phil Nash | 7286892 | 2015-07-15 23:02:25 +0100 | [diff] [blame] | 155 | #define CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( expr, Catch::ResultDisposition::ContinueOnFailure, matcher, "CHECK_THROWS_WITH" ) |
| Phil Nash | 1af13db | 2012-11-10 10:20:08 +0000 | [diff] [blame] | 156 | #define CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, Catch::ResultDisposition::ContinueOnFailure, "CHECK_NOTHROW" ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 157 | |
| Phil Nash | 1af13db | 2012-11-10 10:20:08 +0000 | [diff] [blame] | 158 | #define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::ContinueOnFailure, "CHECK_THAT" ) |
| 159 | #define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, Catch::ResultDisposition::Normal, "REQUIRE_THAT" ) |
| Phil Nash | eca5637 | 2012-03-04 11:14:21 +0000 | [diff] [blame] | 160 | |
| Phil Nash | 207b27b | 2013-02-02 19:58:04 +0000 | [diff] [blame] | 161 | #define INFO( msg ) INTERNAL_CATCH_INFO( msg, "INFO" ) |
| Phil Nash | 274ed3e | 2013-12-12 23:02:31 +0000 | [diff] [blame] | 162 | #define WARN( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, "WARN", msg ) |
| Phil Nash | b5fd5a6 | 2013-06-28 17:09:57 +0100 | [diff] [blame] | 163 | #define SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( msg, "INFO" ) |
| Phil Nash | 207b27b | 2013-02-02 19:58:04 +0000 | [diff] [blame] | 164 | #define CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CAPTURE" ) |
| Phil Nash | b5fd5a6 | 2013-06-28 17:09:57 +0100 | [diff] [blame] | 165 | #define SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( #msg " := " << msg, "CAPTURE" ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 166 | |
| Phil Nash | c0b6980 | 2013-03-16 20:18:52 +0000 | [diff] [blame] | 167 | #ifdef CATCH_CONFIG_VARIADIC_MACROS |
| 168 | #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) |
| Phil Nash | 597ed1f | 2013-05-14 19:31:21 +0100 | [diff] [blame] | 169 | #define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) |
| Phil Nash | c0b6980 | 2013-03-16 20:18:52 +0000 | [diff] [blame] | 170 | #define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) |
| Phil Nash | f294c98 | 2016-01-05 08:19:16 +0000 | [diff] [blame] | 171 | #define REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) |
| Phil Nash | c0b6980 | 2013-03-16 20:18:52 +0000 | [diff] [blame] | 172 | #define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) |
| Phil Nash | 274ed3e | 2013-12-12 23:02:31 +0000 | [diff] [blame] | 173 | #define FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", __VA_ARGS__ ) |
| Phil Nash | 557b3bd | 2013-12-14 23:16:03 +0000 | [diff] [blame] | 174 | #define SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", __VA_ARGS__ ) |
| Phil Nash | c0b6980 | 2013-03-16 20:18:52 +0000 | [diff] [blame] | 175 | #else |
| 176 | #define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description ) |
| Phil Nash | 597ed1f | 2013-05-14 19:31:21 +0100 | [diff] [blame] | 177 | #define TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description ) |
| Phil Nash | c0b6980 | 2013-03-16 20:18:52 +0000 | [diff] [blame] | 178 | #define METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description ) |
| Phil Nash | 2106d82 | 2015-12-09 18:24:29 +0000 | [diff] [blame] | 179 | #define REGISTER_TEST_CASE( method, name, description ) INTERNAL_CATCH_REGISTER_TESTCASE( method, name, description ) |
| Phil Nash | c0b6980 | 2013-03-16 20:18:52 +0000 | [diff] [blame] | 180 | #define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description ) |
| Phil Nash | 274ed3e | 2013-12-12 23:02:31 +0000 | [diff] [blame] | 181 | #define FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", msg ) |
| Phil Nash | 557b3bd | 2013-12-14 23:16:03 +0000 | [diff] [blame] | 182 | #define SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", msg ) |
| Phil Nash | c0b6980 | 2013-03-16 20:18:52 +0000 | [diff] [blame] | 183 | #endif |
| 184 | #define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 185 | |
| Phil Nash | 5cad9d5 | 2011-01-27 22:29:36 +0000 | [diff] [blame] | 186 | #define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) |
| Phil Nash | 8255acf | 2012-11-30 19:29:03 +0000 | [diff] [blame] | 187 | #define REGISTER_LEGACY_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) |
| Phil Nash | 5cad9d5 | 2011-01-27 22:29:36 +0000 | [diff] [blame] | 188 | |
| 189 | #define GENERATE( expr) INTERNAL_CATCH_GENERATE( expr ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 190 | |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 191 | #endif |
| 192 | |
| 193 | #define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 194 | |
| Phil Nash | 37186a1 | 2013-03-13 12:19:30 +0000 | [diff] [blame] | 195 | // "BDD-style" convenience wrappers |
| Phil Nash | 444f4dd | 2013-03-16 20:39:19 +0000 | [diff] [blame] | 196 | #ifdef CATCH_CONFIG_VARIADIC_MACROS |
| 197 | #define SCENARIO( ... ) TEST_CASE( "Scenario: " __VA_ARGS__ ) |
| James Wilkinson | 63005a1 | 2014-07-10 10:22:20 +0100 | [diff] [blame] | 198 | #define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ ) |
| Phil Nash | 444f4dd | 2013-03-16 20:39:19 +0000 | [diff] [blame] | 199 | #else |
| Phil Nash | 37186a1 | 2013-03-13 12:19:30 +0000 | [diff] [blame] | 200 | #define SCENARIO( name, tags ) TEST_CASE( "Scenario: " name, tags ) |
| James Wilkinson | 63005a1 | 2014-07-10 10:22:20 +0100 | [diff] [blame] | 201 | #define SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags ) |
| Phil Nash | 444f4dd | 2013-03-16 20:39:19 +0000 | [diff] [blame] | 202 | #endif |
| Phil Nash | 6de135c | 2015-07-22 18:07:28 +0100 | [diff] [blame] | 203 | #define GIVEN( desc ) SECTION( std::string(" Given: ") + desc, "" ) |
| 204 | #define WHEN( desc ) SECTION( std::string(" When: ") + desc, "" ) |
| 205 | #define AND_WHEN( desc ) SECTION( std::string("And when: ") + desc, "" ) |
| 206 | #define THEN( desc ) SECTION( std::string(" Then: ") + desc, "" ) |
| 207 | #define AND_THEN( desc ) SECTION( std::string(" And: ") + desc, "" ) |
| Phil Nash | 37186a1 | 2013-03-13 12:19:30 +0000 | [diff] [blame] | 208 | |
| Phil Nash | 01db6c4 | 2011-04-04 07:56:44 +0100 | [diff] [blame] | 209 | using Catch::Detail::Approx; |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 210 | |
| Phil Nash | 3bdc97d | 2014-05-19 18:57:14 +0100 | [diff] [blame] | 211 | #include "internal/catch_reenable_warnings.h" |
| Phil Nash | a695eb9 | 2012-08-13 07:46:10 +0100 | [diff] [blame] | 212 | |
| Phil Nash | 73acd94 | 2011-02-16 19:02:09 +0000 | [diff] [blame] | 213 | #endif // TWOBLUECUBES_CATCH_HPP_INCLUDED |