| 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 | cda2149 | 2012-08-16 18:47:41 +0100 | [diff] [blame] | 12 | #ifdef __clang__ |
| Phil Nash | 778f9c4 | 2012-10-30 09:09:30 +0000 | [diff] [blame] | 13 | #pragma clang diagnostic ignored "-Wglobal-constructors" |
| Phil Nash | a695eb9 | 2012-08-13 07:46:10 +0100 | [diff] [blame] | 14 | |
| 15 | #pragma clang diagnostic push |
| 16 | #pragma clang diagnostic ignored "-Wpadded" |
| Phil Nash | cda2149 | 2012-08-16 18:47:41 +0100 | [diff] [blame] | 17 | #endif |
| Phil Nash | a695eb9 | 2012-08-13 07:46:10 +0100 | [diff] [blame] | 18 | |
| Phil Nash | 1091ca8 | 2012-08-06 20:16:53 +0100 | [diff] [blame] | 19 | #include "internal/catch_notimplemented_exception.h" |
| Phil Nash | 5ec53b2 | 2012-05-10 07:58:48 +0100 | [diff] [blame] | 20 | #include "internal/catch_context.h" |
| Phil Nash | 896a04f | 2011-01-05 21:16:54 +0000 | [diff] [blame] | 21 | #include "internal/catch_test_registry.hpp" |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 22 | #include "internal/catch_capture.hpp" |
| 23 | #include "internal/catch_section.hpp" |
| Phil Nash | 5cad9d5 | 2011-01-27 22:29:36 +0000 | [diff] [blame] | 24 | #include "internal/catch_generators.hpp" |
| Phil Nash | 9430a2c | 2011-04-20 15:40:40 +0100 | [diff] [blame] | 25 | #include "internal/catch_interfaces_exception.h" |
| Phil Nash | d7c203c | 2011-04-28 08:03:28 +0100 | [diff] [blame] | 26 | #include "internal/catch_approx.hpp" |
| Phil Nash | a6a40b3 | 2012-03-04 20:10:36 +0000 | [diff] [blame] | 27 | #include "internal/catch_matchers.hpp" |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 28 | |
| Phil Nash | 0f9c551 | 2012-06-02 23:12:42 +0100 | [diff] [blame] | 29 | // These files are included here so the single_include script doesn't put them |
| 30 | // in the conditionally compiled sections |
| Phil Nash | ddfe963 | 2012-08-14 19:30:30 +0100 | [diff] [blame] | 31 | #include "internal/catch_test_case_info.h" |
| Phil Nash | 0f9c551 | 2012-06-02 23:12:42 +0100 | [diff] [blame] | 32 | #include "internal/catch_interfaces_runner.h" |
| 33 | |
| Phil Nash | 8350ef6 | 2011-08-12 18:52:10 +0100 | [diff] [blame] | 34 | #ifdef __OBJC__ |
| 35 | #include "internal/catch_objc.hpp" |
| 36 | #endif |
| 37 | |
| Phil Nash | 89d1e6c | 2011-05-24 08:23:02 +0100 | [diff] [blame] | 38 | #if defined( CATCH_CONFIG_MAIN ) || defined( CATCH_CONFIG_RUNNER ) |
| Phil Nash | 1091ca8 | 2012-08-06 20:16:53 +0100 | [diff] [blame] | 39 | #include "internal/catch_impl.hpp" |
| Phil Nash | 89d1e6c | 2011-05-24 08:23:02 +0100 | [diff] [blame] | 40 | #endif |
| 41 | |
| 42 | #ifdef CATCH_CONFIG_MAIN |
| 43 | #include "internal/catch_default_main.hpp" |
| 44 | #endif |
| 45 | |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 46 | ////// |
| 47 | |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 48 | // If this config identifier is defined then all CATCH macros are prefixed with CATCH_ |
| 49 | #ifdef CATCH_CONFIG_PREFIX_ALL |
| 50 | |
| 51 | #define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, false, true, "CATCH_REQUIRE" ) |
| 52 | #define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, true, true, "CATCH_REQUIRE_FALSE" ) |
| 53 | |
| 54 | #define CATCH_REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., true, "CATCH_REQUIRE_THROWS" ) |
| 55 | #define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, true, "CATCH_REQUIRE_THROWS_AS" ) |
| 56 | #define CATCH_REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, true, "CATCH_REQUIRE_NOTHROW" ) |
| 57 | |
| 58 | #define CATCH_CHECK( expr ) INTERNAL_CATCH_TEST( expr, false, false, "CATCH_CHECK" ) |
| 59 | #define CATCH_CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, true, false, "CATCH_CHECK_FALSE" ) |
| 60 | #define CATCH_CHECKED_IF( expr ) INTERNAL_CATCH_IF( expr, false, false, "CATCH_CHECKED_IF" ) |
| 61 | #define CATCH_CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, false, false, "CATCH_CHECKED_ELSE" ) |
| 62 | |
| 63 | #define CATCH_CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., false, "CATCH_CHECK_THROWS" ) |
| 64 | #define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, false, "CATCH_CHECK_THROWS_AS" ) |
| 65 | #define CATCH_CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, false, "CATCH_CHECK_NOTHROW" ) |
| 66 | |
| 67 | #define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, false, "CATCH_CHECK_THAT" ) |
| 68 | #define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, true, "CATCH_REQUIRE_THAT" ) |
| 69 | |
| 70 | #define CATCH_INFO( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Info, false, "CATCH_INFO" ) |
| 71 | #define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Warning, false, "CATCH_WARN" ) |
| 72 | #define CATCH_FAIL( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::ExplicitFailure, true, "CATCH_FAIL" ) |
| Phil Nash | 74d1d31 | 2012-08-31 18:37:47 +0100 | [diff] [blame] | 73 | #define CATCH_SUCCEED( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Ok, false, "CATCH_SUCCEED" ) |
| Phil Nash | e04e74f | 2012-10-24 21:59:47 +0100 | [diff] [blame] | 74 | #define CATCH_SCOPED_INFO( msg ) INTERNAL_CATCH_SCOPED_INFO( msg, "CATCH_SCOPED_INFO" ) |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 75 | #define CATCH_CAPTURE( msg ) INTERNAL_CATCH_MSG( #msg " := " << msg, Catch::ResultWas::Info, false, "CATCH_CAPTURE" ) |
| Phil Nash | e04e74f | 2012-10-24 21:59:47 +0100 | [diff] [blame] | 76 | #define CATCH_SCOPED_CAPTURE( msg ) INTERNAL_CATCH_SCOPED_INFO( #msg " := " << msg, "CATCH_SCOPED_CAPTURE" ) |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 77 | |
| 78 | #define CATCH_SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description ) |
| 79 | |
| 80 | #define CATCH_TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description ) |
| 81 | #define CATCH_TEST_CASE_NORETURN( name, description ) INTERNAL_CATCH_TESTCASE_NORETURN( name, description ) |
| 82 | #define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "Anonymous test case" ) |
| 83 | #define CATCH_METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description ) |
| 84 | |
| 85 | #define CATCH_REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) |
| 86 | |
| 87 | #define CATCH_GENERATE( expr) INTERNAL_CATCH_GENERATE( expr ) |
| 88 | |
| 89 | /////////////// |
| 90 | // Still to be implemented |
| 91 | //#define CHECK_NOFAIL( expr ) // !TBD - reports violation, but doesn't fail Test |
| 92 | |
| 93 | // If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required |
| 94 | #else |
| 95 | |
| Phil Nash | a2d2095 | 2010-12-14 09:00:09 +0000 | [diff] [blame] | 96 | #define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, false, true, "REQUIRE" ) |
| 97 | #define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, true, true, "REQUIRE_FALSE" ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 98 | |
| Phil Nash | c27e6dc | 2011-03-14 08:49:42 +0000 | [diff] [blame] | 99 | #define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., true, "REQUIRE_THROWS" ) |
| 100 | #define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, true, "REQUIRE_THROWS_AS" ) |
| Phil Nash | 0dc4508 | 2011-03-14 08:45:55 +0000 | [diff] [blame] | 101 | #define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, true, "REQUIRE_NOTHROW" ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 102 | |
| Phil Nash | 3455e55 | 2010-11-10 07:42:15 +0000 | [diff] [blame] | 103 | #define CHECK( expr ) INTERNAL_CATCH_TEST( expr, false, false, "CHECK" ) |
| Phil Nash | a2d2095 | 2010-12-14 09:00:09 +0000 | [diff] [blame] | 104 | #define CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, true, false, "CHECK_FALSE" ) |
| Phil Nash | a162e22 | 2012-02-10 08:30:13 +0000 | [diff] [blame] | 105 | #define CHECKED_IF( expr ) INTERNAL_CATCH_IF( expr, false, false, "CHECKED_IF" ) |
| 106 | #define CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( expr, false, false, "CHECKED_ELSE" ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 107 | |
| Phil Nash | c27e6dc | 2011-03-14 08:49:42 +0000 | [diff] [blame] | 108 | #define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., false, "CHECK_THROWS" ) |
| 109 | #define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, false, "CHECK_THROWS_AS" ) |
| Phil Nash | 0dc4508 | 2011-03-14 08:45:55 +0000 | [diff] [blame] | 110 | #define CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, false, "CHECK_NOTHROW" ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 111 | |
| Phil Nash | eca5637 | 2012-03-04 11:14:21 +0000 | [diff] [blame] | 112 | #define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, false, "CHECK_THAT" ) |
| 113 | #define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( arg, matcher, true, "REQUIRE_THAT" ) |
| 114 | |
| Phil Nash | e401601 | 2011-02-28 19:01:04 +0000 | [diff] [blame] | 115 | #define INFO( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Info, false, "INFO" ) |
| 116 | #define WARN( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Warning, false, "WARN" ) |
| 117 | #define FAIL( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::ExplicitFailure, true, "FAIL" ) |
| Phil Nash | a70fbe3 | 2012-08-31 08:10:36 +0100 | [diff] [blame] | 118 | #define SUCCEED( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Ok, false, "SUCCEED" ) |
| Phil Nash | e04e74f | 2012-10-24 21:59:47 +0100 | [diff] [blame] | 119 | #define SCOPED_INFO( msg ) INTERNAL_CATCH_SCOPED_INFO( msg, "SCOPED_INFO" ) |
| Phil Nash | e401601 | 2011-02-28 19:01:04 +0000 | [diff] [blame] | 120 | #define CAPTURE( msg ) INTERNAL_CATCH_MSG( #msg " := " << msg, Catch::ResultWas::Info, false, "CAPTURE" ) |
| Phil Nash | e04e74f | 2012-10-24 21:59:47 +0100 | [diff] [blame] | 121 | #define SCOPED_CAPTURE( msg ) INTERNAL_CATCH_SCOPED_INFO( #msg " := " << msg, "SCOPED_CAPTURE" ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 122 | |
| Phil Nash | 5cad9d5 | 2011-01-27 22:29:36 +0000 | [diff] [blame] | 123 | #define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 124 | |
| Phil Nash | 3455e55 | 2010-11-10 07:42:15 +0000 | [diff] [blame] | 125 | #define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description ) |
| Phil Nash | d1ee964 | 2011-01-31 20:15:40 +0000 | [diff] [blame] | 126 | #define TEST_CASE_NORETURN( name, description ) INTERNAL_CATCH_TESTCASE_NORETURN( name, description ) |
| Phil Nash | 2b05dfa | 2011-01-18 20:09:21 +0000 | [diff] [blame] | 127 | #define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "Anonymous test case" ) |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 128 | #define METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 129 | |
| Phil Nash | 5cad9d5 | 2011-01-27 22:29:36 +0000 | [diff] [blame] | 130 | #define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) |
| 131 | |
| 132 | #define GENERATE( expr) INTERNAL_CATCH_GENERATE( expr ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 133 | |
| Phil Nash | 46bcd4b | 2012-07-20 18:43:48 +0100 | [diff] [blame] | 134 | #endif |
| 135 | |
| 136 | #define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 137 | |
| Phil Nash | 01db6c4 | 2011-04-04 07:56:44 +0100 | [diff] [blame] | 138 | using Catch::Detail::Approx; |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 139 | |
| Phil Nash | cda2149 | 2012-08-16 18:47:41 +0100 | [diff] [blame] | 140 | #ifdef __clang__ |
| Phil Nash | a695eb9 | 2012-08-13 07:46:10 +0100 | [diff] [blame] | 141 | #pragma clang diagnostic pop |
| Phil Nash | cda2149 | 2012-08-16 18:47:41 +0100 | [diff] [blame] | 142 | #endif |
| Phil Nash | a695eb9 | 2012-08-13 07:46:10 +0100 | [diff] [blame] | 143 | |
| Phil Nash | 73acd94 | 2011-02-16 19:02:09 +0000 | [diff] [blame] | 144 | #endif // TWOBLUECUBES_CATCH_HPP_INCLUDED |