1 /* 2 * Created by Phil on 03/11/2010. 3 * Copyright 2010 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 9 #include "catch_section.h" 10 #include "catch_capture.hpp" 11 #include "catch_uncaught_exceptions.h" 12 13 namespace Catch { 14 Section(SectionInfo const & info)15 Section::Section( SectionInfo const& info ) 16 : m_info( info ), 17 m_sectionIncluded( getResultCapture().sectionStarted( m_info, m_assertions ) ) 18 { 19 m_timer.start(); 20 } 21 ~Section()22 Section::~Section() { 23 if( m_sectionIncluded ) { 24 SectionEndInfo endInfo{ m_info, m_assertions, m_timer.getElapsedSeconds() }; 25 if( uncaught_exceptions() ) 26 getResultCapture().sectionEndedEarly( endInfo ); 27 else 28 getResultCapture().sectionEnded( endInfo ); 29 } 30 } 31 32 // This indicates whether the section should be executed or not operator bool() const33 Section::operator bool() const { 34 return m_sectionIncluded; 35 } 36 37 38 } // end namespace Catch 39