catch_section.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Created by Phil on 03/12/2013.
  3. * Copyright 2013 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. #ifndef TWOBLUECUBES_CATCH_SECTION_H_INCLUDED
  9. #define TWOBLUECUBES_CATCH_SECTION_H_INCLUDED
  10. #include "catch_compiler_capabilities.h"
  11. #include "catch_section_info.h"
  12. #include "catch_totals.h"
  13. #include "catch_timer.h"
  14. #include <string>
  15. namespace Catch {
  16. class Section : NonCopyable {
  17. public:
  18. Section( SectionInfo const& info );
  19. ~Section();
  20. // This indicates whether the section should be executed or not
  21. explicit operator bool() const;
  22. private:
  23. SectionInfo m_info;
  24. std::string m_name;
  25. Counts m_assertions;
  26. bool m_sectionIncluded;
  27. Timer m_timer;
  28. };
  29. } // end namespace Catch
  30. #define INTERNAL_CATCH_SECTION( ... ) \
  31. CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
  32. CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \
  33. if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) ) \
  34. CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
  35. #define INTERNAL_CATCH_DYNAMIC_SECTION( ... ) \
  36. CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
  37. CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \
  38. if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, (Catch::ReusableStringStream() << __VA_ARGS__).str() ) ) \
  39. CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
  40. #endif // TWOBLUECUBES_CATCH_SECTION_H_INCLUDED