mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 12:17:11 +01:00 
			
		
		
		
	Split MessageInfo into its own header
This is first step towards splitting apart reporter implementation and `catch_string.hpp`.
This commit is contained in:
		| @@ -84,6 +84,7 @@ set(INTERNAL_HEADERS | |||||||
|     ${SOURCES_DIR}/matchers/catch_matchers_templated.hpp |     ${SOURCES_DIR}/matchers/catch_matchers_templated.hpp | ||||||
|     ${SOURCES_DIR}/matchers/catch_matchers_vector.hpp |     ${SOURCES_DIR}/matchers/catch_matchers_vector.hpp | ||||||
|     ${SOURCES_DIR}/catch_message.hpp |     ${SOURCES_DIR}/catch_message.hpp | ||||||
|  |     ${SOURCES_DIR}/internal/catch_message_info.hpp | ||||||
|     ${SOURCES_DIR}/internal/catch_meta.hpp |     ${SOURCES_DIR}/internal/catch_meta.hpp | ||||||
|     ${SOURCES_DIR}/internal/catch_option.hpp |     ${SOURCES_DIR}/internal/catch_option.hpp | ||||||
|     ${SOURCES_DIR}/internal/catch_output_redirect.hpp |     ${SOURCES_DIR}/internal/catch_output_redirect.hpp | ||||||
| @@ -151,6 +152,7 @@ set(IMPL_SOURCES | |||||||
|     ${SOURCES_DIR}/matchers/catch_matchers_string.cpp |     ${SOURCES_DIR}/matchers/catch_matchers_string.cpp | ||||||
|     ${SOURCES_DIR}/matchers/catch_matchers_templated.cpp |     ${SOURCES_DIR}/matchers/catch_matchers_templated.cpp | ||||||
|     ${SOURCES_DIR}/catch_message.cpp |     ${SOURCES_DIR}/catch_message.cpp | ||||||
|  |     ${SOURCES_DIR}/internal/catch_message_info.cpp | ||||||
|     ${SOURCES_DIR}/internal/catch_output_redirect.cpp |     ${SOURCES_DIR}/internal/catch_output_redirect.cpp | ||||||
|     ${SOURCES_DIR}/catch_registry_hub.cpp |     ${SOURCES_DIR}/catch_registry_hub.cpp | ||||||
|     ${SOURCES_DIR}/internal/catch_combined_tu.cpp |     ${SOURCES_DIR}/internal/catch_combined_tu.cpp | ||||||
|   | |||||||
| @@ -56,6 +56,7 @@ | |||||||
| #include <catch2/internal/catch_fatal_condition_handler.hpp> | #include <catch2/internal/catch_fatal_condition_handler.hpp> | ||||||
| #include <catch2/internal/catch_leak_detector.hpp> | #include <catch2/internal/catch_leak_detector.hpp> | ||||||
| #include <catch2/internal/catch_list.hpp> | #include <catch2/internal/catch_list.hpp> | ||||||
|  | #include <catch2/internal/catch_message_info.hpp> | ||||||
| #include <catch2/internal/catch_meta.hpp> | #include <catch2/internal/catch_meta.hpp> | ||||||
| #include <catch2/internal/catch_option.hpp> | #include <catch2/internal/catch_option.hpp> | ||||||
| #include <catch2/internal/catch_output_redirect.hpp> | #include <catch2/internal/catch_output_redirect.hpp> | ||||||
|   | |||||||
| @@ -16,27 +16,6 @@ | |||||||
|  |  | ||||||
| namespace Catch { | namespace Catch { | ||||||
|  |  | ||||||
|     MessageInfo::MessageInfo(   StringRef const& _macroName, |  | ||||||
|                                 SourceLineInfo const& _lineInfo, |  | ||||||
|                                 ResultWas::OfType _type ) |  | ||||||
|     :   macroName( _macroName ), |  | ||||||
|         lineInfo( _lineInfo ), |  | ||||||
|         type( _type ), |  | ||||||
|         sequence( ++globalCount ) |  | ||||||
|     {} |  | ||||||
|  |  | ||||||
|     bool MessageInfo::operator==( MessageInfo const& other ) const { |  | ||||||
|         return sequence == other.sequence; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     bool MessageInfo::operator<( MessageInfo const& other ) const { |  | ||||||
|         return sequence < other.sequence; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     // This may need protecting if threading support is added |  | ||||||
|     unsigned int MessageInfo::globalCount = 0; |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     //////////////////////////////////////////////////////////////////////////// |     //////////////////////////////////////////////////////////////////////////// | ||||||
|  |  | ||||||
|     Catch::MessageBuilder::MessageBuilder( StringRef const& macroName, |     Catch::MessageBuilder::MessageBuilder( StringRef const& macroName, | ||||||
|   | |||||||
| @@ -11,6 +11,7 @@ | |||||||
| #include <catch2/internal/catch_result_type.hpp> | #include <catch2/internal/catch_result_type.hpp> | ||||||
| #include <catch2/internal/catch_common.hpp> | #include <catch2/internal/catch_common.hpp> | ||||||
| #include <catch2/internal/catch_stream.hpp> | #include <catch2/internal/catch_stream.hpp> | ||||||
|  | #include <catch2/internal/catch_message_info.hpp> | ||||||
| #include <catch2/interfaces/catch_interfaces_capture.hpp> | #include <catch2/interfaces/catch_interfaces_capture.hpp> | ||||||
| #include <catch2/catch_tostring.hpp> | #include <catch2/catch_tostring.hpp> | ||||||
|  |  | ||||||
| @@ -19,23 +20,6 @@ | |||||||
|  |  | ||||||
| namespace Catch { | namespace Catch { | ||||||
|  |  | ||||||
|     struct MessageInfo { |  | ||||||
|         MessageInfo(    StringRef const& _macroName, |  | ||||||
|                         SourceLineInfo const& _lineInfo, |  | ||||||
|                         ResultWas::OfType _type ); |  | ||||||
|  |  | ||||||
|         StringRef macroName; |  | ||||||
|         std::string message; |  | ||||||
|         SourceLineInfo lineInfo; |  | ||||||
|         ResultWas::OfType type; |  | ||||||
|         unsigned int sequence; |  | ||||||
|  |  | ||||||
|         bool operator == ( MessageInfo const& other ) const; |  | ||||||
|         bool operator < ( MessageInfo const& other ) const; |  | ||||||
|     private: |  | ||||||
|         static unsigned int globalCount; |  | ||||||
|     }; |  | ||||||
|  |  | ||||||
|     struct MessageStream { |     struct MessageStream { | ||||||
|  |  | ||||||
|         template<typename T> |         template<typename T> | ||||||
|   | |||||||
| @@ -7,6 +7,7 @@ | |||||||
|  |  | ||||||
| #include <catch2/interfaces/catch_interfaces_reporter.hpp> | #include <catch2/interfaces/catch_interfaces_reporter.hpp> | ||||||
| #include <catch2/internal/catch_console_colour.hpp> | #include <catch2/internal/catch_console_colour.hpp> | ||||||
|  | #include <catch2/catch_message.hpp> | ||||||
| #include <catch2/internal/catch_list.hpp> | #include <catch2/internal/catch_list.hpp> | ||||||
| #include <catch2/internal/catch_text.hpp> | #include <catch2/internal/catch_text.hpp> | ||||||
| #include <catch2/internal/catch_string_manip.hpp> | #include <catch2/internal/catch_string_manip.hpp> | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ | |||||||
| #include <catch2/catch_totals.hpp> | #include <catch2/catch_totals.hpp> | ||||||
| #include <catch2/catch_test_case_info.hpp> | #include <catch2/catch_test_case_info.hpp> | ||||||
| #include <catch2/catch_assertion_result.hpp> | #include <catch2/catch_assertion_result.hpp> | ||||||
| #include <catch2/catch_message.hpp> | #include <catch2/internal/catch_message_info.hpp> | ||||||
| #include <catch2/internal/catch_option.hpp> | #include <catch2/internal/catch_option.hpp> | ||||||
| #include <catch2/internal/catch_stringref.hpp> | #include <catch2/internal/catch_stringref.hpp> | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										26
									
								
								src/catch2/internal/catch_message_info.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src/catch2/internal/catch_message_info.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,26 @@ | |||||||
|  |  | ||||||
|  | #include <catch2/internal/catch_message_info.hpp> | ||||||
|  |  | ||||||
|  | namespace Catch { | ||||||
|  |  | ||||||
|  |     MessageInfo::MessageInfo(   StringRef const& _macroName, | ||||||
|  |                                 SourceLineInfo const& _lineInfo, | ||||||
|  |                                 ResultWas::OfType _type ) | ||||||
|  |     :   macroName( _macroName ), | ||||||
|  |         lineInfo( _lineInfo ), | ||||||
|  |         type( _type ), | ||||||
|  |         sequence( ++globalCount ) | ||||||
|  |     {} | ||||||
|  |  | ||||||
|  |     bool MessageInfo::operator==( MessageInfo const& other ) const { | ||||||
|  |         return sequence == other.sequence; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     bool MessageInfo::operator<( MessageInfo const& other ) const { | ||||||
|  |         return sequence < other.sequence; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     // This may need protecting if threading support is added | ||||||
|  |     unsigned int MessageInfo::globalCount = 0; | ||||||
|  |  | ||||||
|  | } // end namespace Catch | ||||||
							
								
								
									
										31
									
								
								src/catch2/internal/catch_message_info.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/catch2/internal/catch_message_info.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,31 @@ | |||||||
|  | #ifndef CATCH_MESSAGE_INFO_HPP_INCLUDED | ||||||
|  | #define CATCH_MESSAGE_INFO_HPP_INCLUDED | ||||||
|  |  | ||||||
|  | #include <catch2/internal/catch_result_type.hpp> | ||||||
|  | #include <catch2/internal/catch_common.hpp> | ||||||
|  | #include <catch2/interfaces/catch_interfaces_capture.hpp> | ||||||
|  |  | ||||||
|  | #include <string> | ||||||
|  |  | ||||||
|  | namespace Catch { | ||||||
|  |  | ||||||
|  |     struct MessageInfo { | ||||||
|  |         MessageInfo(    StringRef const& _macroName, | ||||||
|  |                         SourceLineInfo const& _lineInfo, | ||||||
|  |                         ResultWas::OfType _type ); | ||||||
|  |  | ||||||
|  |         StringRef macroName; | ||||||
|  |         std::string message; | ||||||
|  |         SourceLineInfo lineInfo; | ||||||
|  |         ResultWas::OfType type; | ||||||
|  |         unsigned int sequence; | ||||||
|  |  | ||||||
|  |         bool operator == ( MessageInfo const& other ) const; | ||||||
|  |         bool operator < ( MessageInfo const& other ) const; | ||||||
|  |     private: | ||||||
|  |         static unsigned int globalCount; | ||||||
|  |     }; | ||||||
|  |  | ||||||
|  | } // end namespace Catch | ||||||
|  |  | ||||||
|  | #endif // CATCH_MESSAGE_INFO_HPP_INCLUDED | ||||||
| @@ -16,6 +16,7 @@ | |||||||
| #include <catch2/internal/catch_test_registry.hpp> | #include <catch2/internal/catch_test_registry.hpp> | ||||||
| #include <catch2/catch_test_case_info.hpp> | #include <catch2/catch_test_case_info.hpp> | ||||||
| #include <catch2/internal/catch_test_macro_impl.hpp> | #include <catch2/internal/catch_test_macro_impl.hpp> | ||||||
|  | #include <catch2/catch_message.hpp> | ||||||
| #include <catch2/catch_totals.hpp> | #include <catch2/catch_totals.hpp> | ||||||
| #include <catch2/catch_test_spec.hpp> | #include <catch2/catch_test_spec.hpp> | ||||||
| #include <catch2/internal/catch_test_case_tracker.hpp> | #include <catch2/internal/catch_test_case_tracker.hpp> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Martin Hořeňovský
					Martin Hořeňovský