catch_section.cpp 1.1 KB

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