| 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) |
| 19 | INFO() stores messages until next result |
| 20 | Revisit Approx() |
| 21 | Extra reports |
| 22 | Tags? |
| 23 | Detect caught "Catch" exception, offer continuation based iteration instead |
| 24 | Finish macros, listed here, later (just CHECK_NOFAIL now) |
| 25 | */ |
| 26 | #ifndef TWOBLUECUBES_CATCH_HPP_INCLUDED |
| 27 | #define TWOBLUECUBES_CATCH_HPP_INCLUDED |
| 28 | |
| Phil Nash | aca80a1 | 2010-12-31 22:54:35 +0000 | [diff] [blame] | 29 | #include "internal/catch_hub.h" |
| Phil Nash | 896a04f | 2011-01-05 21:16:54 +0000 | [diff] [blame^] | 30 | #include "internal/catch_test_registry.hpp" |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 31 | #include "internal/catch_capture.hpp" |
| 32 | #include "internal/catch_section.hpp" |
| 33 | |
| 34 | ////// |
| 35 | |
| Phil Nash | a2d2095 | 2010-12-14 09:00:09 +0000 | [diff] [blame] | 36 | #define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, false, true, "REQUIRE" ) |
| 37 | #define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, true, true, "REQUIRE_FALSE" ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 38 | |
| Phil Nash | a2d2095 | 2010-12-14 09:00:09 +0000 | [diff] [blame] | 39 | #define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., false, true, "REQUIRE_THROWS" ) |
| 40 | #define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, false, true, "REQUIRE_THROWS_AS" ) |
| 41 | #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] | 42 | |
| Phil Nash | 3455e55 | 2010-11-10 07:42:15 +0000 | [diff] [blame] | 43 | #define CHECK( expr ) INTERNAL_CATCH_TEST( expr, false, false, "CHECK" ) |
| Phil Nash | a2d2095 | 2010-12-14 09:00:09 +0000 | [diff] [blame] | 44 | #define CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, true, false, "CHECK_FALSE" ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 45 | |
| Phil Nash | 3455e55 | 2010-11-10 07:42:15 +0000 | [diff] [blame] | 46 | #define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., false. false, "CHECK_THROWS" ) |
| 47 | #define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, false, false, "CHECK_THROWS_AS" ) |
| 48 | #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] | 49 | |
| Phil Nash | 3455e55 | 2010-11-10 07:42:15 +0000 | [diff] [blame] | 50 | #define INFO( reason ) INTERNAL_CATCH_MSG( reason, Catch::ResultWas::Info, false, "INFO" ) |
| 51 | #define WARN( reason ) INTERNAL_CATCH_MSG( reason, Catch::ResultWas::Warning, false, "WARN" ) |
| 52 | #define FAIL( reason ) INTERNAL_CATCH_MSG( reason, Catch::ResultWas::ExplicitFailure, true, "FAIL" ) |
| Phil Nash | 0025668 | 2010-12-27 11:09:34 +0000 | [diff] [blame] | 53 | #define SCOPED_INFO( log ) INTERNAL_CATCH_SCOPED_INFO( log ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 54 | |
| 55 | #define SECTION( name, description ) CATCH_SECTION( name, description ) |
| 56 | |
| Phil Nash | 3455e55 | 2010-11-10 07:42:15 +0000 | [diff] [blame] | 57 | #define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description ) |
| 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 | |
| 60 | #define REGISTER_REPORTER( name, reporterType ) CATCH_REGISTER_REPORTER( name, reporterType ) |
| 61 | |
| 62 | /////////////// |
| 63 | // Still to be implemented |
| Phil Nash | 3455e55 | 2010-11-10 07:42:15 +0000 | [diff] [blame] | 64 | #define CHECK_NOFAIL( expr ) // !TBD - reports violation, but doesn't fail Test |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 65 | |
| 66 | using Catch::Approx; |
| 67 | |
| 68 | #endif // TWOBLUECUBES_CATCH_HPP_INCLUDED |