| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * catch.hpp |
| 3 | * Catch |
| 4 | * |
| 5 | * Created by Phil on 22/10/2010. |
| 6 | * Copyright 2010 Two Blue Cubes Ltd |
| 7 | * |
| 8 | * Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 9 | * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 10 | * |
| 11 | */ |
| 12 | |
| 13 | /* TBD: |
| 14 | |
| 15 | Next: |
| 16 | |
| 17 | Later: |
| 18 | Finish command line parser (list as xml, specify FP tolerance) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 19 | Revisit Approx() |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 20 | Tags? |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 21 | Finish macros, listed here, later (just CHECK_NOFAIL now) |
| 22 | */ |
| 23 | #ifndef TWOBLUECUBES_CATCH_HPP_INCLUDED |
| 24 | #define TWOBLUECUBES_CATCH_HPP_INCLUDED |
| 25 | |
| Phil Nash | aca80a1 | 2010-12-31 22:54:35 +0000 | [diff] [blame] | 26 | #include "internal/catch_hub.h" |
| Phil Nash | 896a04f | 2011-01-05 21:16:54 +0000 | [diff] [blame] | 27 | #include "internal/catch_test_registry.hpp" |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 28 | #include "internal/catch_capture.hpp" |
| 29 | #include "internal/catch_section.hpp" |
| Phil Nash | 5cad9d5 | 2011-01-27 22:29:36 +0000 | [diff] [blame] | 30 | #include "internal/catch_generators.hpp" |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 31 | |
| 32 | ////// |
| 33 | |
| Phil Nash | a2d2095 | 2010-12-14 09:00:09 +0000 | [diff] [blame] | 34 | #define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, false, true, "REQUIRE" ) |
| 35 | #define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, true, true, "REQUIRE_FALSE" ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 36 | |
| Phil Nash | a2d2095 | 2010-12-14 09:00:09 +0000 | [diff] [blame] | 37 | #define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., false, true, "REQUIRE_THROWS" ) |
| 38 | #define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, false, true, "REQUIRE_THROWS_AS" ) |
| 39 | #define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_THROWS_AS( expr, Catch::DummyExceptionType_DontUse, true, true, "REQUIRE_NOTHROW" ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 40 | |
| Phil Nash | 3455e55 | 2010-11-10 07:42:15 +0000 | [diff] [blame] | 41 | #define CHECK( expr ) INTERNAL_CATCH_TEST( expr, false, false, "CHECK" ) |
| Phil Nash | a2d2095 | 2010-12-14 09:00:09 +0000 | [diff] [blame] | 42 | #define CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, true, false, "CHECK_FALSE" ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 43 | |
| Phil Nash | 3455e55 | 2010-11-10 07:42:15 +0000 | [diff] [blame] | 44 | #define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., false. false, "CHECK_THROWS" ) |
| 45 | #define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, false, false, "CHECK_THROWS_AS" ) |
| 46 | #define CHECK_NOTHROW( expr ) INTERNAL_CATCH_THROWS_AS( expr, Catch::DummyExceptionType_DontUse, true, false, "CHECK_NOTHROW" ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 47 | |
| Phil Nash | 3455e55 | 2010-11-10 07:42:15 +0000 | [diff] [blame] | 48 | #define INFO( reason ) INTERNAL_CATCH_MSG( reason, Catch::ResultWas::Info, false, "INFO" ) |
| 49 | #define WARN( reason ) INTERNAL_CATCH_MSG( reason, Catch::ResultWas::Warning, false, "WARN" ) |
| 50 | #define FAIL( reason ) INTERNAL_CATCH_MSG( reason, Catch::ResultWas::ExplicitFailure, true, "FAIL" ) |
| Phil Nash | 0025668 | 2010-12-27 11:09:34 +0000 | [diff] [blame] | 51 | #define SCOPED_INFO( log ) INTERNAL_CATCH_SCOPED_INFO( log ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 52 | |
| Phil Nash | 5cad9d5 | 2011-01-27 22:29:36 +0000 | [diff] [blame] | 53 | #define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 54 | |
| Phil Nash | 3455e55 | 2010-11-10 07:42:15 +0000 | [diff] [blame] | 55 | #define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description ) |
| Phil Nash | d1ee964 | 2011-01-31 20:15:40 +0000 | [diff] [blame] | 56 | #define TEST_CASE_NORETURN( name, description ) INTERNAL_CATCH_TESTCASE_NORETURN( name, description ) |
| Phil Nash | 2b05dfa | 2011-01-18 20:09:21 +0000 | [diff] [blame] | 57 | #define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "Anonymous test case" ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 58 | #define METHOD_AS_TEST_CASE( method, name, description ) CATCH_METHOD_AS_TEST_CASE( method, name, description ) |
| 59 | |
| Phil Nash | 5cad9d5 | 2011-01-27 22:29:36 +0000 | [diff] [blame] | 60 | #define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) |
| 61 | |
| 62 | #define GENERATE( expr) INTERNAL_CATCH_GENERATE( expr ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 63 | |
| 64 | /////////////// |
| 65 | // Still to be implemented |
| Phil Nash | 3455e55 | 2010-11-10 07:42:15 +0000 | [diff] [blame] | 66 | #define CHECK_NOFAIL( expr ) // !TBD - reports violation, but doesn't fail Test |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 67 | |
| 68 | using Catch::Approx; |
| 69 | |
| Phil Nash | 73acd94 | 2011-02-16 19:02:09 +0000 | [diff] [blame^] | 70 | #endif // TWOBLUECUBES_CATCH_HPP_INCLUDED |