blob: f83d828ba93a18d382831e71643a627841e4b15b [file] [log] [blame]
Phil Nashc4a089c2013-12-03 18:52:41 +00001/*
2 * Created by Phil on 03/12/2013.
3 * Copyright 2013 Two Blue Cubes Ltd. All rights reserved.
4 *
5 * Distributed under the Boost Software License, Version 1.0. (See accompanying
6 * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 */
8#ifndef TWOBLUECUBES_CATCH_SECTION_H_INCLUDED
9#define TWOBLUECUBES_CATCH_SECTION_H_INCLUDED
10
11#include "catch_section_info.h"
12#include "catch_totals.hpp"
13#include "catch_timer.h"
14
15#include <string>
16
17namespace Catch {
18
19 class Section {
20 public:
Phil Nash23181ee2014-07-09 07:39:57 +010021 Section( SectionInfo const& info );
Phil Nashc4a089c2013-12-03 18:52:41 +000022 ~Section();
Phil Nashc4a089c2013-12-03 18:52:41 +000023
24 // This indicates whether the section should be executed or not
Phil Nash23181ee2014-07-09 07:39:57 +010025 operator bool() const;
Phil Nashc4a089c2013-12-03 18:52:41 +000026
27 private:
Phil Nash23181ee2014-07-09 07:39:57 +010028#ifdef CATCH_CPP11_OR_GREATER
29 Section( Section const& ) = delete;
30 Section( Section && ) = delete;
31 Section& operator = ( Section const& ) = delete;
32 Section& operator = ( Section && ) = delete;
33#else
34 Section( Section const& info );
35 Section& operator = ( Section const& );
36#endif
Phil Nashc4a089c2013-12-03 18:52:41 +000037 SectionInfo m_info;
38
39 std::string m_name;
40 Counts m_assertions;
41 bool m_sectionIncluded;
42 Timer m_timer;
43 };
44
45} // end namespace Catch
46
47#ifdef CATCH_CONFIG_VARIADIC_MACROS
48 #define INTERNAL_CATCH_SECTION( ... ) \
Phil Nash23181ee2014-07-09 07:39:57 +010049 if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) )
Phil Nashc4a089c2013-12-03 18:52:41 +000050#else
51 #define INTERNAL_CATCH_SECTION( name, desc ) \
Phil Nash23181ee2014-07-09 07:39:57 +010052 if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, name, desc ) )
Phil Nashc4a089c2013-12-03 18:52:41 +000053#endif
54
55#endif // TWOBLUECUBES_CATCH_SECTION_H_INCLUDED