blob: 488dde45c235bb0a8f89892b4087d2f1910324e0 [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 Nash9430a2c2011-04-20 15:40:40 +010031#include "internal/catch_interfaces_exception.h"
Phil Nashd8026002010-11-09 23:24:00 +000032
33//////
34
Phil Nasha2d20952010-12-14 09:00:09 +000035#define REQUIRE( expr ) INTERNAL_CATCH_TEST( expr, false, true, "REQUIRE" )
36#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( expr, true, true, "REQUIRE_FALSE" )
Phil Nashd8026002010-11-09 23:24:00 +000037
Phil Nashc27e6dc2011-03-14 08:49:42 +000038#define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., true, "REQUIRE_THROWS" )
39#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, true, "REQUIRE_THROWS_AS" )
Phil Nash0dc45082011-03-14 08:45:55 +000040#define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, true, "REQUIRE_NOTHROW" )
Phil Nashd8026002010-11-09 23:24:00 +000041
Phil Nash3455e552010-11-10 07:42:15 +000042#define CHECK( expr ) INTERNAL_CATCH_TEST( expr, false, false, "CHECK" )
Phil Nasha2d20952010-12-14 09:00:09 +000043#define CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( expr, true, false, "CHECK_FALSE" )
Phil Nashd8026002010-11-09 23:24:00 +000044
Phil Nashc27e6dc2011-03-14 08:49:42 +000045#define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., false, "CHECK_THROWS" )
46#define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, false, "CHECK_THROWS_AS" )
Phil Nash0dc45082011-03-14 08:45:55 +000047#define CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, false, "CHECK_NOTHROW" )
Phil Nashd8026002010-11-09 23:24:00 +000048
Phil Nashe4016012011-02-28 19:01:04 +000049#define INFO( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Info, false, "INFO" )
50#define WARN( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Warning, false, "WARN" )
51#define FAIL( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::ExplicitFailure, true, "FAIL" )
52#define SCOPED_INFO( msg ) INTERNAL_CATCH_SCOPED_INFO( msg )
53#define CAPTURE( msg ) INTERNAL_CATCH_MSG( #msg " := " << msg, Catch::ResultWas::Info, false, "CAPTURE" )
Phil Nashd8026002010-11-09 23:24:00 +000054
Phil Nash5cad9d52011-01-27 22:29:36 +000055#define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
Phil Nashd8026002010-11-09 23:24:00 +000056
Phil Nash3455e552010-11-10 07:42:15 +000057#define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
Phil Nashd1ee9642011-01-31 20:15:40 +000058#define TEST_CASE_NORETURN( name, description ) INTERNAL_CATCH_TESTCASE_NORETURN( name, description )
Phil Nash2b05dfa2011-01-18 20:09:21 +000059#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "Anonymous test case" )
Phil Nashd8026002010-11-09 23:24:00 +000060#define METHOD_AS_TEST_CASE( method, name, description ) CATCH_METHOD_AS_TEST_CASE( method, name, description )
61
Phil Nash5cad9d52011-01-27 22:29:36 +000062#define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
63
64#define GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
Phil Nashd8026002010-11-09 23:24:00 +000065
66///////////////
67// Still to be implemented
Phil Nash3455e552010-11-10 07:42:15 +000068#define CHECK_NOFAIL( expr ) // !TBD - reports violation, but doesn't fail Test
Phil Nashd8026002010-11-09 23:24:00 +000069
Phil Nash01db6c42011-04-04 07:56:44 +010070using Catch::Detail::Approx;
Phil Nashd8026002010-11-09 23:24:00 +000071
Phil Nash73acd942011-02-16 19:02:09 +000072#endif // TWOBLUECUBES_CATCH_HPP_INCLUDED