Phil Nash | c4a089c | 2013-12-03 18:52:41 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | namespace Catch { |
| 18 | |
| 19 | class Section { |
| 20 | public: |
Phil Nash | 23181ee | 2014-07-09 07:39:57 +0100 | [diff] [blame^] | 21 | Section( SectionInfo const& info ); |
Phil Nash | c4a089c | 2013-12-03 18:52:41 +0000 | [diff] [blame] | 22 | ~Section(); |
Phil Nash | c4a089c | 2013-12-03 18:52:41 +0000 | [diff] [blame] | 23 | |
| 24 | // This indicates whether the section should be executed or not |
Phil Nash | 23181ee | 2014-07-09 07:39:57 +0100 | [diff] [blame^] | 25 | operator bool() const; |
Phil Nash | c4a089c | 2013-12-03 18:52:41 +0000 | [diff] [blame] | 26 | |
| 27 | private: |
Phil Nash | 23181ee | 2014-07-09 07:39:57 +0100 | [diff] [blame^] | 28 | #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 Nash | c4a089c | 2013-12-03 18:52:41 +0000 | [diff] [blame] | 37 | 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 Nash | 23181ee | 2014-07-09 07:39:57 +0100 | [diff] [blame^] | 49 | if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) ) |
Phil Nash | c4a089c | 2013-12-03 18:52:41 +0000 | [diff] [blame] | 50 | #else |
| 51 | #define INTERNAL_CATCH_SECTION( name, desc ) \ |
Phil Nash | 23181ee | 2014-07-09 07:39:57 +0100 | [diff] [blame^] | 52 | if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, name, desc ) ) |
Phil Nash | c4a089c | 2013-12-03 18:52:41 +0000 | [diff] [blame] | 53 | #endif |
| 54 | |
| 55 | #endif // TWOBLUECUBES_CATCH_SECTION_H_INCLUDED |