2020-08-30 15:43:45 +02:00
|
|
|
|
|
|
|
|
// Copyright Catch2 Authors
|
|
|
|
|
// Distributed under the Boost Software License, Version 1.0.
|
|
|
|
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
|
|
|
|
// https://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
|
|
|
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
2020-08-29 20:48:32 +02:00
|
|
|
#ifndef CATCH_SECTION_HPP_INCLUDED
|
|
|
|
|
#define CATCH_SECTION_HPP_INCLUDED
|
2013-12-03 18:52:41 +00:00
|
|
|
|
2020-03-30 10:34:21 +02:00
|
|
|
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
2020-08-18 11:35:58 +02:00
|
|
|
#include <catch2/internal/catch_noncopyable.hpp>
|
2020-03-30 10:34:21 +02:00
|
|
|
#include <catch2/catch_section_info.hpp>
|
|
|
|
|
#include <catch2/catch_timer.hpp>
|
|
|
|
|
#include <catch2/catch_totals.hpp>
|
2021-02-24 23:13:56 +01:00
|
|
|
#include <catch2/internal/catch_unique_name.hpp>
|
2013-12-03 18:52:41 +00:00
|
|
|
|
|
|
|
|
namespace Catch {
|
|
|
|
|
|
2020-08-18 11:35:58 +02:00
|
|
|
class Section : Detail::NonCopyable {
|
2013-12-03 18:52:41 +00:00
|
|
|
public:
|
2020-07-29 21:29:38 +02:00
|
|
|
Section( SectionInfo&& info );
|
2013-12-03 18:52:41 +00:00
|
|
|
~Section();
|
|
|
|
|
|
|
|
|
|
// This indicates whether the section should be executed or not
|
2017-04-25 18:56:53 +01:00
|
|
|
explicit operator bool() const;
|
2013-12-03 18:52:41 +00:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
SectionInfo m_info;
|
|
|
|
|
|
|
|
|
|
Counts m_assertions;
|
|
|
|
|
bool m_sectionIncluded;
|
|
|
|
|
Timer m_timer;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // end namespace Catch
|
|
|
|
|
|
2018-06-25 19:04:29 +01:00
|
|
|
#define INTERNAL_CATCH_SECTION( ... ) \
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
|
2020-04-25 18:13:17 +02:00
|
|
|
CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \
|
2018-07-01 20:54:07 +02:00
|
|
|
if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) ) \
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
|
2013-12-03 18:52:41 +00:00
|
|
|
|
2018-06-25 19:19:21 +01:00
|
|
|
#define INTERNAL_CATCH_DYNAMIC_SECTION( ... ) \
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
|
2020-04-25 18:13:17 +02:00
|
|
|
CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \
|
2018-07-01 20:54:07 +02:00
|
|
|
if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, (Catch::ReusableStringStream() << __VA_ARGS__).str() ) ) \
|
2019-10-27 21:07:21 +01:00
|
|
|
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
|
2018-06-25 19:19:21 +01:00
|
|
|
|
2020-08-29 20:48:32 +02:00
|
|
|
#endif // CATCH_SECTION_HPP_INCLUDED
|