blob: 440ec253f802a279675e84471dcb5a841d5fba88 [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)
Phil Nashd8026002010-11-09 23:24:00 +000019 Revisit Approx()
Phil Nashd8026002010-11-09 23:24:00 +000020 Tags?
Phil Nashd8026002010-11-09 23:24:00 +000021 Finish macros, listed here, later (just CHECK_NOFAIL now)
22 */
23#ifndef TWOBLUECUBES_CATCH_HPP_INCLUDED
24#define TWOBLUECUBES_CATCH_HPP_INCLUDED
25
Phil Nashaca80a12010-12-31 22:54:35 +000026#include "internal/catch_hub.h"
Phil Nash896a04f2011-01-05 21:16:54 +000027#include "internal/catch_test_registry.hpp"
Phil Nashd8026002010-11-09 23:24:00 +000028#include "internal/catch_capture.hpp"
29#include "internal/catch_section.hpp"
Phil Nash5cad9d52011-01-27 22:29:36 +000030#include "internal/catch_generators.hpp"
Phil Nashd8026002010-11-09 23:24:00 +000031
32//////
33
Phil Nasha2d20952010-12-14 09:00:09 +000034#define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, false, true, "REQUIRE" )
35#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, true, true, "REQUIRE_FALSE" )
Phil Nashd8026002010-11-09 23:24:00 +000036
Phil Nasha2d20952010-12-14 09:00:09 +000037#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 Nashd8026002010-11-09 23:24:00 +000040
Phil Nash3455e552010-11-10 07:42:15 +000041#define CHECK( expr ) INTERNAL_CATCH_TEST( expr, false, false, "CHECK" )
Phil Nasha2d20952010-12-14 09:00:09 +000042#define CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, true, false, "CHECK_FALSE" )
Phil Nashd8026002010-11-09 23:24:00 +000043
Phil Nash3455e552010-11-10 07:42:15 +000044#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 Nashd8026002010-11-09 23:24:00 +000047
Phil Nash3455e552010-11-10 07:42:15 +000048#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 Nash00256682010-12-27 11:09:34 +000051#define SCOPED_INFO( log ) INTERNAL_CATCH_SCOPED_INFO( log )
Phil Nashd8026002010-11-09 23:24:00 +000052
Phil Nash5cad9d52011-01-27 22:29:36 +000053#define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
Phil Nashd8026002010-11-09 23:24:00 +000054
Phil Nash3455e552010-11-10 07:42:15 +000055#define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
Phil Nashd1ee9642011-01-31 20:15:40 +000056#define TEST_CASE_NORETURN( name, description ) INTERNAL_CATCH_TESTCASE_NORETURN( name, description )
Phil Nash2b05dfa2011-01-18 20:09:21 +000057#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "Anonymous test case" )
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
Phil Nash5cad9d52011-01-27 22:29:36 +000060#define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
61
62#define GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
Phil Nashd8026002010-11-09 23:24:00 +000063
64///////////////
65// Still to be implemented
Phil Nash3455e552010-11-10 07:42:15 +000066#define CHECK_NOFAIL( expr ) // !TBD - reports violation, but doesn't fail Test
Phil Nashd8026002010-11-09 23:24:00 +000067
68using Catch::Approx;
69
70#endif // TWOBLUECUBES_CATCH_HPP_INCLUDED