blob: 0a241b092ec2b3c90296a1d5383d1fb0b26b8725 [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 Nashc27e6dc2011-03-14 08:49:42 +000037#define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., true, "REQUIRE_THROWS" )
38#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, true, "REQUIRE_THROWS_AS" )
Phil Nash0dc45082011-03-14 08:45:55 +000039#define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, 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 Nashc27e6dc2011-03-14 08:49:42 +000044#define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( expr, ..., false, "CHECK_THROWS" )
45#define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( expr, exceptionType, false, "CHECK_THROWS_AS" )
Phil Nash0dc45082011-03-14 08:45:55 +000046#define CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( expr, false, "CHECK_NOTHROW" )
Phil Nashd8026002010-11-09 23:24:00 +000047
Phil Nashe4016012011-02-28 19:01:04 +000048#define INFO( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Info, false, "INFO" )
49#define WARN( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::Warning, false, "WARN" )
50#define FAIL( msg ) INTERNAL_CATCH_MSG( msg, Catch::ResultWas::ExplicitFailure, true, "FAIL" )
51#define SCOPED_INFO( msg ) INTERNAL_CATCH_SCOPED_INFO( msg )
52#define CAPTURE( msg ) INTERNAL_CATCH_MSG( #msg " := " << msg, Catch::ResultWas::Info, false, "CAPTURE" )
Phil Nashd8026002010-11-09 23:24:00 +000053
Phil Nash5cad9d52011-01-27 22:29:36 +000054#define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
Phil Nashd8026002010-11-09 23:24:00 +000055
Phil Nash3455e552010-11-10 07:42:15 +000056#define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
Phil Nashd1ee9642011-01-31 20:15:40 +000057#define TEST_CASE_NORETURN( name, description ) INTERNAL_CATCH_TESTCASE_NORETURN( name, description )
Phil Nash2b05dfa2011-01-18 20:09:21 +000058#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "Anonymous test case" )
Phil Nashd8026002010-11-09 23:24:00 +000059#define METHOD_AS_TEST_CASE( method, name, description ) CATCH_METHOD_AS_TEST_CASE( method, name, description )
60
Phil Nash5cad9d52011-01-27 22:29:36 +000061#define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
62
63#define GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
Phil Nashd8026002010-11-09 23:24:00 +000064
65///////////////
66// Still to be implemented
Phil Nash3455e552010-11-10 07:42:15 +000067#define CHECK_NOFAIL( expr ) // !TBD - reports violation, but doesn't fail Test
Phil Nashd8026002010-11-09 23:24:00 +000068
Phil Nash01db6c42011-04-04 07:56:44 +010069using Catch::Detail::Approx;
Phil Nashd8026002010-11-09 23:24:00 +000070
Phil Nash73acd942011-02-16 19:02:09 +000071#endif // TWOBLUECUBES_CATCH_HPP_INCLUDED