Files
Catch2/src/catch2/internal/catch_section.cpp
T

44 lines
1.3 KiB
C++
Raw Normal View History

// 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-03-30 10:34:21 +02:00
#include <catch2/internal/catch_section.hpp>
#include <catch2/internal/catch_test_macro_impl.hpp>
2020-03-30 10:34:21 +02:00
#include <catch2/internal/catch_uncaught_exceptions.hpp>
#include <utility>
2012-05-16 08:02:20 +01:00
namespace Catch {
2012-05-15 07:42:26 +01:00
Section::Section( SectionInfo&& info ):
m_info( std::move( info ) ),
m_sectionIncluded(
getResultCapture().sectionStarted( m_info, m_assertions ) ) {
// Non-"included" sections will not use the timing information
// anyway, so don't bother with the potential syscall.
if (m_sectionIncluded) {
m_timer.start();
}
}
2011-01-26 23:23:33 +00:00
Section::~Section() {
if( m_sectionIncluded ) {
SectionEndInfo endInfo{ m_info, m_assertions, m_timer.getElapsedSeconds() };
if( uncaught_exceptions() )
getResultCapture().sectionEndedEarly( endInfo );
else
getResultCapture().sectionEnded( endInfo );
}
}
2013-07-03 19:14:59 +01:00
// This indicates whether the section should be executed or not
Section::operator bool() const {
return m_sectionIncluded;
}
2010-11-29 22:33:48 +00:00
2013-07-03 19:14:59 +01:00
2010-11-09 23:24:00 +00:00
} // end namespace Catch