blob: 0dcb9b52134ad5ff99200155688af2d50533eeee [file] [log] [blame]
Phil Nashd8026002010-11-09 23:24:00 +00001/*
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 Nashaca80a12010-12-31 22:54:35 +000029#include "internal/catch_hub.h"
Phil Nash896a04f2011-01-05 21:16:54 +000030#include "internal/catch_test_registry.hpp"
Phil Nashd8026002010-11-09 23:24:00 +000031#include "internal/catch_capture.hpp"
32#include "internal/catch_section.hpp"
33
34//////
35
Phil Nasha2d20952010-12-14 09:00:09 +000036#define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, false, true, "REQUIRE" )
37#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, true, true, "REQUIRE_FALSE" )
Phil Nashd8026002010-11-09 23:24:00 +000038
Phil Nasha2d20952010-12-14 09:00:09 +000039#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 Nashd8026002010-11-09 23:24:00 +000042
Phil Nash3455e552010-11-10 07:42:15 +000043#define CHECK( expr ) INTERNAL_CATCH_TEST( expr, false, false, "CHECK" )
Phil Nasha2d20952010-12-14 09:00:09 +000044#define CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, true, false, "CHECK_FALSE" )
Phil Nashd8026002010-11-09 23:24:00 +000045
Phil Nash3455e552010-11-10 07:42:15 +000046#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 Nashd8026002010-11-09 23:24:00 +000049
Phil Nash3455e552010-11-10 07:42:15 +000050#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 Nash00256682010-12-27 11:09:34 +000053#define SCOPED_INFO( log ) INTERNAL_CATCH_SCOPED_INFO( log )
Phil Nashd8026002010-11-09 23:24:00 +000054
55#define SECTION( name, description ) CATCH_SECTION( name, description )
56
Phil Nash3455e552010-11-10 07:42:15 +000057#define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
Phil Nashd8026002010-11-09 23:24:00 +000058#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 Nash3455e552010-11-10 07:42:15 +000064#define CHECK_NOFAIL( expr ) // !TBD - reports violation, but doesn't fail Test
Phil Nashd8026002010-11-09 23:24:00 +000065
66using Catch::Approx;
67
68#endif // TWOBLUECUBES_CATCH_HPP_INCLUDED