diff options
| author | Chris Thrasher | 2025-09-21 18:05:21 -0600 |
|---|---|---|
| committer | Chris Thrasher | 2025-09-22 11:50:44 -0600 |
| commit | 8efee9b7632e6dd014b5b041ee326eef7d0b09e6 (patch) | |
| tree | fbc1657a5d7d414fbe93a412990bcf5cfb2df438 /src | |
| parent | a5735af2f7d956600250541d289c552ace7e87ae (diff) | |
| download | catch3-devel-c++17.tar.gz | |
Use std::string_viewdevel-c++17
Diffstat (limited to 'src')
89 files changed, 595 insertions, 810 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1b5a7a8b..7c29add5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -124,7 +124,6 @@ set(IMPL_HEADERS ${SOURCES_DIR}/internal/catch_stdstreams.hpp ${SOURCES_DIR}/internal/catch_stream_end_stop.hpp ${SOURCES_DIR}/internal/catch_string_manip.hpp - ${SOURCES_DIR}/internal/catch_stringref.hpp ${SOURCES_DIR}/internal/catch_tag_alias_registry.hpp ${SOURCES_DIR}/internal/catch_template_test_registry.hpp ${SOURCES_DIR}/internal/catch_test_case_info_hasher.hpp @@ -201,7 +200,6 @@ set(IMPL_SOURCES ${SOURCES_DIR}/internal/catch_startup_exception_registry.cpp ${SOURCES_DIR}/internal/catch_stdstreams.cpp ${SOURCES_DIR}/internal/catch_string_manip.cpp - ${SOURCES_DIR}/internal/catch_stringref.cpp ${SOURCES_DIR}/internal/catch_tag_alias_registry.cpp ${SOURCES_DIR}/internal/catch_test_case_info_hasher.cpp ${SOURCES_DIR}/internal/catch_test_case_registry_impl.cpp diff --git a/src/catch2/catch_all.hpp b/src/catch2/catch_all.hpp index 4c9ea994..d948e126 100644 --- a/src/catch2/catch_all.hpp +++ b/src/catch2/catch_all.hpp @@ -106,7 +106,6 @@ #include <catch2/internal/catch_stdstreams.hpp> #include <catch2/internal/catch_stream_end_stop.hpp> #include <catch2/internal/catch_string_manip.hpp> -#include <catch2/internal/catch_stringref.hpp> #include <catch2/internal/catch_tag_alias_registry.hpp> #include <catch2/internal/catch_template_test_registry.hpp> #include <catch2/internal/catch_test_case_info_hasher.hpp> diff --git a/src/catch2/catch_assertion_info.hpp b/src/catch2/catch_assertion_info.hpp index 9d2f91fa..b64ad74b 100644 --- a/src/catch2/catch_assertion_info.hpp +++ b/src/catch2/catch_assertion_info.hpp @@ -10,16 +10,17 @@ #include <catch2/internal/catch_result_type.hpp> #include <catch2/internal/catch_source_line_info.hpp> -#include <catch2/internal/catch_stringref.hpp> + +#include <string_view> namespace Catch { struct AssertionInfo { // AssertionInfo() = delete; - StringRef macroName; + std::string_view macroName; SourceLineInfo lineInfo; - StringRef capturedExpression; + std::string_view capturedExpression; ResultDisposition::Flags resultDisposition; }; diff --git a/src/catch2/catch_assertion_result.cpp b/src/catch2/catch_assertion_result.cpp index dba86229..6fa33bf5 100644 --- a/src/catch2/catch_assertion_result.cpp +++ b/src/catch2/catch_assertion_result.cpp @@ -91,14 +91,14 @@ namespace Catch { : expr; } - StringRef AssertionResult::getMessage() const { + std::string_view AssertionResult::getMessage() const { return m_resultData.message; } SourceLineInfo AssertionResult::getSourceInfo() const { return m_info.lineInfo; } - StringRef AssertionResult::getTestMacroName() const { + std::string_view AssertionResult::getTestMacroName() const { return m_info.macroName; } diff --git a/src/catch2/catch_assertion_result.hpp b/src/catch2/catch_assertion_result.hpp index 48882876..d3f986e6 100644 --- a/src/catch2/catch_assertion_result.hpp +++ b/src/catch2/catch_assertion_result.hpp @@ -11,7 +11,6 @@ #include <catch2/catch_assertion_info.hpp> #include <catch2/internal/catch_result_type.hpp> #include <catch2/internal/catch_source_line_info.hpp> -#include <catch2/internal/catch_stringref.hpp> #include <catch2/internal/catch_lazy_expr.hpp> #include <string> @@ -46,9 +45,9 @@ namespace Catch { std::string getExpressionInMacro() const; bool hasExpandedExpression() const; std::string getExpandedExpression() const; - StringRef getMessage() const; + std::string_view getMessage() const; SourceLineInfo getSourceInfo() const; - StringRef getTestMacroName() const; + std::string_view getTestMacroName() const; //protected: AssertionInfo m_info; diff --git a/src/catch2/catch_config.cpp b/src/catch2/catch_config.cpp index 4e5c9e2c..3cb7c474 100644 --- a/src/catch2/catch_config.cpp +++ b/src/catch2/catch_config.cpp @@ -10,7 +10,6 @@ #include <catch2/internal/catch_enforce.hpp> #include <catch2/internal/catch_parse_numbers.hpp> #include <catch2/internal/catch_stdstreams.hpp> -#include <catch2/internal/catch_stringref.hpp> #include <catch2/internal/catch_string_manip.hpp> #include <catch2/internal/catch_test_spec_parser.hpp> #include <catch2/interfaces/catch_interfaces_tag_alias_registry.hpp> @@ -186,7 +185,7 @@ namespace Catch { // IConfig interface bool Config::allowThrows() const { return !m_data.noThrow; } - StringRef Config::name() const { return m_data.name.empty() ? m_data.processName : m_data.name; } + std::string_view Config::name() const { return m_data.name.empty() ? m_data.processName : m_data.name; } bool Config::includeSuccessfulResults() const { return m_data.showSuccessfulTests; } bool Config::warnAboutMissingAssertions() const { return !!( m_data.warnings & WarnAbout::NoAssertions ); diff --git a/src/catch2/catch_config.hpp b/src/catch2/catch_config.hpp index e22f2d3e..b97ff8a3 100644 --- a/src/catch2/catch_config.hpp +++ b/src/catch2/catch_config.hpp @@ -11,7 +11,6 @@ #include <catch2/catch_test_spec.hpp> #include <catch2/interfaces/catch_interfaces_config.hpp> #include <catch2/internal/catch_unique_ptr.hpp> -#include <catch2/internal/catch_stringref.hpp> #include <catch2/internal/catch_random_seed_generation.hpp> #include <catch2/internal/catch_reporter_spec_parser.hpp> @@ -115,7 +114,7 @@ namespace Catch { // IConfig interface bool allowThrows() const override; - StringRef name() const override; + std::string_view name() const override; bool includeSuccessfulResults() const override; bool warnAboutMissingAssertions() const override; bool warnAboutUnmatchedTestSpecs() const override; diff --git a/src/catch2/catch_message.cpp b/src/catch2/catch_message.cpp index 1ea8c299..074eb930 100644 --- a/src/catch2/catch_message.cpp +++ b/src/catch2/catch_message.cpp @@ -35,10 +35,10 @@ namespace Catch { } - Capturer::Capturer( StringRef macroName, + Capturer::Capturer( std::string_view macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, - StringRef names ): + std::string_view names ): m_resultCapture( getResultCapture() ) { auto trimmed = [&] (size_t start, size_t end) { while (names[start] == ',' || isspace(static_cast<unsigned char>(names[start]))) { @@ -86,7 +86,7 @@ namespace Catch { if (start != pos && openings.empty()) { m_messages.emplace_back(macroName, lineInfo, resultType); m_messages.back().message += trimmed(start, pos); - m_messages.back().message += " := "_sr; + m_messages.back().message += " := "; start = pos; } break; @@ -96,7 +96,7 @@ namespace Catch { assert(openings.empty() && "Mismatched openings"); m_messages.emplace_back(macroName, lineInfo, resultType); m_messages.back().message += trimmed(start, names.size() - 1); - m_messages.back().message += " := "_sr; + m_messages.back().message += " := "; } Capturer::~Capturer() { assert( m_captured == m_messages.size() ); diff --git a/src/catch2/catch_message.hpp b/src/catch2/catch_message.hpp index db3d682a..9ed66c3e 100644 --- a/src/catch2/catch_message.hpp +++ b/src/catch2/catch_message.hpp @@ -36,7 +36,7 @@ namespace Catch { }; struct MessageBuilder : MessageStream { - MessageBuilder( StringRef macroName, + MessageBuilder( std::string_view macroName, SourceLineInfo const& lineInfo, ResultWas::OfType type ): m_info(macroName, lineInfo, type) {} @@ -66,7 +66,7 @@ namespace Catch { IResultCapture& m_resultCapture; size_t m_captured = 0; public: - Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names ); + Capturer( std::string_view macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, std::string_view names ); Capturer(Capturer const&) = delete; Capturer& operator=(Capturer const&) = delete; @@ -92,26 +92,26 @@ namespace Catch { /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_MSG( macroName, messageType, resultDisposition, ... ) \ do { \ - Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::StringRef(), resultDisposition ); \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, std::string_view(), resultDisposition ); \ catchAssertionHandler.handleMessage( messageType, ( Catch::MessageStream() << __VA_ARGS__ + ::Catch::StreamEndStop() ).m_stream.str() ); \ catchAssertionHandler.complete(); \ } while( false ) /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_CAPTURE( varName, macroName, ... ) \ - Catch::Capturer varName( macroName##_catch_sr, \ + Catch::Capturer varName( macroName, \ CATCH_INTERNAL_LINEINFO, \ Catch::ResultWas::Info, \ - #__VA_ARGS__##_catch_sr ); \ + #__VA_ARGS__ ); \ varName.captureValues( 0, __VA_ARGS__ ) /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_INFO( macroName, log ) \ - const Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage )( Catch::MessageBuilder( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log ) + const Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage )( Catch::MessageBuilder( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log ) /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_UNSCOPED_INFO( macroName, log ) \ - Catch::getResultCapture().emplaceUnscopedMessage( Catch::MessageBuilder( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log ) + Catch::getResultCapture().emplaceUnscopedMessage( Catch::MessageBuilder( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log ) #if defined(CATCH_CONFIG_PREFIX_MESSAGES) && !defined(CATCH_CONFIG_DISABLE) diff --git a/src/catch2/catch_section_info.hpp b/src/catch2/catch_section_info.hpp index 7de8441c..d8cf9341 100644 --- a/src/catch2/catch_section_info.hpp +++ b/src/catch2/catch_section_info.hpp @@ -10,7 +10,6 @@ #include <catch2/internal/catch_move_and_forward.hpp> #include <catch2/internal/catch_source_line_info.hpp> -#include <catch2/internal/catch_stringref.hpp> #include <catch2/catch_totals.hpp> #include <string> |