| 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 | |
| 29 | #include "internal/catch_registry.hpp" |
| 30 | #include "internal/catch_capture.hpp" |
| 31 | #include "internal/catch_section.hpp" |
| 32 | |
| 33 | ////// |
| 34 | |
| Phil Nash | 3455e55 | 2010-11-10 07:42:15 +0000 | [diff] [blame] | 35 | #define EXPECT( expr ) INTERNAL_CATCH_TEST( expr, false, true, "EXPECT" ) |
| 36 | #define EXPECT_NOT( expr ) INTERNAL_CATCH_TEST( expr, true, true, "EXPECT_NOT" ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 37 | |
| Phil Nash | 3455e55 | 2010-11-10 07:42:15 +0000 | [diff] [blame] | 38 | #define EXPECT_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., false, true, "EXPECT_THROWS" ) |
| 39 | #define EXPECT_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, false, true, "EXPECT_THROWS_AS" ) |
| 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" ) |
| 42 | #define CHECK_NOT( expr ) INTERNAL_CATCH_TEST( expr, true, false, "CHECK_NOT" ) |
| 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 | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 51 | |
| 52 | #define SECTION( name, description ) CATCH_SECTION( name, description ) |
| 53 | |
| Phil Nash | 3455e55 | 2010-11-10 07:42:15 +0000 | [diff] [blame] | 54 | #define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description ) |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 55 | #define METHOD_AS_TEST_CASE( method, name, description ) CATCH_METHOD_AS_TEST_CASE( method, name, description ) |
| 56 | |
| 57 | #define REGISTER_REPORTER( name, reporterType ) CATCH_REGISTER_REPORTER( name, reporterType ) |
| 58 | |
| 59 | /////////////// |
| 60 | // Still to be implemented |
| Phil Nash | 3455e55 | 2010-11-10 07:42:15 +0000 | [diff] [blame] | 61 | #define CHECK_NOFAIL( expr ) // !TBD - reports violation, but doesn't fail Test |
| Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 62 | |
| 63 | using Catch::Approx; |
| 64 | |
| 65 | #endif // TWOBLUECUBES_CATCH_HPP_INCLUDED |