2010-11-10 00:24:00 +01:00
|
|
|
/*
|
|
|
|
* Created by Phil on 03/11/2010.
|
|
|
|
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
|
|
|
|
*
|
|
|
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
*/
|
|
|
|
|
2013-12-03 19:52:41 +01:00
|
|
|
#include "catch_section.h"
|
2010-11-29 20:40:44 +01:00
|
|
|
#include "catch_capture.hpp"
|
2018-01-26 16:59:47 +01:00
|
|
|
#include "catch_uncaught_exceptions.h"
|
2010-11-29 20:40:44 +01:00
|
|
|
|
2012-05-16 09:02:20 +02:00
|
|
|
namespace Catch {
|
2012-05-15 08:42:26 +02:00
|
|
|
|
2014-07-09 08:39:57 +02:00
|
|
|
Section::Section( SectionInfo const& info )
|
|
|
|
: m_info( info ),
|
2014-05-20 19:49:28 +02:00
|
|
|
m_sectionIncluded( getResultCapture().sectionStarted( m_info, m_assertions ) )
|
2013-12-03 19:52:41 +01:00
|
|
|
{
|
|
|
|
m_timer.start();
|
|
|
|
}
|
2013-07-03 20:14:59 +02:00
|
|
|
|
2013-12-03 19:52:41 +01:00
|
|
|
Section::~Section() {
|
2015-09-27 03:12:21 +02:00
|
|
|
if( m_sectionIncluded ) {
|
2018-06-25 20:04:29 +02:00
|
|
|
SectionEndInfo endInfo{ m_info, m_assertions, m_timer.getElapsedSeconds() };
|
2018-01-26 16:59:47 +01:00
|
|
|
if( uncaught_exceptions() )
|
2015-09-27 03:12:21 +02:00
|
|
|
getResultCapture().sectionEndedEarly( endInfo );
|
|
|
|
else
|
|
|
|
getResultCapture().sectionEnded( endInfo );
|
|
|
|
}
|
2013-12-03 19:52:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// This indicates whether the section should be executed or not
|
2014-07-09 08:39:57 +02:00
|
|
|
Section::operator bool() const {
|
2013-12-03 19:52:41 +01:00
|
|
|
return m_sectionIncluded;
|
|
|
|
}
|
2010-11-10 00:24:00 +01:00
|
|
|
|
2013-12-03 19:52:41 +01:00
|
|
|
|
|
|
|
} // end namespace Catch
|