File indexing completed on 2025-01-18 09:54:06
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef CATCH_SECTION_HPP_INCLUDED
0009 #define CATCH_SECTION_HPP_INCLUDED
0010
0011 #include <catch2/internal/catch_compiler_capabilities.hpp>
0012 #include <catch2/internal/catch_config_static_analysis_support.hpp>
0013 #include <catch2/internal/catch_noncopyable.hpp>
0014 #include <catch2/catch_section_info.hpp>
0015 #include <catch2/catch_timer.hpp>
0016 #include <catch2/catch_totals.hpp>
0017 #include <catch2/internal/catch_unique_name.hpp>
0018
0019 namespace Catch {
0020
0021 class Section : Detail::NonCopyable {
0022 public:
0023 Section( SectionInfo&& info );
0024 Section( SourceLineInfo const& _lineInfo,
0025 StringRef _name,
0026 const char* const = nullptr );
0027 ~Section();
0028
0029
0030 explicit operator bool() const;
0031
0032 private:
0033 SectionInfo m_info;
0034
0035 Counts m_assertions;
0036 bool m_sectionIncluded;
0037 Timer m_timer;
0038 };
0039
0040 }
0041
0042 #if !defined(CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT)
0043 # define INTERNAL_CATCH_SECTION( ... ) \
0044 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
0045 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \
0046 if ( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( \
0047 catch_internal_Section ) = \
0048 Catch::Section( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) ) \
0049 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
0050
0051 # define INTERNAL_CATCH_DYNAMIC_SECTION( ... ) \
0052 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
0053 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \
0054 if ( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( \
0055 catch_internal_Section ) = \
0056 Catch::SectionInfo( \
0057 CATCH_INTERNAL_LINEINFO, \
0058 ( Catch::ReusableStringStream() << __VA_ARGS__ ) \
0059 .str() ) ) \
0060 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
0061
0062 #else
0063
0064
0065
0066
0067
0068 namespace Catch {
0069 namespace Detail {
0070
0071
0072 int GetNewSectionHint();
0073 }
0074 }
0075
0076
0077 # define INTERNAL_CATCH_SECTION( ... ) \
0078 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
0079 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \
0080 CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \
0081 if ( [[maybe_unused]] int catchInternalPreviousSectionHint = \
0082 catchInternalSectionHint, \
0083 catchInternalSectionHint = Catch::Detail::GetNewSectionHint(); \
0084 catchInternalPreviousSectionHint == __LINE__ ) \
0085 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
0086
0087 # define INTERNAL_CATCH_DYNAMIC_SECTION( ... ) \
0088 CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
0089 CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \
0090 CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \
0091 if ( [[maybe_unused]] int catchInternalPreviousSectionHint = \
0092 catchInternalSectionHint, \
0093 catchInternalSectionHint = Catch::Detail::GetNewSectionHint(); \
0094 catchInternalPreviousSectionHint == __LINE__ ) \
0095 CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
0096
0097 #endif
0098
0099
0100 #endif