From 8efee9b7632e6dd014b5b041ee326eef7d0b09e6 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Sun, 21 Sep 2025 18:05:21 -0600 Subject: [PATCH] Use std::string_view --- docs/reporter-events.md | 10 +- examples/210-Evt-EventListeners.cpp | 6 +- src/CMakeLists.txt | 2 - src/catch2/catch_all.hpp | 1 - src/catch2/catch_assertion_info.hpp | 7 +- src/catch2/catch_assertion_result.cpp | 4 +- src/catch2/catch_assertion_result.hpp | 5 +- src/catch2/catch_config.cpp | 3 +- src/catch2/catch_config.hpp | 3 +- src/catch2/catch_message.cpp | 8 +- src/catch2/catch_message.hpp | 14 +- src/catch2/catch_section_info.hpp | 1 - src/catch2/catch_test_case_info.cpp | 37 +- src/catch2/catch_test_case_info.hpp | 14 +- src/catch2/catch_test_run_info.hpp | 6 +- src/catch2/catch_tostring.cpp | 6 +- src/catch2/catch_tostring.hpp | 12 +- src/catch2/generators/catch_generators.cpp | 4 +- src/catch2/generators/catch_generators.hpp | 9 +- .../interfaces/catch_interfaces_capture.hpp | 13 +- .../interfaces/catch_interfaces_config.hpp | 3 +- .../catch_interfaces_enum_values_registry.hpp | 13 +- .../catch_interfaces_generatortracker.cpp | 2 +- .../catch_interfaces_generatortracker.hpp | 3 +- .../interfaces/catch_interfaces_reporter.hpp | 11 +- .../catch_interfaces_reporter_factory.hpp | 3 +- .../internal/catch_assertion_handler.cpp | 4 +- .../internal/catch_assertion_handler.hpp | 4 +- .../catch_case_insensitive_comparisons.cpp | 8 +- .../catch_case_insensitive_comparisons.hpp | 10 +- src/catch2/internal/catch_clara.cpp | 20 +- src/catch2/internal/catch_clara.hpp | 45 +- src/catch2/internal/catch_decomposer.cpp | 2 +- src/catch2/internal/catch_decomposer.hpp | 27 +- .../internal/catch_enum_values_registry.cpp | 15 +- .../internal/catch_enum_values_registry.hpp | 7 +- src/catch2/internal/catch_jsonwriter.cpp | 24 +- src/catch2/internal/catch_jsonwriter.hpp | 9 +- src/catch2/internal/catch_list.cpp | 4 +- src/catch2/internal/catch_list.hpp | 9 +- src/catch2/internal/catch_message_info.cpp | 2 +- src/catch2/internal/catch_message_info.hpp | 5 +- src/catch2/internal/catch_preprocessor.hpp | 8 +- .../catch_preprocessor_internal_stringify.hpp | 4 +- .../internal/catch_reporter_spec_parser.cpp | 24 +- .../internal/catch_reporter_spec_parser.hpp | 7 +- src/catch2/internal/catch_run_context.cpp | 16 +- src/catch2/internal/catch_run_context.hpp | 12 +- src/catch2/internal/catch_section.cpp | 2 +- src/catch2/internal/catch_section.hpp | 4 +- src/catch2/internal/catch_stream_end_stop.hpp | 4 +- src/catch2/internal/catch_string_manip.cpp | 24 +- src/catch2/internal/catch_string_manip.hpp | 25 +- src/catch2/internal/catch_stringref.cpp | 65 --- src/catch2/internal/catch_stringref.hpp | 123 ----- .../internal/catch_template_test_registry.hpp | 6 +- .../internal/catch_test_case_tracker.cpp | 10 +- .../internal/catch_test_case_tracker.hpp | 18 +- src/catch2/internal/catch_test_macro_impl.hpp | 11 +- src/catch2/internal/catch_test_registry.cpp | 4 +- src/catch2/internal/catch_test_registry.hpp | 29 +- src/catch2/internal/catch_xmlwriter.cpp | 34 +- src/catch2/internal/catch_xmlwriter.hpp | 32 +- src/catch2/matchers/catch_matchers_string.cpp | 16 +- src/catch2/matchers/catch_matchers_string.hpp | 8 +- .../matchers/catch_matchers_templated.cpp | 2 +- .../matchers/catch_matchers_templated.hpp | 10 +- .../matchers/internal/catch_matchers_impl.hpp | 4 +- src/catch2/meson.build | 2 - .../reporters/catch_reporter_compact.cpp | 24 +- .../reporters/catch_reporter_compact.hpp | 2 +- .../reporters/catch_reporter_console.cpp | 76 +-- .../reporters/catch_reporter_console.hpp | 8 +- .../catch_reporter_cumulative_base.hpp | 10 +- .../catch_reporter_event_listener.cpp | 10 +- .../catch_reporter_event_listener.hpp | 10 +- .../reporters/catch_reporter_helpers.cpp | 16 +- src/catch2/reporters/catch_reporter_json.cpp | 116 ++--- src/catch2/reporters/catch_reporter_json.hpp | 8 +- src/catch2/reporters/catch_reporter_junit.cpp | 42 +- src/catch2/reporters/catch_reporter_multi.cpp | 10 +- src/catch2/reporters/catch_reporter_multi.hpp | 10 +- .../reporters/catch_reporter_registrars.hpp | 10 +- .../reporters/catch_reporter_sonarqube.cpp | 14 +- .../reporters/catch_reporter_sonarqube.hpp | 2 +- .../catch_reporter_streaming_base.hpp | 12 +- src/catch2/reporters/catch_reporter_tap.cpp | 28 +- src/catch2/reporters/catch_reporter_tap.hpp | 2 +- .../reporters/catch_reporter_teamcity.cpp | 2 +- src/catch2/reporters/catch_reporter_xml.cpp | 106 ++-- src/catch2/reporters/catch_reporter_xml.hpp | 4 +- tests/BUILD.bazel | 1 - tests/CMakeLists.txt | 1 - .../Baselines/automake.sw.approved.txt | 2 - .../Baselines/automake.sw.multi.approved.txt | 2 - .../Baselines/compact.sw.approved.txt | 109 +--- .../Baselines/compact.sw.multi.approved.txt | 109 +--- .../Baselines/console.std.approved.txt | 4 +- .../Baselines/console.sw.approved.txt | 493 ++---------------- .../Baselines/console.sw.multi.approved.txt | 493 ++---------------- .../SelfTest/Baselines/junit.sw.approved.txt | 29 +- .../Baselines/junit.sw.multi.approved.txt | 29 +- .../Baselines/sonarqube.sw.approved.txt | 29 -- .../Baselines/sonarqube.sw.multi.approved.txt | 29 -- tests/SelfTest/Baselines/tap.sw.approved.txt | 150 +----- .../Baselines/tap.sw.multi.approved.txt | 150 +----- .../Baselines/teamcity.sw.approved.txt | 4 - .../Baselines/teamcity.sw.multi.approved.txt | 4 - tests/SelfTest/Baselines/xml.sw.approved.txt | 486 ++--------------- .../Baselines/xml.sw.multi.approved.txt | 486 ++--------------- .../AssertionHandler.tests.cpp | 2 +- .../GeneratorsImpl.tests.cpp | 20 +- .../IntrospectiveTests/PartTracker.tests.cpp | 2 +- .../IntrospectiveTests/Reporters.tests.cpp | 10 +- .../IntrospectiveTests/String.tests.cpp | 212 -------- .../IntrospectiveTests/StringManip.tests.cpp | 21 +- .../SelfTest/IntrospectiveTests/Tag.tests.cpp | 8 +- .../IntrospectiveTests/ToString.tests.cpp | 36 +- tests/meson.build | 1 - 119 files changed, 913 insertions(+), 3430 deletions(-) delete mode 100644 src/catch2/internal/catch_stringref.cpp delete mode 100644 src/catch2/internal/catch_stringref.hpp delete mode 100644 tests/SelfTest/IntrospectiveTests/String.tests.cpp diff --git a/docs/reporter-events.md b/docs/reporter-events.md index 015f67be..a9ed40cf 100644 --- a/docs/reporter-events.md +++ b/docs/reporter-events.md @@ -109,10 +109,10 @@ and then `assertionEnded` event is emitted. > [Introduced](https://github.com/catchorg/Catch2/issues/1616) in Catch2 2.9.0. ```cpp -void benchmarkPreparing( StringRef name ) override; +void benchmarkPreparing( std::string_view name ) override; void benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) override; void benchmarkEnded( BenchmarkStats<> const& benchmarkStats ) override; -void benchmarkFailed( StringRef error ) override; +void benchmarkFailed( std::string_view error ) override; ``` Due to the benchmark lifecycle being bit more complicated, the benchmarking @@ -153,9 +153,9 @@ void listTags( std::vector const& tagInfos ); ## Miscellaneous events ```cpp -void reportInvalidTestSpec( StringRef unmatchedSpec ); -void fatalErrorEncountered( StringRef error ); -void noMatchingTestCases( StringRef unmatchedSpec ); +void reportInvalidTestSpec( std::string_view unmatchedSpec ); +void fatalErrorEncountered( std::string_view error ); +void noMatchingTestCases( std::string_view unmatchedSpec ); ``` These are one-off events that do not neatly fit into other categories. diff --git a/examples/210-Evt-EventListeners.cpp b/examples/210-Evt-EventListeners.cpp index 26d5c62c..8550e179 100644 --- a/examples/210-Evt-EventListeners.cpp +++ b/examples/210-Evt-EventListeners.cpp @@ -131,7 +131,7 @@ void print( std::ostream& os, int const level, std::string const& title, Catch:: } // struct Tag { -// StringRef original, lowerCased; +// std::string_view original, lowerCased; // }; // // @@ -221,9 +221,9 @@ void print( std::ostream& os, int const level, std::string const& title, Catch:: // struct AssertionInfo // { -// StringRef macroName; +// std::string_view macroName; // SourceLineInfo lineInfo; -// StringRef capturedExpression; +// std::string_view capturedExpression; // ResultDisposition::Flags resultDisposition; // }; 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 #include #include -#include #include #include #include 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 #include -#include + +#include 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 #include #include -#include #include #include @@ -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 #include #include -#include #include #include #include @@ -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 #include #include -#include #include #include @@ -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(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 #include -#include #include #include diff --git a/src/catch2/catch_test_case_info.cpp b/src/catch2/catch_test_case_info.cpp index 9d64e532..407b8673 100644 --- a/src/catch2/catch_test_case_info.cpp +++ b/src/catch2/catch_test_case_info.cpp @@ -14,6 +14,7 @@ #include #include #include +#include namespace Catch { @@ -47,28 +48,28 @@ namespace Catch { return tcp != TestCaseProperties::None; } - TestCaseProperties parseSpecialTag( StringRef tag ) { + TestCaseProperties parseSpecialTag( std::string_view tag ) { if( !tag.empty() && tag[0] == '.' ) return TestCaseProperties::IsHidden; - else if( tag == "!throws"_sr ) + else if( tag == "!throws" ) return TestCaseProperties::Throws; - else if( tag == "!shouldfail"_sr ) + else if( tag == "!shouldfail" ) return TestCaseProperties::ShouldFail; - else if( tag == "!mayfail"_sr ) + else if( tag == "!mayfail" ) return TestCaseProperties::MayFail; - else if( tag == "!nonportable"_sr ) + else if( tag == "!nonportable" ) return TestCaseProperties::NonPortable; - else if( tag == "!benchmark"_sr ) + else if( tag == "!benchmark" ) return TestCaseProperties::Benchmark | TestCaseProperties::IsHidden; else return TestCaseProperties::None; } - bool isReservedTag( StringRef tag ) { + bool isReservedTag( std::string_view tag ) { return parseSpecialTag( tag ) == TestCaseProperties::None && tag.size() > 0 && !std::isalnum( static_cast(tag[0]) ); } - void enforceNotReservedTag( StringRef tag, SourceLineInfo const& _lineInfo ) { + void enforceNotReservedTag( std::string_view tag, SourceLineInfo const& _lineInfo ) { CATCH_ENFORCE( !isReservedTag(tag), "Tag name: [" << tag << "] is not allowed.\n" << "Tag names starting with non alphanumeric characters are reserved\n" @@ -80,13 +81,13 @@ namespace Catch { return "Anonymous test case " + std::to_string(++counter); } - constexpr StringRef extractFilenamePart(StringRef filename) { + constexpr std::string_view extractFilenamePart(std::string_view filename) { size_t lastDot = filename.size(); while (lastDot > 0 && filename[lastDot - 1] != '.') { --lastDot; } // In theory we could have filename without any extension in it - if ( lastDot == 0 ) { return StringRef(); } + if ( lastDot == 0 ) { return std::string_view(); } --lastDot; size_t nameStart = lastDot; @@ -98,7 +99,7 @@ namespace Catch { } // Returns the upper bound on size of extra tags ([#file]+[.]) - constexpr size_t sizeOfExtraTags(StringRef filepath) { + constexpr size_t sizeOfExtraTags(std::string_view filepath) { // [.] is 3, [#] is another 3 const size_t extras = 3 + 3; return extractFilenamePart(filepath).size() + extras; @@ -115,20 +116,20 @@ namespace Catch { } Detail::unique_ptr - makeTestCaseInfo(StringRef _className, + makeTestCaseInfo(std::string_view _className, NameAndTags const& nameAndTags, SourceLineInfo const& _lineInfo ) { return Detail::make_unique(_className, nameAndTags, _lineInfo); } - TestCaseInfo::TestCaseInfo(StringRef _className, + TestCaseInfo::TestCaseInfo(std::string_view _className, NameAndTags const& _nameAndTags, SourceLineInfo const& _lineInfo): name( _nameAndTags.name.empty() ? makeDefaultName() : _nameAndTags.name ), className( _className ), lineInfo( _lineInfo ) { - StringRef originalTags = _nameAndTags.tags; + std::string_view originalTags = _nameAndTags.tags; // We need to reserve enough space to store all of the tags // (including optional hidden tag and filename tag) auto requiredSize = originalTags.size() + sizeOfExtraTags(_lineInfo.file); @@ -163,7 +164,7 @@ namespace Catch { // We need to check the tag for special meanings, copy // it over to backing storage and actually reference the // backing storage in the saved tags - StringRef tagStr = originalTags.substr(tagStart+1, tagEnd - tagStart - 1); + std::string_view tagStr = originalTags.substr(tagStart+1, tagEnd - tagStart - 1); CATCH_ENFORCE( !tagStr.empty(), "Found an empty tag while registering test case '" << _nameAndTags.name << "' at " @@ -190,7 +191,7 @@ namespace Catch { // Add [.] if relevant if (isHidden()) { - internalAppendTag("."_sr); + internalAppendTag("."); } // Sort and prepare tags @@ -235,13 +236,13 @@ namespace Catch { return ret; } - void TestCaseInfo::internalAppendTag(StringRef tagStr) { + void TestCaseInfo::internalAppendTag(std::string_view tagStr) { backingTags += '['; const auto backingStart = backingTags.size(); backingTags += tagStr; const auto backingEnd = backingTags.size(); backingTags += ']'; - tags.emplace_back(StringRef(backingTags.c_str() + backingStart, backingEnd - backingStart)); + tags.emplace_back(std::string_view(backingTags.c_str() + backingStart, backingEnd - backingStart)); } bool operator<( TestCaseInfo const& lhs, TestCaseInfo const& rhs ) { diff --git a/src/catch2/catch_test_case_info.hpp b/src/catch2/catch_test_case_info.hpp index 3466660c..c80f6644 100644 --- a/src/catch2/catch_test_case_info.hpp +++ b/src/catch2/catch_test_case_info.hpp @@ -11,12 +11,12 @@ #include #include #include -#include #include #include #include +#include #include #ifdef __clang__ @@ -34,10 +34,10 @@ namespace Catch { * as "cool-tag" internally. */ struct Tag { - constexpr Tag(StringRef original_): + constexpr Tag(std::string_view original_): original(original_) {} - StringRef original; + std::string_view original; friend bool operator< ( Tag const& lhs, Tag const& rhs ); friend bool operator==( Tag const& lhs, Tag const& rhs ); @@ -67,7 +67,7 @@ namespace Catch { */ struct TestCaseInfo : Detail::NonCopyable { - TestCaseInfo(StringRef _className, + TestCaseInfo(std::string_view _className, NameAndTags const& _nameAndTags, SourceLineInfo const& _lineInfo); @@ -87,12 +87,12 @@ namespace Catch { std::string tagsAsString() const; std::string name; - StringRef className; + std::string_view className; private: std::string backingTags; // Internally we copy tags to the backing storage and then add // refs to this storage to the tags vector. - void internalAppendTag(StringRef tagString); + void internalAppendTag(std::string_view tagString); public: std::vector tags; SourceLineInfo lineInfo; @@ -130,7 +130,7 @@ namespace Catch { }; Detail::unique_ptr - makeTestCaseInfo( StringRef className, + makeTestCaseInfo( std::string_view className, NameAndTags const& nameAndTags, SourceLineInfo const& lineInfo ); } diff --git a/src/catch2/catch_test_run_info.hpp b/src/catch2/catch_test_run_info.hpp index 90357b0a..92713b20 100644 --- a/src/catch2/catch_test_run_info.hpp +++ b/src/catch2/catch_test_run_info.hpp @@ -8,13 +8,13 @@ #ifndef CATCH_TEST_RUN_INFO_HPP_INCLUDED #define CATCH_TEST_RUN_INFO_HPP_INCLUDED -#include +#include namespace Catch { struct TestRunInfo { - constexpr TestRunInfo(StringRef _name) : name(_name) {} - StringRef name; + constexpr TestRunInfo(std::string_view _name) : name(_name) {} + std::string_view name; }; } // end namespace Catch diff --git a/src/catch2/catch_tostring.cpp b/src/catch2/catch_tostring.cpp index cadfdb56..20620488 100644 --- a/src/catch2/catch_tostring.cpp +++ b/src/catch2/catch_tostring.cpp @@ -58,7 +58,7 @@ namespace Detail { } } // end unnamed namespace - std::string convertIntoString(StringRef string, bool escapeInvisibles) { + std::string convertIntoString(std::string_view string, bool escapeInvisibles) { std::string ret; // This is enough for the "don't escape invisibles" case, and a good // lower bound on the "escape invisibles" case. @@ -96,7 +96,7 @@ namespace Detail { return ret; } - std::string convertIntoString(StringRef string) { + std::string convertIntoString(std::string_view string) { return convertIntoString(string, getCurrentContext().getConfig()->showInvisibles()); } @@ -137,7 +137,7 @@ std::string StringMaker::convert(const std::string& str) { } std::string StringMaker::convert(std::string_view str) { - return Detail::convertIntoString( StringRef( str.data(), str.size() ) ); + return Detail::convertIntoString( std::string_view( str.data(), str.size() ) ); } std::string StringMaker::convert(char const* str) { diff --git a/src/catch2/catch_tostring.hpp b/src/catch2/catch_tostring.hpp index bf6bcd56..87c8d703 100644 --- a/src/catch2/catch_tostring.hpp +++ b/src/catch2/catch_tostring.hpp @@ -46,14 +46,14 @@ namespace Catch { return n; } - constexpr StringRef unprintableString = "{?}"_sr; + constexpr std::string_view unprintableString = "{?}"; //! Encases `string in quotes, and optionally escapes invisibles - std::string convertIntoString( StringRef string, bool escapeInvisibles ); + std::string convertIntoString( std::string_view string, bool escapeInvisibles ); //! Encases `string` in quotes, and escapes invisibles if user requested //! it via CLI - std::string convertIntoString( StringRef string ); + std::string convertIntoString( std::string_view string ); std::string rawMemoryToString( const void *object, std::size_t size ); @@ -210,7 +210,7 @@ namespace Catch { struct StringMaker { static std::string convert(char const* str) { return Detail::convertIntoString( - StringRef( str, Detail::catch_strnlen( str, SZ ) ) ); + std::string_view( str, Detail::catch_strnlen( str, SZ ) ) ); } }; template @@ -218,7 +218,7 @@ namespace Catch { static std::string convert(signed char const* str) { auto reinterpreted = reinterpret_cast(str); return Detail::convertIntoString( - StringRef(reinterpreted, Detail::catch_strnlen(reinterpreted, SZ))); + std::string_view(reinterpreted, Detail::catch_strnlen(reinterpreted, SZ))); } }; template @@ -226,7 +226,7 @@ namespace Catch { static std::string convert(unsigned char const* str) { auto reinterpreted = reinterpret_cast(str); return Detail::convertIntoString( - StringRef(reinterpreted, Detail::catch_strnlen(reinterpreted, SZ))); + std::string_view(reinterpreted, Detail::catch_strnlen(reinterpreted, SZ))); } }; diff --git a/src/catch2/generators/catch_generators.cpp b/src/catch2/generators/catch_generators.cpp index 3514e9f6..4917a444 100644 --- a/src/catch2/generators/catch_generators.cpp +++ b/src/catch2/generators/catch_generators.cpp @@ -27,11 +27,11 @@ namespace Detail { GeneratorUntypedBase::~GeneratorUntypedBase() = default; - IGeneratorTracker* acquireGeneratorTracker(StringRef generatorName, SourceLineInfo const& lineInfo ) { + IGeneratorTracker* acquireGeneratorTracker(std::string_view generatorName, SourceLineInfo const& lineInfo ) { return getResultCapture().acquireGeneratorTracker( generatorName, lineInfo ); } - IGeneratorTracker* createGeneratorTracker( StringRef generatorName, + IGeneratorTracker* createGeneratorTracker( std::string_view generatorName, SourceLineInfo lineInfo, GeneratorBasePtr&& generator ) { return getResultCapture().createGeneratorTracker( diff --git a/src/catch2/generators/catch_generators.hpp b/src/catch2/generators/catch_generators.hpp index 0690bf6a..59c4b7cc 100644 --- a/src/catch2/generators/catch_generators.hpp +++ b/src/catch2/generators/catch_generators.hpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include @@ -197,14 +196,14 @@ namespace Detail { return makeGenerators( value( T( CATCH_FORWARD( val ) ) ), CATCH_FORWARD( moreGenerators )... ); } - IGeneratorTracker* acquireGeneratorTracker( StringRef generatorName, + IGeneratorTracker* acquireGeneratorTracker( std::string_view generatorName, SourceLineInfo const& lineInfo ); - IGeneratorTracker* createGeneratorTracker( StringRef generatorName, + IGeneratorTracker* createGeneratorTracker( std::string_view generatorName, SourceLineInfo lineInfo, GeneratorBasePtr&& generator ); template - auto generate( StringRef generatorName, SourceLineInfo const& lineInfo, L const& generatorExpression ) -> typename decltype(generatorExpression())::type { + auto generate( std::string_view generatorName, SourceLineInfo const& lineInfo, L const& generatorExpression ) -> typename decltype(generatorExpression())::type { using UnderlyingType = typename decltype(generatorExpression())::type; IGeneratorTracker* tracker = acquireGeneratorTracker( generatorName, lineInfo ); @@ -225,7 +224,7 @@ namespace Detail { } // namespace Generators } // namespace Catch -#define CATCH_INTERNAL_GENERATOR_STRINGIZE_IMPL( ... ) #__VA_ARGS__##_catch_sr +#define CATCH_INTERNAL_GENERATOR_STRINGIZE_IMPL( ... ) #__VA_ARGS__ #define CATCH_INTERNAL_GENERATOR_STRINGIZE(...) CATCH_INTERNAL_GENERATOR_STRINGIZE_IMPL(__VA_ARGS__) #define GENERATE( ... ) \ diff --git a/src/catch2/interfaces/catch_interfaces_capture.hpp b/src/catch2/interfaces/catch_interfaces_capture.hpp index b4fee6cd..737b7262 100644 --- a/src/catch2/interfaces/catch_interfaces_capture.hpp +++ b/src/catch2/interfaces/catch_interfaces_capture.hpp @@ -10,7 +10,6 @@ #include -#include #include #include #include @@ -43,31 +42,31 @@ namespace Catch { virtual ~IResultCapture(); virtual void notifyAssertionStarted( AssertionInfo const& info ) = 0; - virtual bool sectionStarted( StringRef sectionName, + virtual bool sectionStarted( std::string_view sectionName, SourceLineInfo const& sectionLineInfo, Counts& assertions ) = 0; virtual void sectionEnded( SectionEndInfo&& endInfo ) = 0; virtual void sectionEndedEarly( SectionEndInfo&& endInfo ) = 0; virtual IGeneratorTracker* - acquireGeneratorTracker( StringRef generatorName, + acquireGeneratorTracker( std::string_view generatorName, SourceLineInfo const& lineInfo ) = 0; virtual IGeneratorTracker* - createGeneratorTracker( StringRef generatorName, + createGeneratorTracker( std::string_view generatorName, SourceLineInfo lineInfo, Generators::GeneratorBasePtr&& generator ) = 0; - virtual void benchmarkPreparing( StringRef name ) = 0; + virtual void benchmarkPreparing( std::string_view name ) = 0; virtual void benchmarkStarting( BenchmarkInfo const& info ) = 0; virtual void benchmarkEnded( BenchmarkStats<> const& stats ) = 0; - virtual void benchmarkFailed( StringRef error ) = 0; + virtual void benchmarkFailed( std::string_view error ) = 0; virtual void pushScopedMessage( MessageInfo&& message ) = 0; virtual void popScopedMessage( unsigned int messageId ) = 0; virtual void emplaceUnscopedMessage( MessageBuilder&& builder ) = 0; - virtual void handleFatalErrorCondition( StringRef message ) = 0; + virtual void handleFatalErrorCondition( std::string_view message ) = 0; virtual void handleExpr ( AssertionInfo const& info, diff --git a/src/catch2/interfaces/catch_interfaces_config.hpp b/src/catch2/interfaces/catch_interfaces_config.hpp index 82a298db..8aa43a59 100644 --- a/src/catch2/interfaces/catch_interfaces_config.hpp +++ b/src/catch2/interfaces/catch_interfaces_config.hpp @@ -9,7 +9,6 @@ #define CATCH_INTERFACES_CONFIG_HPP_INCLUDED #include -#include #include #include @@ -66,7 +65,7 @@ namespace Catch { virtual ~IConfig(); virtual bool allowThrows() const = 0; - virtual StringRef name() const = 0; + virtual std::string_view name() const = 0; virtual bool includeSuccessfulResults() const = 0; virtual bool shouldDebugBreak() const = 0; virtual bool warnAboutMissingAssertions() const = 0; diff --git a/src/catch2/interfaces/catch_interfaces_enum_values_registry.hpp b/src/catch2/interfaces/catch_interfaces_enum_values_registry.hpp index 38b052d9..8a601bce 100644 --- a/src/catch2/interfaces/catch_interfaces_enum_values_registry.hpp +++ b/src/catch2/interfaces/catch_interfaces_enum_values_registry.hpp @@ -8,20 +8,19 @@ #ifndef CATCH_INTERFACES_ENUM_VALUES_REGISTRY_HPP_INCLUDED #define CATCH_INTERFACES_ENUM_VALUES_REGISTRY_HPP_INCLUDED -#include - +#include #include namespace Catch { namespace Detail { struct EnumInfo { - StringRef m_name; - std::vector> m_values; + std::string_view m_name; + std::vector> m_values; ~EnumInfo(); - StringRef lookup( int value ) const; + std::string_view lookup( int value ) const; }; } // namespace Detail @@ -29,10 +28,10 @@ namespace Catch { public: virtual ~IMutableEnumValuesRegistry(); // = default; - virtual Detail::EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::vector const& values ) = 0; + virtual Detail::EnumInfo const& registerEnum( std::string_view enumName, std::string_view allEnums, std::vector const& values ) = 0; template - Detail::EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::initializer_list values ) { + Detail::EnumInfo const& registerEnum( std::string_view enumName, std::string_view allEnums, std::initializer_list values ) { static_assert(sizeof(int) >= sizeof(E), "Cannot serialize enum to int"); std::vector intValues; intValues.reserve( values.size() ); diff --git a/src/catch2/interfaces/catch_interfaces_generatortracker.cpp b/src/catch2/interfaces/catch_interfaces_generatortracker.cpp index e9fa5dda..837bf63b 100644 --- a/src/catch2/interfaces/catch_interfaces_generatortracker.cpp +++ b/src/catch2/interfaces/catch_interfaces_generatortracker.cpp @@ -21,7 +21,7 @@ namespace Catch { return ret; } - StringRef GeneratorUntypedBase::currentElementAsString() const { + std::string_view GeneratorUntypedBase::currentElementAsString() const { if ( m_stringReprCache.empty() ) { m_stringReprCache = stringifyImpl(); } diff --git a/src/catch2/interfaces/catch_interfaces_generatortracker.hpp b/src/catch2/interfaces/catch_interfaces_generatortracker.hpp index d70cb593..2e83d39d 100644 --- a/src/catch2/interfaces/catch_interfaces_generatortracker.hpp +++ b/src/catch2/interfaces/catch_interfaces_generatortracker.hpp @@ -9,7 +9,6 @@ #define CATCH_INTERFACES_GENERATORTRACKER_HPP_INCLUDED #include -#include #include @@ -71,7 +70,7 @@ namespace Catch { * is destructed, or it moves onto the next element, whichever * comes first. */ - StringRef currentElementAsString() const; + std::string_view currentElementAsString() const; }; using GeneratorBasePtr = Catch::Detail::unique_ptr; diff --git a/src/catch2/interfaces/catch_interfaces_reporter.hpp b/src/catch2/interfaces/catch_interfaces_reporter.hpp index c7217889..7e9e85e8 100644 --- a/src/catch2/interfaces/catch_interfaces_reporter.hpp +++ b/src/catch2/interfaces/catch_interfaces_reporter.hpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include @@ -154,9 +153,9 @@ namespace Catch { } //! Called when no test cases match provided test spec - virtual void noMatchingTestCases( StringRef unmatchedSpec ) = 0; + virtual void noMatchingTestCases( std::string_view unmatchedSpec ) = 0; //! Called for all invalid test specs from the cli - virtual void reportInvalidTestSpec( StringRef invalidArgument ) = 0; + virtual void reportInvalidTestSpec( std::string_view invalidArgument ) = 0; /** * Called once in a testing run before tests are started @@ -173,13 +172,13 @@ namespace Catch { virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0; //! Called when user-code is being probed before the actual benchmark runs - virtual void benchmarkPreparing( StringRef benchmarkName ) = 0; + virtual void benchmarkPreparing( std::string_view benchmarkName ) = 0; //! Called after probe but before the user-code is being benchmarked virtual void benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) = 0; //! Called with the benchmark results if benchmark successfully finishes virtual void benchmarkEnded( BenchmarkStats<> const& benchmarkStats ) = 0; //! Called if running the benchmarks fails for any reason - virtual void benchmarkFailed( StringRef benchmarkName ) = 0; + virtual void benchmarkFailed( std::string_view benchmarkName ) = 0; //! Called before assertion success/failure is evaluated virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0; @@ -209,7 +208,7 @@ namespace Catch { virtual void skipTest( TestCaseInfo const& testInfo ) = 0; //! Called if a fatal error (signal/structured exception) occurred - virtual void fatalErrorEncountered( StringRef error ) = 0; + virtual void fatalErrorEncountered( std::string_view error ) = 0; //! Writes out information about provided reporters using reporter-specific format virtual void listReporters(std::vector const& descriptions) = 0; diff --git a/src/catch2/interfaces/catch_interfaces_reporter_factory.hpp b/src/catch2/interfaces/catch_interfaces_reporter_factory.hpp index 83ddd7bc..100f1dc0 100644 --- a/src/catch2/interfaces/catch_interfaces_reporter_factory.hpp +++ b/src/catch2/interfaces/catch_interfaces_reporter_factory.hpp @@ -9,7 +9,6 @@ #define CATCH_INTERFACES_REPORTER_FACTORY_HPP_INCLUDED #include -#include #include @@ -36,7 +35,7 @@ namespace Catch { virtual ~EventListenerFactory(); // = default virtual IEventListenerPtr create( IConfig const* config ) const = 0; //! Return a meaningful name for the listener, e.g. its type name - virtual StringRef getName() const = 0; + virtual std::string_view getName() const = 0; //! Return listener's description if available virtual std::string getDescription() const = 0; }; diff --git a/src/catch2/internal/catch_assertion_handler.cpp b/src/catch2/internal/catch_assertion_handler.cpp index 9a28e79c..e812863f 100644 --- a/src/catch2/internal/catch_assertion_handler.cpp +++ b/src/catch2/internal/catch_assertion_handler.cpp @@ -15,9 +15,9 @@ namespace Catch { AssertionHandler::AssertionHandler - ( StringRef macroName, + ( std::string_view macroName, SourceLineInfo const& lineInfo, - StringRef capturedExpression, + std::string_view capturedExpression, ResultDisposition::Flags resultDisposition ) : m_assertionInfo{ macroName, lineInfo, capturedExpression, resultDisposition }, m_resultCapture( getResultCapture() ) diff --git a/src/catch2/internal/catch_assertion_handler.hpp b/src/catch2/internal/catch_assertion_handler.hpp index c71c6898..bc5ac052 100644 --- a/src/catch2/internal/catch_assertion_handler.hpp +++ b/src/catch2/internal/catch_assertion_handler.hpp @@ -30,9 +30,9 @@ namespace Catch { public: AssertionHandler - ( StringRef macroName, + ( std::string_view macroName, SourceLineInfo const& lineInfo, - StringRef capturedExpression, + std::string_view capturedExpression, ResultDisposition::Flags resultDisposition ); ~AssertionHandler() { if ( !m_completed ) { diff --git a/src/catch2/internal/catch_case_insensitive_comparisons.cpp b/src/catch2/internal/catch_case_insensitive_comparisons.cpp index b3e7b53a..9920e528 100644 --- a/src/catch2/internal/catch_case_insensitive_comparisons.cpp +++ b/src/catch2/internal/catch_case_insensitive_comparisons.cpp @@ -14,8 +14,8 @@ namespace Catch { namespace Detail { - bool CaseInsensitiveLess::operator()( StringRef lhs, - StringRef rhs ) const { + bool CaseInsensitiveLess::operator()( std::string_view lhs, + std::string_view rhs ) const { return std::lexicographical_compare( lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), @@ -23,8 +23,8 @@ namespace Catch { } bool - CaseInsensitiveEqualTo::operator()( StringRef lhs, - StringRef rhs ) const { + CaseInsensitiveEqualTo::operator()( std::string_view lhs, + std::string_view rhs ) const { return std::equal( lhs.begin(), lhs.end(), rhs.begin(), rhs.end(), diff --git a/src/catch2/internal/catch_case_insensitive_comparisons.hpp b/src/catch2/internal/catch_case_insensitive_comparisons.hpp index 33b77826..f8cf6a92 100644 --- a/src/catch2/internal/catch_case_insensitive_comparisons.hpp +++ b/src/catch2/internal/catch_case_insensitive_comparisons.hpp @@ -8,20 +8,20 @@ #ifndef CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED #define CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED -#include +#include namespace Catch { namespace Detail { //! Provides case-insensitive `op<` semantics when called struct CaseInsensitiveLess { - bool operator()( StringRef lhs, - StringRef rhs ) const; + bool operator()( std::string_view lhs, + std::string_view rhs ) const; }; //! Provides case-insensitive `op==` semantics when called struct CaseInsensitiveEqualTo { - bool operator()( StringRef lhs, - StringRef rhs ) const; + bool operator()( std::string_view lhs, + std::string_view rhs ) const; }; } // namespace Detail diff --git a/src/catch2/internal/catch_clara.cpp b/src/catch2/internal/catch_clara.cpp index f9dd9138..bbddc903 100644 --- a/src/catch2/internal/catch_clara.cpp +++ b/src/catch2/internal/catch_clara.cpp @@ -25,7 +25,7 @@ namespace { ; } - Catch::StringRef normaliseOpt( Catch::StringRef optName ) { + std::string_view normaliseOpt( std::string_view optName ) { if ( optName[0] == '-' #if defined(CATCH_PLATFORM_WINDOWS) || optName[0] == '/' @@ -37,7 +37,7 @@ namespace { return optName; } - static size_t find_first_separator(Catch::StringRef sr) { + static size_t find_first_separator(std::string_view sr) { auto is_separator = []( char c ) { return c == ' ' || c == ':' || c == '='; }; @@ -47,7 +47,7 @@ namespace { ++pos; } - return Catch::StringRef::npos; + return std::string_view::npos; } } // namespace @@ -65,10 +65,10 @@ namespace Catch { } if ( it != itEnd ) { - StringRef next = *it; + std::string_view next = *it; if ( isOptPrefix( next[0] ) ) { auto delimiterPos = find_first_separator(next); - if ( delimiterPos != StringRef::npos ) { + if ( delimiterPos != std::string_view::npos ) { m_tokenBuffer.push_back( { TokenType::Option, next.substr( 0, delimiterPos ) } ); @@ -205,7 +205,7 @@ namespace Catch { return { oss.str(), m_description }; } - bool Opt::isMatch(StringRef optToken) const { + bool Opt::isMatch(std::string_view optToken) const { auto normalisedToken = normaliseOpt(optToken); for (auto const& name : m_optNames) { if (normaliseOpt(name) == normalisedToken) @@ -243,12 +243,12 @@ namespace Catch { if (!tokens) return Detail::InternalParseResult::runtimeError( "Expected argument following " + - token.token); + std::string(token.token)); auto const& argToken = *tokens; if (argToken.type != Detail::TokenType::Argument) return Detail::InternalParseResult::runtimeError( "Expected argument following " + - token.token); + std::string(token.token)); const auto result = valueRef->setValue(static_cast(argToken.token)); if (!result) return Detail::InternalParseResult(result); @@ -436,7 +436,7 @@ namespace Catch { if ( !tokenParsed ) return Detail::InternalParseResult::runtimeError( "Unrecognised token: " + - result.value().remainingTokens()->token ); + std::string(result.value().remainingTokens()->token) ); } // !TBD Check missing required options return result; @@ -445,7 +445,7 @@ namespace Catch { Args::Args(int argc, char const* const* argv) : m_exeName(argv[0]), m_args(argv + 1, argv + argc) {} - Args::Args(std::initializer_list args) : + Args::Args(std::initializer_list args) : m_exeName(*args.begin()), m_args(args.begin() + 1, args.end()) {} diff --git a/src/catch2/internal/catch_clara.hpp b/src/catch2/internal/catch_clara.hpp index 49983b54..9b91bf33 100644 --- a/src/catch2/internal/catch_clara.hpp +++ b/src/catch2/internal/catch_clara.hpp @@ -22,7 +22,6 @@ #include -#include #include #include #include @@ -93,13 +92,13 @@ namespace Catch { enum class TokenType { Option, Argument }; struct Token { TokenType type; - StringRef token; + std::string_view token; }; // Abstracts iterators into args as a stream of tokens, with option // arguments uniformly handled class TokenStream { - using Iterator = std::vector::const_iterator; + using Iterator = std::vector::const_iterator; Iterator it; Iterator itEnd; std::vector m_tokenBuffer; @@ -302,7 +301,7 @@ namespace Catch { struct HelpColumns { std::string left; - StringRef descriptions; + std::string_view descriptions; }; template @@ -480,8 +479,8 @@ namespace Catch { protected: Optionality m_optionality = Optionality::Optional; std::shared_ptr m_ref; - StringRef m_hint; - StringRef m_description; + std::string_view m_hint; + std::string_view m_description; explicit ParserRefImpl( std::shared_ptr const& ref ): m_ref( ref ) {} @@ -490,29 +489,29 @@ namespace Catch { template ParserRefImpl( accept_many_t, LambdaT const& ref, - StringRef hint ): + std::string_view hint ): m_ref( std::make_shared>( ref ) ), m_hint( hint ) {} template >> - ParserRefImpl( T& ref, StringRef hint ): + ParserRefImpl( T& ref, std::string_view hint ): m_ref( std::make_shared>( ref ) ), m_hint( hint ) {} template >> - ParserRefImpl( LambdaT const& ref, StringRef hint ): + ParserRefImpl( LambdaT const& ref, std::string_view hint ): m_ref( std::make_shared>( ref ) ), m_hint( hint ) {} - DerivedT& operator()( StringRef description ) & { + DerivedT& operator()( std::string_view description ) & { m_description = description; return static_cast( *this ); } - DerivedT&& operator()( StringRef description ) && { + DerivedT&& operator()( std::string_view description ) && { m_description = description; return static_cast( *this ); } @@ -538,7 +537,7 @@ namespace Catch { return 1; } - StringRef hint() const { return m_hint; } + std::string_view hint() const { return m_hint; } }; } // namespace detail @@ -558,7 +557,7 @@ namespace Catch { // A parser for options class Opt : public Detail::ParserRefImpl { protected: - std::vector m_optNames; + std::vector m_optNames; public: template @@ -571,31 +570,31 @@ namespace Catch { template >> - Opt( LambdaT const& ref, StringRef hint ): + Opt( LambdaT const& ref, std::string_view hint ): ParserRefImpl( ref, hint ) {} template - Opt( accept_many_t, LambdaT const& ref, StringRef hint ): + Opt( accept_many_t, LambdaT const& ref, std::string_view hint ): ParserRefImpl( accept_many, ref, hint ) {} template >> - Opt( T& ref, StringRef hint ): + Opt( T& ref, std::string_view hint ): ParserRefImpl( ref, hint ) {} - Opt& operator[]( StringRef optName ) & { + Opt& operator[]( std::string_view optName ) & { m_optNames.push_back(optName); return *this; } - Opt&& operator[]( StringRef optName ) && { + Opt&& operator[]( std::string_view optName ) && { m_optNames.push_back( optName ); return CATCH_MOVE(*this); } Detail::HelpColumns getHelpColumns() const; - bool isMatch(StringRef optToken) const; + bool isMatch(std::string_view optToken) const; using ParserBase::parse; @@ -696,15 +695,15 @@ namespace Catch { */ class Args { friend Detail::TokenStream; - StringRef m_exeName; - std::vector m_args; + std::string_view m_exeName; + std::vector m_args; public: Args(int argc, char const* const* argv); // Helper constructor for testing - Args(std::initializer_list args); + Args(std::initializer_list args); - StringRef exeName() const { return m_exeName; } + std::string_view exeName() const { return m_exeName; } }; diff --git a/src/catch2/internal/catch_decomposer.cpp b/src/catch2/internal/catch_decomposer.cpp index 17a7bc95..4cfca2d3 100644 --- a/src/catch2/internal/catch_decomposer.cpp +++ b/src/catch2/internal/catch_decomposer.cpp @@ -17,7 +17,7 @@ namespace Catch { os << "Some class derived from ITransientExpression without overriding streamReconstructedExpression"; } - void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ) { + void formatReconstructedExpression( std::ostream &os, std::string const& lhs, std::string_view op, std::string const& rhs ) { if( lhs.size() + rhs.size() < 40 && lhs.find('\n') == std::string::npos && rhs.find('\n') == std::string::npos ) diff --git a/src/catch2/internal/catch_decomposer.hpp b/src/catch2/internal/catch_decomposer.hpp index 18398dc4..fd7613aa 100644 --- a/src/catch2/internal/catch_decomposer.hpp +++ b/src/catch2/internal/catch_decomposer.hpp @@ -9,7 +9,6 @@ #define CATCH_DECOMPOSER_HPP_INCLUDED #include -#include #include #include #include @@ -189,12 +188,12 @@ namespace Catch { } }; - void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ); + void formatReconstructedExpression( std::ostream &os, std::string const& lhs, std::string_view op, std::string const& rhs ); template class BinaryExpr : public ITransientExpression { LhsT m_lhs; - StringRef m_op; + std::string_view m_op; RhsT m_rhs; void streamReconstructedExpression( std::ostream &os ) const override { @@ -203,7 +202,7 @@ namespace Catch { } public: - constexpr BinaryExpr( bool comparisonResult, LhsT lhs, StringRef op, RhsT rhs ) + constexpr BinaryExpr( bool comparisonResult, LhsT lhs, std::string_view op, RhsT rhs ) : ITransientExpression{ true, comparisonResult }, m_lhs( lhs ), m_op( op ), @@ -298,7 +297,7 @@ namespace Catch { Detail::RemoveCVRef_t>>>, \ BinaryExpr> { \ return { \ - static_cast( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ + static_cast( lhs.m_lhs op rhs ), lhs.m_lhs, #op, rhs }; \ } \ template \ constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ @@ -307,7 +306,7 @@ namespace Catch { capture_by_value>, \ BinaryExpr> { \ return { \ - static_cast( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ + static_cast( lhs.m_lhs op rhs ), lhs.m_lhs, #op, rhs }; \ } \ template \ constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ @@ -321,7 +320,7 @@ namespace Catch { BinaryExpr> { \ if ( rhs != 0 ) { throw_test_failure_exception(); } \ return { \ - static_cast( lhs.m_lhs op 0 ), lhs.m_lhs, #op##_sr, rhs }; \ + static_cast( lhs.m_lhs op 0 ), lhs.m_lhs, #op, rhs }; \ } \ template \ constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ @@ -334,7 +333,7 @@ namespace Catch { std::is_same>>, \ BinaryExpr> { \ if ( lhs.m_lhs != 0 ) { throw_test_failure_exception(); } \ - return { static_cast( 0 op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ + return { static_cast( 0 op rhs ), lhs.m_lhs, #op, rhs }; \ } CATCH_INTERNAL_DEFINE_EXPRESSION_EQUALITY_OPERATOR( eq, == ) @@ -352,7 +351,7 @@ namespace Catch { Detail::RemoveCVRef_t>>>, \ BinaryExpr> { \ return { \ - static_cast( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ + static_cast( lhs.m_lhs op rhs ), lhs.m_lhs, #op, rhs }; \ } \ template \ constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ @@ -361,7 +360,7 @@ namespace Catch { capture_by_value> , \ BinaryExpr> { \ return { \ - static_cast( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ + static_cast( lhs.m_lhs op rhs ), lhs.m_lhs, #op, rhs }; \ } \ template \ constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ @@ -373,7 +372,7 @@ namespace Catch { BinaryExpr> { \ if ( rhs != 0 ) { throw_test_failure_exception(); } \ return { \ - static_cast( lhs.m_lhs op 0 ), lhs.m_lhs, #op##_sr, rhs }; \ + static_cast( lhs.m_lhs op 0 ), lhs.m_lhs, #op, rhs }; \ } \ template \ constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ @@ -384,7 +383,7 @@ namespace Catch { std::is_same>, \ BinaryExpr> { \ if ( lhs.m_lhs != 0 ) { throw_test_failure_exception(); } \ - return { static_cast( 0 op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ + return { static_cast( 0 op rhs ), lhs.m_lhs, #op, rhs }; \ } CATCH_INTERNAL_DEFINE_EXPRESSION_COMPARISON_OPERATOR( lt, < ) @@ -402,14 +401,14 @@ namespace Catch { !capture_by_value>::value, \ BinaryExpr> { \ return { \ - static_cast( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ + static_cast( lhs.m_lhs op rhs ), lhs.m_lhs, #op, rhs }; \ } \ template \ constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ -> std::enable_if_t::value, \ BinaryExpr> { \ return { \ - static_cast( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ + static_cast( lhs.m_lhs op rhs ), lhs.m_lhs, #op, rhs }; \ } CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR(|) diff --git a/src/catch2/internal/catch_enum_values_registry.cpp b/src/catch2/internal/catch_enum_values_registry.cpp index a94b6088..a0eeee46 100644 --- a/src/catch2/internal/catch_enum_values_registry.cpp +++ b/src/catch2/internal/catch_enum_values_registry.cpp @@ -19,7 +19,7 @@ namespace Catch { namespace { // Extracts the actual name part of an enum instance // In other words, it returns the Blue part of Bikeshed::Colour::Blue - StringRef extractInstanceName(StringRef enumInstance) { + std::string_view extractInstanceName(std::string_view enumInstance) { // Find last occurrence of ":" size_t name_start = enumInstance.size(); while (name_start > 0 && enumInstance[name_start - 1] != ':') { @@ -29,9 +29,9 @@ namespace Catch { } } - std::vector parseEnums( StringRef enums ) { + std::vector parseEnums( std::string_view enums ) { auto enumValues = splitStringRef( enums, ',' ); - std::vector parsed; + std::vector parsed; parsed.reserve( enumValues.size() ); for( auto const& enumValue : enumValues ) { parsed.push_back(trim(extractInstanceName(enumValue))); @@ -41,15 +41,15 @@ namespace Catch { EnumInfo::~EnumInfo() = default; - StringRef EnumInfo::lookup( int value ) const { + std::string_view EnumInfo::lookup( int value ) const { for( auto const& valueToName : m_values ) { if( valueToName.first == value ) return valueToName.second; } - return "{** unexpected enum value **}"_sr; + return "{** unexpected enum value **}"; } - Catch::Detail::unique_ptr makeEnumInfo( StringRef enumName, StringRef allValueNames, std::vector const& values ) { + Catch::Detail::unique_ptr makeEnumInfo( std::string_view enumName, std::string_view allValueNames, std::vector const& values ) { auto enumInfo = Catch::Detail::make_unique(); enumInfo->m_name = enumName; enumInfo->m_values.reserve( values.size() ); @@ -63,11 +63,10 @@ namespace Catch { return enumInfo; } - EnumInfo const& EnumValuesRegistry::registerEnum( StringRef enumName, StringRef allValueNames, std::vector const& values ) { + EnumInfo const& EnumValuesRegistry::registerEnum( std::string_view enumName, std::string_view allValueNames, std::vector const& values ) { m_enumInfos.push_back(makeEnumInfo(enumName, allValueNames, values)); return *m_enumInfos.back(); } } // Detail } // Catch - diff --git a/src/catch2/internal/catch_enum_values_registry.hpp b/src/catch2/internal/catch_enum_values_registry.hpp index de994c35..82399c9a 100644 --- a/src/catch2/internal/catch_enum_values_registry.hpp +++ b/src/catch2/internal/catch_enum_values_registry.hpp @@ -10,7 +10,6 @@ #include #include -#include #include @@ -18,16 +17,16 @@ namespace Catch { namespace Detail { - Catch::Detail::unique_ptr makeEnumInfo( StringRef enumName, StringRef allValueNames, std::vector const& values ); + Catch::Detail::unique_ptr makeEnumInfo( std::string_view enumName, std::string_view allValueNames, std::vector const& values ); class EnumValuesRegistry : public IMutableEnumValuesRegistry { std::vector> m_enumInfos; - EnumInfo const& registerEnum( StringRef enumName, StringRef allValueNames, std::vector const& values) override; + EnumInfo const& registerEnum( std::string_view enumName, std::string_view allValueNames, std::vector const& values) override; }; - std::vector parseEnums( StringRef enums ); + std::vector parseEnums( std::string_view enums ); } // Detail diff --git a/src/catch2/internal/catch_jsonwriter.cpp b/src/catch2/internal/catch_jsonwriter.cpp index 6915c9c3..b4a749f8 100644 --- a/src/catch2/internal/catch_jsonwriter.cpp +++ b/src/catch2/internal/catch_jsonwriter.cpp @@ -17,21 +17,21 @@ namespace Catch { c == '\n' || c == '\r' || c == '\t'; } - static Catch::StringRef makeEscapeStringRef( char c ) { + static std::string_view makeEscapeStringRef( char c ) { if ( c == '"' ) { - return "\\\""_sr; + return "\\\""; } else if ( c == '\\' ) { - return "\\\\"_sr; + return "\\\\"; } else if ( c == '\b' ) { - return "\\b"_sr; + return "\\b"; } else if ( c == '\f' ) { - return "\\f"_sr; + return "\\f"; } else if ( c == '\n' ) { - return "\\n"_sr; + return "\\n"; } else if ( c == '\r' ) { - return "\\r"_sr; + return "\\r"; } else if ( c == '\t' ) { - return "\\t"_sr; + return "\\t"; } Catch::Detail::Unreachable(); } @@ -75,7 +75,7 @@ namespace Catch { m_os << '}'; } - JsonValueWriter JsonObjectWriter::write( StringRef key ) { + JsonValueWriter JsonObjectWriter::write( std::string_view key ) { JsonUtils::appendCommaNewline( m_os, m_should_comma, m_indent_level + 1 ); @@ -136,15 +136,15 @@ namespace Catch { return JsonArrayWriter{ m_os, m_indent_level }; } - void JsonValueWriter::write( Catch::StringRef value ) && { + void JsonValueWriter::write( std::string_view value ) && { writeImpl( value, true ); } void JsonValueWriter::write( bool value ) && { - writeImpl( value ? "true"_sr : "false"_sr, false ); + writeImpl( value ? "true" : "false", false ); } - void JsonValueWriter::writeImpl( Catch::StringRef value, bool quote ) { + void JsonValueWriter::writeImpl( std::string_view value, bool quote ) { if ( quote ) { m_os << '"'; } size_t current_start = 0; for ( size_t i = 0; i < value.size(); ++i ) { diff --git a/src/catch2/internal/catch_jsonwriter.hpp b/src/catch2/internal/catch_jsonwriter.hpp index a0ad6300..f78193c0 100644 --- a/src/catch2/internal/catch_jsonwriter.hpp +++ b/src/catch2/internal/catch_jsonwriter.hpp @@ -9,7 +9,6 @@ #define CATCH_JSONWRITER_HPP_INCLUDED #include -#include #include #include @@ -37,11 +36,11 @@ namespace Catch { void write( T const& value ) && { writeImpl( value, !std::is_arithmetic_v ); } - void write( StringRef value ) &&; + void write( std::string_view value ) &&; void write( bool value ) &&; private: - void writeImpl( StringRef value, bool quote ); + void writeImpl( std::string_view value, bool quote ); // Without this SFINAE, this overload is a better match // for `std::string`, `char const*`, `char const[N]` args. @@ -49,7 +48,7 @@ namespace Catch { // and multiple iteration over the strings template >> + !std::is_convertible_v>> void writeImpl( T const& value, bool quote_value ) { m_sstream << value; writeImpl( m_sstream.str(), quote_value ); @@ -70,7 +69,7 @@ namespace Catch { ~JsonObjectWriter(); - JsonValueWriter write( StringRef key ); + JsonValueWriter write( std::string_view key ); private: std::ostream& m_os; diff --git a/src/catch2/internal/catch_list.cpp b/src/catch2/internal/catch_list.cpp index 5bd06a2a..3fe17ce1 100644 --- a/src/catch2/internal/catch_list.cpp +++ b/src/catch2/internal/catch_list.cpp @@ -30,7 +30,7 @@ namespace Catch { auto const& testSpec = config.testSpec(); std::vector matchedTestCases = filterTests(getAllTestCasesSorted(config), testSpec, config); - std::map tagCounts; + std::map tagCounts; for (auto const& testCase : matchedTestCases) { for (auto const& tagName : testCase.getTestCaseInfo().tags) { auto it = tagCounts.find(tagName.original); @@ -75,7 +75,7 @@ namespace Catch { } // end anonymous namespace - void TagInfo::add( StringRef spelling ) { + void TagInfo::add( std::string_view spelling ) { ++count; spellings.insert( spelling ); } diff --git a/src/catch2/internal/catch_list.hpp b/src/catch2/internal/catch_list.hpp index 9b4abd82..3e631ab3 100644 --- a/src/catch2/internal/catch_list.hpp +++ b/src/catch2/internal/catch_list.hpp @@ -8,10 +8,9 @@ #ifndef CATCH_LIST_HPP_INCLUDED #define CATCH_LIST_HPP_INCLUDED -#include - #include #include +#include namespace Catch { @@ -24,15 +23,15 @@ namespace Catch { std::string name, description; }; struct ListenerDescription { - StringRef name; + std::string_view name; std::string description; }; struct TagInfo { - void add(StringRef spelling); + void add(std::string_view spelling); std::string all() const; - std::set spellings; + std::set spellings; std::size_t count = 0; }; diff --git a/src/catch2/internal/catch_message_info.cpp b/src/catch2/internal/catch_message_info.cpp index bc887abf..c5eae9e7 100644 --- a/src/catch2/internal/catch_message_info.cpp +++ b/src/catch2/internal/catch_message_info.cpp @@ -10,7 +10,7 @@ namespace Catch { - MessageInfo::MessageInfo( StringRef _macroName, + MessageInfo::MessageInfo( std::string_view _macroName, SourceLineInfo const& _lineInfo, ResultWas::OfType _type ) : macroName( _macroName ), diff --git a/src/catch2/internal/catch_message_info.hpp b/src/catch2/internal/catch_message_info.hpp index 8c18186b..8364b9e8 100644 --- a/src/catch2/internal/catch_message_info.hpp +++ b/src/catch2/internal/catch_message_info.hpp @@ -11,18 +11,17 @@ #include #include #include -#include #include namespace Catch { struct MessageInfo { - MessageInfo( StringRef _macroName, + MessageInfo( std::string_view _macroName, SourceLineInfo const& _lineInfo, ResultWas::OfType _type ); - StringRef macroName; + std::string_view macroName; std::string message; SourceLineInfo lineInfo; ResultWas::OfType type; diff --git a/src/catch2/internal/catch_preprocessor.hpp b/src/catch2/internal/catch_preprocessor.hpp index 1fc8fb8c..4de973a6 100644 --- a/src/catch2/internal/catch_preprocessor.hpp +++ b/src/catch2/internal/catch_preprocessor.hpp @@ -176,7 +176,7 @@ namespace Catch { template\ void reg_test(TypeList, Catch::NameAndTags nameAndTags)\ {\ - Catch::AutoReg( Catch::makeTestInvoker(&TestFunc), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), nameAndTags);\ + Catch::AutoReg( Catch::makeTestInvoker(&TestFunc), CATCH_INTERNAL_LINEINFO, std::string_view(), nameAndTags);\ } #define INTERNAL_CATCH_NTTP_REGISTER0(TestFunc, signature, ...) @@ -184,19 +184,19 @@ namespace Catch { template\ void reg_test(Nttp<__VA_ARGS__>, Catch::NameAndTags nameAndTags)\ {\ - Catch::AutoReg( Catch::makeTestInvoker(&TestFunc<__VA_ARGS__>), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), nameAndTags);\ + Catch::AutoReg( Catch::makeTestInvoker(&TestFunc<__VA_ARGS__>), CATCH_INTERNAL_LINEINFO, std::string_view(), nameAndTags);\ } #define INTERNAL_CATCH_NTTP_REGISTER_METHOD0(TestName, signature, ...)\ template\ - void reg_test(TypeList, Catch::StringRef className, Catch::NameAndTags nameAndTags)\ + void reg_test(TypeList, std::string_view className, Catch::NameAndTags nameAndTags)\ {\ Catch::AutoReg( Catch::makeTestInvoker(&TestName::test), CATCH_INTERNAL_LINEINFO, className, nameAndTags);\ } #define INTERNAL_CATCH_NTTP_REGISTER_METHOD(TestName, signature, ...)\ template\ - void reg_test(Nttp<__VA_ARGS__>, Catch::StringRef className, Catch::NameAndTags nameAndTags)\ + void reg_test(Nttp<__VA_ARGS__>, std::string_view className, Catch::NameAndTags nameAndTags)\ {\ Catch::AutoReg( Catch::makeTestInvoker(&TestName<__VA_ARGS__>::test), CATCH_INTERNAL_LINEINFO, className, nameAndTags);\ } diff --git a/src/catch2/internal/catch_preprocessor_internal_stringify.hpp b/src/catch2/internal/catch_preprocessor_internal_stringify.hpp index 2fd64e1c..12a9ae8f 100644 --- a/src/catch2/internal/catch_preprocessor_internal_stringify.hpp +++ b/src/catch2/internal/catch_preprocessor_internal_stringify.hpp @@ -11,9 +11,9 @@ #include #if !defined(CATCH_CONFIG_DISABLE_STRINGIFICATION) - #define CATCH_INTERNAL_STRINGIFY(...) #__VA_ARGS__##_catch_sr + #define CATCH_INTERNAL_STRINGIFY(...) #__VA_ARGS__ #else - #define CATCH_INTERNAL_STRINGIFY(...) "Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION"_catch_sr + #define CATCH_INTERNAL_STRINGIFY(...) "Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION" #endif #endif // CATCH_PREPROCESSOR_INTERNAL_STRINGIFY_HPP_INCLUDED diff --git a/src/catch2/internal/catch_reporter_spec_parser.cpp b/src/catch2/internal/catch_reporter_spec_parser.cpp index 92c6fdfe..16641dd7 100644 --- a/src/catch2/internal/catch_reporter_spec_parser.cpp +++ b/src/catch2/internal/catch_reporter_spec_parser.cpp @@ -12,26 +12,30 @@ #include #include +#include namespace Catch { namespace { struct kvPair { - StringRef key, value; + std::string_view key, value; }; - kvPair splitKVPair(StringRef kvString) { - auto splitPos = static_cast( - std::find( kvString.begin(), kvString.end(), '=' ) - - kvString.begin() ); + kvPair splitKVPair(std::string_view kvString) { + const auto splitPos = kvString.find_first_of('='); - return { kvString.substr( 0, splitPos ), - kvString.substr( splitPos + 1, kvString.size() ) }; + const std::string_view key = kvString.substr( 0, splitPos ); + + std::string_view value; + if (splitPos < kvString.size()) + value = kvString.substr( splitPos + 1, kvString.size() ); + + return { key, value }; } } namespace Detail { - std::vector splitReporterSpec( StringRef reporterSpec ) { + std::vector splitReporterSpec( std::string_view reporterSpec ) { static constexpr auto separator = "::"; static constexpr size_t separatorSize = 2; @@ -80,7 +84,7 @@ namespace Catch { return parts; } - std::optional stringToColourMode( StringRef colourMode ) { + std::optional stringToColourMode( std::string_view colourMode ) { if ( colourMode == "default" ) { return ColourMode::PlatformDefault; } else if ( colourMode == "ansi" ) { @@ -103,7 +107,7 @@ namespace Catch { lhs.m_customOptions == rhs.m_customOptions; } - std::optional parseReporterSpec( StringRef reporterSpec ) { + std::optional parseReporterSpec( std::string_view reporterSpec ) { auto parts = Detail::splitReporterSpec( reporterSpec ); assert( parts.size() > 0 && "Split should never return empty vector" ); diff --git a/src/catch2/internal/catch_reporter_spec_parser.hpp b/src/catch2/internal/catch_reporter_spec_parser.hpp index daad31df..75e36dc6 100644 --- a/src/catch2/internal/catch_reporter_spec_parser.hpp +++ b/src/catch2/internal/catch_reporter_spec_parser.hpp @@ -9,7 +9,6 @@ #define CATCH_REPORTER_SPEC_PARSER_HPP_INCLUDED #include -#include #include #include @@ -22,9 +21,9 @@ namespace Catch { namespace Detail { //! Splits the reporter spec into reporter name and kv-pair options - std::vector splitReporterSpec( StringRef reporterSpec ); + std::vector splitReporterSpec( std::string_view reporterSpec ); - std::optional stringToColourMode( StringRef colourMode ); + std::optional stringToColourMode( std::string_view colourMode ); } /** @@ -78,7 +77,7 @@ namespace Catch { * * empty key/value in an custom kv pair * * ... */ - std::optional parseReporterSpec( StringRef reporterSpec ); + std::optional parseReporterSpec( std::string_view reporterSpec ); } diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp index e7f43fea..335ca2ce 100644 --- a/src/catch2/internal/catch_run_context.cpp +++ b/src/catch2/internal/catch_run_context.cpp @@ -366,7 +366,7 @@ namespace Catch { } } - bool RunContext::sectionStarted( StringRef sectionName, + bool RunContext::sectionStarted( std::string_view sectionName, SourceLineInfo const& sectionLineInfo, Counts& assertions ) { ITracker& sectionTracker = @@ -392,7 +392,7 @@ namespace Catch { return true; } IGeneratorTracker* - RunContext::acquireGeneratorTracker( StringRef generatorName, + RunContext::acquireGeneratorTracker( std::string_view generatorName, SourceLineInfo const& lineInfo ) { auto* tracker = Generators::GeneratorTracker::acquire( m_trackerContext, @@ -403,7 +403,7 @@ namespace Catch { } IGeneratorTracker* RunContext::createGeneratorTracker( - StringRef generatorName, + std::string_view generatorName, SourceLineInfo lineInfo, Generators::GeneratorBasePtr&& generator ) { @@ -466,7 +466,7 @@ namespace Catch { m_unfinishedSections.push_back(CATCH_MOVE(endInfo)); } - void RunContext::benchmarkPreparing( StringRef name ) { + void RunContext::benchmarkPreparing( std::string_view name ) { auto _ = scopedDeactivate( *m_outputRedirect ); m_reporter->benchmarkPreparing( name ); } @@ -478,7 +478,7 @@ namespace Catch { auto _ = scopedDeactivate( *m_outputRedirect ); m_reporter->benchmarkEnded( stats ); } - void RunContext::benchmarkFailed( StringRef error ) { + void RunContext::benchmarkFailed( std::string_view error ) { auto _ = scopedDeactivate( *m_outputRedirect ); m_reporter->benchmarkFailed( error ); } @@ -531,7 +531,7 @@ namespace Catch { m_shouldReportUnexpected = false; } - void RunContext::handleFatalErrorCondition( StringRef message ) { + void RunContext::handleFatalErrorCondition( std::string_view message ) { // We lock only when touching the reporters directly, to avoid // deadlocks when we call into other functions that also want // to lock the mutex before touching reporters. @@ -791,9 +791,9 @@ namespace Catch { m_activeTestCase->getTestCaseInfo().lineInfo; return AssertionInfo{ - testCaseJustStarted ? "TEST_CASE"_sr : StringRef(), + testCaseJustStarted ? "TEST_CASE" : std::string_view(), Detail::g_lastKnownLineInfo, - testCaseJustStarted ? StringRef() : "{Unknown expression after the reported line}"_sr, + testCaseJustStarted ? std::string_view() : "{Unknown expression after the reported line}", ResultDisposition::Normal }; } diff --git a/src/catch2/internal/catch_run_context.hpp b/src/catch2/internal/catch_run_context.hpp index a98608cf..5e8ac43c 100644 --- a/src/catch2/internal/catch_run_context.hpp +++ b/src/catch2/internal/catch_run_context.hpp @@ -73,7 +73,7 @@ namespace Catch { AssertionReaction &reaction ) override; void notifyAssertionStarted( AssertionInfo const& info ) override; - bool sectionStarted( StringRef sectionName, + bool sectionStarted( std::string_view sectionName, SourceLineInfo const& sectionLineInfo, Counts& assertions ) override; @@ -81,18 +81,18 @@ namespace Catch { void sectionEndedEarly( SectionEndInfo&& endInfo ) override; IGeneratorTracker* - acquireGeneratorTracker( StringRef generatorName, + acquireGeneratorTracker( std::string_view generatorName, SourceLineInfo const& lineInfo ) override; IGeneratorTracker* createGeneratorTracker( - StringRef generatorName, + std::string_view generatorName, SourceLineInfo lineInfo, Generators::GeneratorBasePtr&& generator ) override; - void benchmarkPreparing( StringRef name ) override; + void benchmarkPreparing( std::string_view name ) override; void benchmarkStarting( BenchmarkInfo const& info ) override; void benchmarkEnded( BenchmarkStats<> const& stats ) override; - void benchmarkFailed( StringRef error ) override; + void benchmarkFailed( std::string_view error ) override; void pushScopedMessage( MessageInfo&& message ) override; void popScopedMessage( unsigned int messageId ) override; @@ -105,7 +105,7 @@ namespace Catch { void exceptionEarlyReported() override; - void handleFatalErrorCondition( StringRef message ) override; + void handleFatalErrorCondition( std::string_view message ) override; bool lastAssertionPassed() override; diff --git a/src/catch2/internal/catch_section.cpp b/src/catch2/internal/catch_section.cpp index 677c2164..3dc3fd8c 100644 --- a/src/catch2/internal/catch_section.cpp +++ b/src/catch2/internal/catch_section.cpp @@ -24,7 +24,7 @@ namespace Catch { } Section::Section( SourceLineInfo const& _lineInfo, - StringRef _name, + std::string_view _name, const char* const ): m_info( { "invalid", static_cast( -1 ) }, std::string{} ), m_sectionIncluded( diff --git a/src/catch2/internal/catch_section.hpp b/src/catch2/internal/catch_section.hpp index b99a4c96..1dbfab9b 100644 --- a/src/catch2/internal/catch_section.hpp +++ b/src/catch2/internal/catch_section.hpp @@ -22,7 +22,7 @@ namespace Catch { public: Section( SectionInfo&& info ); Section( SourceLineInfo const& _lineInfo, - StringRef _name, + std::string_view _name, const char* const = nullptr ); ~Section(); @@ -71,7 +71,7 @@ namespace Catch { // symbol for static analysis. // The arguments are used as a dummy for checking warnings in the passed // expressions. - int GetNewSectionHint( StringRef, const char* const = nullptr ); + int GetNewSectionHint( std::string_view, const char* const = nullptr ); } // namespace Detail } // namespace Catch diff --git a/src/catch2/internal/catch_stream_end_stop.hpp b/src/catch2/internal/catch_stream_end_stop.hpp index 66d678cf..bd592a3e 100644 --- a/src/catch2/internal/catch_stream_end_stop.hpp +++ b/src/catch2/internal/catch_stream_end_stop.hpp @@ -8,7 +8,7 @@ #ifndef CATCH_STREAM_END_STOP_HPP_INCLUDED #define CATCH_STREAM_END_STOP_HPP_INCLUDED -#include +#include namespace Catch { @@ -17,7 +17,7 @@ namespace Catch { // as well as // << stuff +StreamEndStop struct StreamEndStop { - constexpr StringRef operator+() const { return StringRef(); } + constexpr std::string_view operator+() const { return std::string_view(); } template constexpr friend T const& operator+( T const& value, StreamEndStop ) { diff --git a/src/catch2/internal/catch_string_manip.cpp b/src/catch2/internal/catch_string_manip.cpp index 68983787..bcfb0518 100644 --- a/src/catch2/internal/catch_string_manip.cpp +++ b/src/catch2/internal/catch_string_manip.cpp @@ -7,28 +7,28 @@ // SPDX-License-Identifier: BSL-1.0 #include #include -#include #include #include #include +#include #include namespace Catch { - bool startsWith( std::string const& s, std::string const& prefix ) { + bool startsWith( std::string_view s, std::string_view prefix ) { return s.size() >= prefix.size() && std::equal(prefix.begin(), prefix.end(), s.begin()); } - bool startsWith( StringRef s, char prefix ) { + bool startsWith( std::string_view s, char prefix ) { return !s.empty() && s[0] == prefix; } - bool endsWith( std::string const& s, std::string const& suffix ) { + bool endsWith( std::string_view s, std::string_view suffix ) { return s.size() >= suffix.size() && std::equal(suffix.rbegin(), suffix.rend(), s.rbegin()); } - bool endsWith( std::string const& s, char suffix ) { + bool endsWith( std::string_view s, char suffix ) { return !s.empty() && s[s.size()-1] == suffix; } - bool contains( std::string const& s, std::string const& infix ) { + bool contains( std::string_view s, std::string_view infix ) { return s.find( infix ) != std::string::npos; } void toLowerInPlace( std::string& s ) { @@ -36,8 +36,8 @@ namespace Catch { c = toLower( c ); } } - std::string toLower( std::string const& s ) { - std::string lc = s; + std::string toLower( std::string_view s ) { + std::string lc(s); toLowerInPlace( lc ); return lc; } @@ -53,7 +53,7 @@ namespace Catch { return start != std::string::npos ? str.substr( start, 1+end-start ) : std::string(); } - StringRef trim(StringRef ref) { + std::string_view trim(std::string_view ref) { const auto is_ws = [](char c) { return c == ' ' || c == '\t' || c == '\n' || c == '\r'; }; @@ -65,7 +65,7 @@ namespace Catch { return ref.substr(real_begin, real_end - real_begin); } - bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ) { + bool replaceInPlace( std::string& str, std::string_view replaceThis, std::string_view withThis ) { std::size_t i = str.find( replaceThis ); if (i == std::string::npos) { return false; @@ -91,8 +91,8 @@ namespace Catch { return true; } - std::vector splitStringRef( StringRef str, char delimiter ) { - std::vector subStrings; + std::vector splitStringRef( std::string_view str, char delimiter ) { + std::vector subStrings; std::size_t start = 0; for(std::size_t pos = 0; pos < str.size(); ++pos ) { if( str[pos] == delimiter ) { diff --git a/src/catch2/internal/catch_string_manip.hpp b/src/catch2/internal/catch_string_manip.hpp index dc0c552c..42fea83a 100644 --- a/src/catch2/internal/catch_string_manip.hpp +++ b/src/catch2/internal/catch_string_manip.hpp @@ -8,31 +8,30 @@ #ifndef CATCH_STRING_MANIP_HPP_INCLUDED #define CATCH_STRING_MANIP_HPP_INCLUDED -#include - #include #include +#include #include #include namespace Catch { - bool startsWith( std::string const& s, std::string const& prefix ); - bool startsWith( StringRef s, char prefix ); - bool endsWith( std::string const& s, std::string const& suffix ); - bool endsWith( std::string const& s, char suffix ); - bool contains( std::string const& s, std::string const& infix ); + bool startsWith( std::string_view s, std::string_view prefix ); + bool startsWith( std::string_view s, char prefix ); + bool endsWith( std::string_view s, std::string_view suffix ); + bool endsWith( std::string_view s, char suffix ); + bool contains( std::string_view s, std::string_view infix ); void toLowerInPlace( std::string& s ); - std::string toLower( std::string const& s ); + std::string toLower( std::string_view s ); char toLower( char c ); //! Returns a new string without whitespace at the start/end std::string trim( std::string const& str ); //! Returns a substring of the original ref without whitespace. Beware lifetimes! - StringRef trim(StringRef ref); + std::string_view trim(std::string_view ref); // !!! Be aware, returns refs into original string - make sure original string outlives them - std::vector splitStringRef( StringRef str, char delimiter ); - bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ); + std::vector splitStringRef( std::string_view str, char delimiter ); + bool replaceInPlace( std::string& str, std::string_view replaceThis, std::string_view withThis ); /** * Helper for streaming a "count [maybe-plural-of-label]" human-friendly string @@ -46,10 +45,10 @@ namespace Catch { */ class pluralise { std::uint64_t m_count; - StringRef m_label; + std::string_view m_label; public: - constexpr pluralise(std::uint64_t count, StringRef label): + constexpr pluralise(std::uint64_t count, std::string_view label): m_count(count), m_label(label) {} diff --git a/src/catch2/internal/catch_stringref.cpp b/src/catch2/internal/catch_stringref.cpp deleted file mode 100644 index 5b593545..00000000 --- a/src/catch2/internal/catch_stringref.cpp +++ /dev/null @@ -1,65 +0,0 @@ - -// Copyright Catch2 Authors -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE.txt or copy at -// https://www.boost.org/LICENSE_1_0.txt) - -// SPDX-License-Identifier: BSL-1.0 -#include - -#include -#include -#include - -namespace Catch { - StringRef::StringRef( char const* rawChars ) noexcept - : StringRef( rawChars, std::strlen(rawChars) ) - {} - - - bool StringRef::operator<(StringRef rhs) const noexcept { - if (m_size < rhs.m_size) { - return strncmp(m_start, rhs.m_start, m_size) <= 0; - } - return strncmp(m_start, rhs.m_start, rhs.m_size) < 0; - } - - int StringRef::compare( StringRef rhs ) const { - auto cmpResult = - strncmp( m_start, rhs.m_start, std::min( m_size, rhs.m_size ) ); - - // This means that strncmp found a difference before the strings - // ended, and we can return it directly - if ( cmpResult != 0 ) { - return cmpResult; - } - - // If strings are equal up to length, then their comparison results on - // their size - if ( m_size < rhs.m_size ) { - return -1; - } else if ( m_size > rhs.m_size ) { - return 1; - } else { - return 0; - } - } - - auto operator << ( std::ostream& os, StringRef str ) -> std::ostream& { - return os.write(str.data(), static_cast(str.size())); - } - - std::string operator+(StringRef lhs, StringRef rhs) { - std::string ret; - ret.reserve(lhs.size() + rhs.size()); - ret += lhs; - ret += rhs; - return ret; - } - - auto operator+=( std::string& lhs, StringRef rhs ) -> std::string& { - lhs.append(rhs.data(), rhs.size()); - return lhs; - } - -} // namespace Catch diff --git a/src/catch2/internal/catch_stringref.hpp b/src/catch2/internal/catch_stringref.hpp deleted file mode 100644 index 421ce712..00000000 --- a/src/catch2/internal/catch_stringref.hpp +++ /dev/null @@ -1,123 +0,0 @@ - -// Copyright Catch2 Authors -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE.txt or copy at -// https://www.boost.org/LICENSE_1_0.txt) - -// SPDX-License-Identifier: BSL-1.0 -#ifndef CATCH_STRINGREF_HPP_INCLUDED -#define CATCH_STRINGREF_HPP_INCLUDED - -#include -#include -#include -#include - -#include - -namespace Catch { - - /// A non-owning string class (similar to the forthcoming std::string_view) - /// Note that, because a StringRef may be a substring of another string, - /// it may not be null terminated. - class StringRef { - public: - using size_type = std::size_t; - using const_iterator = const char*; - - static constexpr size_type npos{ static_cast( -1 ) }; - - private: - static constexpr char const* const s_empty = ""; - - char const* m_start = s_empty; - size_type m_size = 0; - - public: // construction - constexpr StringRef() noexcept = default; - - StringRef( char const* rawChars ) noexcept; - - constexpr StringRef( char const* rawChars, size_type size ) noexcept - : m_start( rawChars ), - m_size( size ) - {} - - StringRef( std::string const& stdString ) noexcept - : m_start( stdString.c_str() ), - m_size( stdString.size() ) - {} - - explicit operator std::string() const { - return std::string(m_start, m_size); - } - - public: // operators - auto operator == ( StringRef other ) const noexcept -> bool { - return m_size == other.m_size - && (std::memcmp( m_start, other.m_start, m_size ) == 0); - } - auto operator != (StringRef other) const noexcept -> bool { - return !(*this == other); - } - - constexpr auto operator[] ( size_type index ) const noexcept -> char { - assert(index < m_size); - return m_start[index]; - } - - bool operator<(StringRef rhs) const noexcept; - - public: // named queries - constexpr auto empty() const noexcept -> bool { - return m_size == 0; - } - constexpr auto size() const noexcept -> size_type { - return m_size; - } - - // Returns a substring of [start, start + length). - // If start + length > size(), then the substring is [start, size()). - // If start > size(), then the substring is empty. - constexpr StringRef substr(size_type start, size_type length) const noexcept { - if (start < m_size) { - const auto shortened_size = m_size - start; - return StringRef(m_start + start, (shortened_size < length) ? shortened_size : length); - } else { - return StringRef(); - } - } - - // Returns the current start pointer. May not be null-terminated. - constexpr char const* data() const noexcept { - return m_start; - } - - constexpr const_iterator begin() const { return m_start; } - constexpr const_iterator end() const { return m_start + m_size; } - - - friend std::string& operator += (std::string& lhs, StringRef rhs); - friend std::ostream& operator << (std::ostream& os, StringRef str); - friend std::string operator+(StringRef lhs, StringRef rhs); - - /** - * Provides a three-way comparison with rhs - * - * Returns negative number if lhs < rhs, 0 if lhs == rhs, and a positive - * number if lhs > rhs - */ - int compare( StringRef rhs ) const; - }; - - - constexpr auto operator ""_sr( char const* rawChars, std::size_t size ) noexcept -> StringRef { - return StringRef( rawChars, size ); - } -} // namespace Catch - -constexpr auto operator ""_catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef { - return Catch::StringRef( rawChars, size ); -} - -#endif // CATCH_STRINGREF_HPP_INCLUDED diff --git a/src/catch2/internal/catch_template_test_registry.hpp b/src/catch2/internal/catch_template_test_registry.hpp index 7aec888f..14067d61 100644 --- a/src/catch2/internal/catch_template_test_registry.hpp +++ b/src/catch2/internal/catch_template_test_registry.hpp @@ -135,7 +135,7 @@ constexpr char const* tmpl_types[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TmplTypes))};\ constexpr char const* types_list[] = {CATCH_REC_LIST(INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS, INTERNAL_CATCH_REMOVE_PARENS(TypesList))};\ constexpr auto num_types = sizeof(types_list) / sizeof(types_list[0]);\ - (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFuncName ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index / num_types]) + '<' + types_list[index % num_types] + '>', Tags } ), index++)... };/* NOLINT */\ + (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFuncName ), CATCH_INTERNAL_LINEINFO, std::string_view(), Catch::NameAndTags{ Name " - " + std::string(tmpl_types[index / num_types]) + '<' + types_list[index % num_types] + '>', Tags } ), index++)... };/* NOLINT */\ } \ }; \ static const int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \ @@ -181,7 +181,7 @@ void reg_tests() { \ size_t index = 0; \ using expander = size_t[]; \ - (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFunc ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ Name " - " INTERNAL_CATCH_STRINGIZE(TmplList) " - " + std::to_string(index), Tags } ), index++)... };/* NOLINT */\ + (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFunc ), CATCH_INTERNAL_LINEINFO, std::string_view(), Catch::NameAndTags{ Name " - " INTERNAL_CATCH_STRINGIZE(TmplList) " - " + std::to_string(index), Tags } ), index++)... };/* NOLINT */\ } \ };\ static const int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){ \ @@ -316,7 +316,7 @@ void reg_tests(){\ size_t index = 0;\ using expander = size_t[];\ - (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName::test ), CATCH_INTERNAL_LINEINFO, #ClassName##_catch_sr, Catch::NameAndTags{ Name " - " INTERNAL_CATCH_STRINGIZE(TmplList) " - " + std::to_string(index), Tags } ), index++)... };/* NOLINT */ \ + (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ Name " - " INTERNAL_CATCH_STRINGIZE(TmplList) " - " + std::to_string(index), Tags } ), index++)... };/* NOLINT */ \ }\ };\ static const int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\ diff --git a/src/catch2/internal/catch_test_case_tracker.cpp b/src/catch2/internal/catch_test_case_tracker.cpp index 1470b91c..5180ae0d 100644 --- a/src/catch2/internal/catch_test_case_tracker.cpp +++ b/src/catch2/internal/catch_test_case_tracker.cpp @@ -157,7 +157,7 @@ namespace TestCaseTracking { SectionTracker::SectionTracker( NameAndLocation&& nameAndLocation, TrackerContext& ctx, ITracker* parent ) : TrackerBase( CATCH_MOVE(nameAndLocation), ctx, parent ), - m_trimmed_name(trim(StringRef(ITracker::nameAndLocation().name))) + m_trimmed_name(trim(std::string_view(ITracker::nameAndLocation().name))) { if( parent ) { while ( !parent->isSectionTracker() ) { @@ -216,17 +216,17 @@ namespace TestCaseTracking { void SectionTracker::addInitialFilters( std::vector const& filters ) { if( !filters.empty() ) { m_filters.reserve( m_filters.size() + filters.size() + 2 ); - m_filters.emplace_back(StringRef{}); // Root - should never be consulted - m_filters.emplace_back(StringRef{}); // Test Case - not a section filter + m_filters.emplace_back(); // Root - should never be consulted + m_filters.emplace_back(); // Test Case - not a section filter m_filters.insert( m_filters.end(), filters.begin(), filters.end() ); } } - void SectionTracker::addNextFilters( std::vector const& filters ) { + void SectionTracker::addNextFilters( std::vector const& filters ) { if( filters.size() > 1 ) m_filters.insert( m_filters.end(), filters.begin()+1, filters.end() ); } - StringRef SectionTracker::trimmedName() const { + std::string_view SectionTracker::trimmedName() const { return m_trimmed_name; } diff --git a/src/catch2/internal/catch_test_case_tracker.hpp b/src/catch2/internal/catch_test_case_tracker.hpp index 50278c91..16914a98 100644 --- a/src/catch2/internal/catch_test_case_tracker.hpp +++ b/src/catch2/internal/catch_test_case_tracker.hpp @@ -10,9 +10,9 @@ #include #include -#include #include +#include #include namespace Catch { @@ -45,10 +45,10 @@ namespace TestCaseTracking { * around the owning variant. */ struct NameAndLocationRef { - StringRef name; + std::string_view name; SourceLineInfo location; - constexpr NameAndLocationRef( StringRef name_, + constexpr NameAndLocationRef( std::string_view name_, SourceLineInfo location_ ): name( name_ ), location( location_ ) {} @@ -59,7 +59,7 @@ namespace TestCaseTracking { // cost of repeating is trivial at that point (we will be paying // multiple strcmp/memcmps at that point). if ( lhs.location.line != rhs.location.line ) { return false; } - return StringRef( lhs.name ) == rhs.name && + return std::string_view( lhs.name ) == rhs.name && lhs.location == rhs.location; } friend bool operator==( NameAndLocationRef const& lhs, @@ -208,12 +208,12 @@ namespace TestCaseTracking { }; class SectionTracker : public TrackerBase { - std::vector m_filters; + std::vector m_filters; // Note that lifetime-wise we piggy back off the name stored in the `ITracker` parent`. // Currently it allocates owns the name, so this is safe. If it is later refactored // to not own the name, the name still has to outlive the `ITracker` parent, so // this should still be safe. - StringRef m_trimmed_name; + std::string_view m_trimmed_name; public: SectionTracker( NameAndLocation&& nameAndLocation, TrackerContext& ctx, ITracker* parent ); @@ -226,11 +226,11 @@ namespace TestCaseTracking { void tryOpen(); void addInitialFilters( std::vector const& filters ); - void addNextFilters( std::vector const& filters ); + void addNextFilters( std::vector const& filters ); //! Returns filters active in this tracker - std::vector const& getFilters() const { return m_filters; } + std::vector const& getFilters() const { return m_filters; } //! Returns whitespace-trimmed name of the tracked section - StringRef trimmedName() const; + std::string_view trimmedName() const; }; } // namespace TestCaseTracking diff --git a/src/catch2/internal/catch_test_macro_impl.hpp b/src/catch2/internal/catch_test_macro_impl.hpp index ccd5bb35..369a05d3 100644 --- a/src/catch2/internal/catch_test_macro_impl.hpp +++ b/src/catch2/internal/catch_test_macro_impl.hpp @@ -12,7 +12,6 @@ #include #include #include -#include #include // We need this suppression to leak, because it took until GCC 10 @@ -43,7 +42,7 @@ do { /* NOLINT(bugprone-infinite-loop) */ \ /* The expression should not be evaluated, but warnings should hopefully be checked */ \ CATCH_INTERNAL_IGNORE_BUT_WARN(__VA_ARGS__); \ - Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition ); \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition ); \ INTERNAL_CATCH_TRY { \ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ @@ -67,7 +66,7 @@ /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_NO_THROW( macroName, resultDisposition, ... ) \ do { \ - Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition ); \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition ); \ try { \ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ CATCH_INTERNAL_SUPPRESS_USELESS_CAST_WARNINGS \ @@ -84,7 +83,7 @@ /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_THROWS( macroName, resultDisposition, ... ) \ do { \ - Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition); \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition); \ if( catchAssertionHandler.allowThrows() ) \ try { \ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ @@ -105,7 +104,7 @@ /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_THROWS_AS( macroName, exceptionType, resultDisposition, expr ) \ do { \ - Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr) ", " CATCH_INTERNAL_STRINGIFY(exceptionType), resultDisposition ); \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr) ", " CATCH_INTERNAL_STRINGIFY(exceptionType), resultDisposition ); \ if( catchAssertionHandler.allowThrows() ) \ try { \ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ @@ -132,7 +131,7 @@ // Although this is matcher-based, it can be used with just a string #define INTERNAL_CATCH_THROWS_STR_MATCHES( macroName, resultDisposition, matcher, ... ) \ do { \ - Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ if( catchAssertionHandler.allowThrows() ) \ try { \ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ diff --git a/src/catch2/internal/catch_test_registry.cpp b/src/catch2/internal/catch_test_registry.cpp index d017c50e..358ce398 100644 --- a/src/catch2/internal/catch_test_registry.cpp +++ b/src/catch2/internal/catch_test_registry.cpp @@ -21,7 +21,7 @@ namespace Catch { ITestInvoker::~ITestInvoker() = default; namespace { - static StringRef extractClassName( StringRef classOrMethodName ) { + static std::string_view extractClassName( std::string_view classOrMethodName ) { if ( !startsWith( classOrMethodName, '&' ) ) { return classOrMethodName; } @@ -66,7 +66,7 @@ namespace Catch { return Detail::make_unique( testAsFunction ); } - AutoReg::AutoReg( Detail::unique_ptr invoker, SourceLineInfo const& lineInfo, StringRef classOrMethod, NameAndTags const& nameAndTags ) noexcept { + AutoReg::AutoReg( Detail::unique_ptr invoker, SourceLineInfo const& lineInfo, std::string_view classOrMethod, NameAndTags const& nameAndTags ) noexcept { CATCH_TRY { getMutableRegistryHub() .registerTest( diff --git a/src/catch2/internal/catch_test_registry.hpp b/src/catch2/internal/catch_test_registry.hpp index 5c3a226d..c36f512e 100644 --- a/src/catch2/internal/catch_test_registry.hpp +++ b/src/catch2/internal/catch_test_registry.hpp @@ -12,18 +12,11 @@ #include #include #include -#include #include #include #include -// GCC 5 and older do not properly handle disabling unused-variable warning -// with a _Pragma. This means that we have to leak the suppression to the -// user code as well :-( -#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ <= 5 -#pragma GCC diagnostic ignored "-Wunused-variable" -#endif - +#include namespace Catch { @@ -77,15 +70,15 @@ Detail::unique_ptr makeTestInvokerFixture( void ( C::*testAsMethod } struct NameAndTags { - constexpr NameAndTags( StringRef name_ = StringRef(), - StringRef tags_ = StringRef() ) noexcept: + constexpr NameAndTags( std::string_view name_ = {}, + std::string_view tags_ = {} ) noexcept: name( name_ ), tags( tags_ ) {} - StringRef name; - StringRef tags; + std::string_view name; + std::string_view tags; }; struct AutoReg : Detail::NonCopyable { - AutoReg( Detail::unique_ptr invoker, SourceLineInfo const& lineInfo, StringRef classOrMethod, NameAndTags const& nameAndTags ) noexcept; + AutoReg( Detail::unique_ptr invoker, SourceLineInfo const& lineInfo, std::string_view classOrMethod, NameAndTags const& nameAndTags ) noexcept; }; } // end namespace Catch @@ -111,7 +104,7 @@ struct AutoReg : Detail::NonCopyable { CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ - namespace{ const Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &TestName ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \ + namespace{ const Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &TestName ), CATCH_INTERNAL_LINEINFO, std::string_view(), Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ static void TestName() #define INTERNAL_CATCH_TESTCASE( ... ) \ @@ -164,7 +157,7 @@ static int catchInternalSectionHint = 0; const Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( \ Catch::makeTestInvoker( &TestName::test ), \ CATCH_INTERNAL_LINEINFO, \ - #ClassName##_catch_sr, \ + #ClassName, \ Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \ } \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ @@ -184,7 +177,7 @@ static int catchInternalSectionHint = 0; const Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( \ Catch::makeTestInvokerFixture( &TestName::test ), \ CATCH_INTERNAL_LINEINFO, \ - #ClassName##_catch_sr, \ + #ClassName, \ Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \ } \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ @@ -202,7 +195,7 @@ static int catchInternalSectionHint = 0; const Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( \ Catch::makeTestInvoker( &QualifiedMethod ), \ CATCH_INTERNAL_LINEINFO, \ - "&" #QualifiedMethod##_catch_sr, \ + "&" #QualifiedMethod, \ Catch::NameAndTags{ __VA_ARGS__ } ); \ } /* NOLINT */ \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION @@ -214,7 +207,7 @@ static int catchInternalSectionHint = 0; CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ - Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( Function ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \ + Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( Function ), CATCH_INTERNAL_LINEINFO, std::string_view(), Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ } while(false) diff --git a/src/catch2/internal/catch_xmlwriter.cpp b/src/catch2/internal/catch_xmlwriter.cpp index 67126be1..f5f00f75 100644 --- a/src/catch2/internal/catch_xmlwriter.cpp +++ b/src/catch2/internal/catch_xmlwriter.cpp @@ -47,7 +47,7 @@ namespace { void hexEscapeChar(std::ostream& os, unsigned char c) { std::ios_base::fmtflags f(os.flags()); - os << "\\x"_sr + os << "\\x" << std::uppercase << std::hex << std::setfill('0') << std::setw(2) << static_cast(c); os.flags(f); @@ -79,25 +79,25 @@ namespace { switch ( c ) { case '<': write_to( idx ); - os << "<"_sr; + os << "<"; break; case '&': write_to( idx ); - os << "&"_sr; + os << "&"; break; case '>': // See: http://www.w3.org/TR/xml/#syntax if ( idx > 2 && m_str[idx - 1] == ']' && m_str[idx - 2] == ']' ) { write_to( idx ); - os << ">"_sr; + os << ">"; } break; case '\"': if ( m_forWhat == ForAttributes ) { write_to( idx ); - os << """_sr; + os << """; } break; @@ -209,14 +209,14 @@ namespace { } XmlWriter::ScopedElement& - XmlWriter::ScopedElement::writeText( StringRef text, XmlFormatting fmt ) { + XmlWriter::ScopedElement::writeText( std::string_view text, XmlFormatting fmt ) { m_writer->writeText( text, fmt ); return *this; } XmlWriter::ScopedElement& - XmlWriter::ScopedElement::writeAttribute( StringRef name, - StringRef attribute ) { + XmlWriter::ScopedElement::writeAttribute( std::string_view name, + std::string_view attribute ) { m_writer->writeAttribute( name, attribute ); return *this; } @@ -273,25 +273,25 @@ namespace { return *this; } - XmlWriter& XmlWriter::writeAttribute( StringRef name, - StringRef attribute ) { + XmlWriter& XmlWriter::writeAttribute( std::string_view name, + std::string_view attribute ) { if( !name.empty() && !attribute.empty() ) m_os << ' ' << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << '"'; return *this; } - XmlWriter& XmlWriter::writeAttribute( StringRef name, bool attribute ) { - writeAttribute(name, (attribute ? "true"_sr : "false"_sr)); + XmlWriter& XmlWriter::writeAttribute( std::string_view name, bool attribute ) { + writeAttribute(name, (attribute ? "true" : "false")); return *this; } - XmlWriter& XmlWriter::writeAttribute( StringRef name, + XmlWriter& XmlWriter::writeAttribute( std::string_view name, char const* attribute ) { - writeAttribute( name, StringRef( attribute ) ); + writeAttribute( name, std::string_view( attribute ) ); return *this; } - XmlWriter& XmlWriter::writeText( StringRef text, XmlFormatting fmt ) { + XmlWriter& XmlWriter::writeText( std::string_view text, XmlFormatting fmt ) { CATCH_ENFORCE(!m_tags.empty(), "Cannot write text as top level element"); if( !text.empty() ){ bool tagWasOpen = m_tagIsOpen; @@ -305,7 +305,7 @@ namespace { return *this; } - XmlWriter& XmlWriter::writeComment( StringRef text, XmlFormatting fmt ) { + XmlWriter& XmlWriter::writeComment( std::string_view text, XmlFormatting fmt ) { ensureTagClosed(); if (shouldIndent(fmt)) { m_os << m_indent; @@ -315,7 +315,7 @@ namespace { return *this; } - void XmlWriter::writeStylesheetRef( StringRef url ) { + void XmlWriter::writeStylesheetRef( std::string_view url ) { m_os << R"()" << '\n'; } diff --git a/src/catch2/internal/catch_xmlwriter.hpp b/src/catch2/internal/catch_xmlwriter.hpp index 232a2272..dec65c61 100644 --- a/src/catch2/internal/catch_xmlwriter.hpp +++ b/src/catch2/internal/catch_xmlwriter.hpp @@ -9,11 +9,11 @@ #define CATCH_XMLWRITER_HPP_INCLUDED #include -#include #include #include #include +#include namespace Catch { enum class XmlFormatting : std::uint8_t { @@ -43,7 +43,7 @@ namespace Catch { public: enum ForWhat { ForTextNodes, ForAttributes }; - constexpr XmlEncode( StringRef str, ForWhat forWhat = ForTextNodes ): + constexpr XmlEncode( std::string_view str, ForWhat forWhat = ForTextNodes ): m_str( str ), m_forWhat( forWhat ) {} @@ -52,7 +52,7 @@ namespace Catch { friend std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode ); private: - StringRef m_str; + std::string_view m_str; ForWhat m_forWhat; }; @@ -69,20 +69,20 @@ namespace Catch { ~ScopedElement(); ScopedElement& - writeText( StringRef text, + writeText( std::string_view text, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent ); - ScopedElement& writeAttribute( StringRef name, - StringRef attribute ); + ScopedElement& writeAttribute( std::string_view name, + std::string_view attribute ); template >> - ScopedElement& writeAttribute( StringRef name, + !std::is_convertible_v>> + ScopedElement& writeAttribute( std::string_view name, T const& attribute ) { m_writer->writeAttribute( name, attribute ); return *this; @@ -106,13 +106,13 @@ namespace Catch { XmlWriter& endElement(XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent); //! The attribute content is XML-encoded - XmlWriter& writeAttribute( StringRef name, StringRef attribute ); + XmlWriter& writeAttribute( std::string_view name, std::string_view attribute ); //! Writes the attribute as "true/false" - XmlWriter& writeAttribute( StringRef name, bool attribute ); + XmlWriter& writeAttribute( std::string_view name, bool attribute ); //! The attribute content is XML-encoded - XmlWriter& writeAttribute( StringRef name, char const* attribute ); + XmlWriter& writeAttribute( std::string_view name, char const* attribute ); //! The attribute value must provide op<<(ostream&, T). The resulting //! serialization is XML-encoded @@ -122,24 +122,24 @@ namespace Catch { // While it would still work, it would cause code bloat // and multiple iteration over the strings typename = typename std::enable_if_t< - !std::is_convertible_v>> - XmlWriter& writeAttribute( StringRef name, T const& attribute ) { + !std::is_convertible_v>> + XmlWriter& writeAttribute( std::string_view name, T const& attribute ) { ReusableStringStream rss; rss << attribute; return writeAttribute( name, rss.str() ); } //! Writes escaped `text` in a element - XmlWriter& writeText( StringRef text, + XmlWriter& writeText( std::string_view text, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent ); //! Writes XML comment as "" - XmlWriter& writeComment( StringRef text, + XmlWriter& writeComment( std::string_view text, XmlFormatting fmt = XmlFormatting::Newline | XmlFormatting::Indent ); - void writeStylesheetRef( StringRef url ); + void writeStylesheetRef( std::string_view url ); void ensureTagClosed(); diff --git a/src/catch2/matchers/catch_matchers_string.cpp b/src/catch2/matchers/catch_matchers_string.cpp index 55002848..bde4c097 100644 --- a/src/catch2/matchers/catch_matchers_string.cpp +++ b/src/catch2/matchers/catch_matchers_string.cpp @@ -24,14 +24,14 @@ namespace Matchers { ? toLower( str ) : str; } - StringRef CasedString::caseSensitivitySuffix() const { + std::string_view CasedString::caseSensitivitySuffix() const { return m_caseSensitivity == CaseSensitive::Yes - ? StringRef() - : " (case insensitive)"_sr; + ? std::string_view() + : " (case insensitive)"; } - StringMatcherBase::StringMatcherBase( StringRef operation, CasedString const& comparator ) + StringMatcherBase::StringMatcherBase( std::string_view operation, CasedString const& comparator ) : m_comparator( comparator ), m_operation( operation ) { } @@ -48,28 +48,28 @@ namespace Matchers { return description; } - StringEqualsMatcher::StringEqualsMatcher( CasedString const& comparator ) : StringMatcherBase( "equals"_sr, comparator ) {} + StringEqualsMatcher::StringEqualsMatcher( CasedString const& comparator ) : StringMatcherBase( "equals", comparator ) {} bool StringEqualsMatcher::match( std::string const& source ) const { return m_comparator.adjustString( source ) == m_comparator.m_str; } - StringContainsMatcher::StringContainsMatcher( CasedString const& comparator ) : StringMatcherBase( "contains"_sr, comparator ) {} + StringContainsMatcher::StringContainsMatcher( CasedString const& comparator ) : StringMatcherBase( "contains", comparator ) {} bool StringContainsMatcher::match( std::string const& source ) const { return contains( m_comparator.adjustString( source ), m_comparator.m_str ); } - StartsWithMatcher::StartsWithMatcher( CasedString const& comparator ) : StringMatcherBase( "starts with"_sr, comparator ) {} + StartsWithMatcher::StartsWithMatcher( CasedString const& comparator ) : StringMatcherBase( "starts with", comparator ) {} bool StartsWithMatcher::match( std::string const& source ) const { return startsWith( m_comparator.adjustString( source ), m_comparator.m_str ); } - EndsWithMatcher::EndsWithMatcher( CasedString const& comparator ) : StringMatcherBase( "ends with"_sr, comparator ) {} + EndsWithMatcher::EndsWithMatcher( CasedString const& comparator ) : StringMatcherBase( "ends with", comparator ) {} bool EndsWithMatcher::match( std::string const& source ) const { return endsWith( m_comparator.adjustString( source ), m_comparator.m_str ); diff --git a/src/catch2/matchers/catch_matchers_string.hpp b/src/catch2/matchers/catch_matchers_string.hpp index 61a385d0..efe17d36 100644 --- a/src/catch2/matchers/catch_matchers_string.hpp +++ b/src/catch2/matchers/catch_matchers_string.hpp @@ -8,11 +8,11 @@ #ifndef CATCH_MATCHERS_STRING_HPP_INCLUDED #define CATCH_MATCHERS_STRING_HPP_INCLUDED -#include #include #include #include +#include namespace Catch { namespace Matchers { @@ -20,7 +20,7 @@ namespace Matchers { struct CasedString { CasedString( std::string const& str, CaseSensitive caseSensitivity ); std::string adjustString( std::string const& str ) const; - StringRef caseSensitivitySuffix() const; + std::string_view caseSensitivitySuffix() const; CaseSensitive m_caseSensitivity; std::string m_str; @@ -29,10 +29,10 @@ namespace Matchers { class StringMatcherBase : public MatcherBase { protected: CasedString m_comparator; - StringRef m_operation; + std::string_view m_operation; public: - StringMatcherBase( StringRef operation, + StringMatcherBase( std::string_view operation, CasedString const& comparator ); std::string describe() const override; }; diff --git a/src/catch2/matchers/catch_matchers_templated.cpp b/src/catch2/matchers/catch_matchers_templated.cpp index 2fc529d2..e395dc65 100644 --- a/src/catch2/matchers/catch_matchers_templated.cpp +++ b/src/catch2/matchers/catch_matchers_templated.cpp @@ -13,7 +13,7 @@ namespace Matchers { namespace Detail { - std::string describe_multi_matcher(StringRef combine, std::string const* descriptions_begin, std::string const* descriptions_end) { + std::string describe_multi_matcher(std::string_view combine, std::string const* descriptions_begin, std::string const* descriptions_end) { std::string description; std::size_t combined_size = 4; for ( auto desc = descriptions_begin; desc != descriptions_end; ++desc ) { diff --git a/src/catch2/matchers/catch_matchers_templated.hpp b/src/catch2/matchers/catch_matchers_templated.hpp index 79063446..9758cdd0 100644 --- a/src/catch2/matchers/catch_matchers_templated.hpp +++ b/src/catch2/matchers/catch_matchers_templated.hpp @@ -9,12 +9,12 @@ #define CATCH_MATCHERS_TEMPLATED_HPP_INCLUDED #include -#include #include #include #include #include +#include #include namespace Catch { @@ -93,10 +93,10 @@ namespace Matchers { return static_cast(matchers[Idx])->match(arg) || match_any_of(arg, matchers, std::index_sequence{}); } - std::string describe_multi_matcher(StringRef combine, std::string const* descriptions_begin, std::string const* descriptions_end); + std::string describe_multi_matcher(std::string_view combine, std::string const* descriptions_begin, std::string const* descriptions_end); template - std::string describe_multi_matcher(StringRef combine, std::array const& matchers, std::index_sequence) { + std::string describe_multi_matcher(std::string_view combine, std::array const& matchers, std::index_sequence) { std::array descriptions {{ static_cast(matchers[Idx])->toString()... }}; @@ -122,7 +122,7 @@ namespace Matchers { } std::string describe() const override { - return describe_multi_matcher(" and "_sr, m_matchers, std::index_sequence_for{}); + return describe_multi_matcher(" and ", m_matchers, std::index_sequence_for{}); } // Has to be public to enable the concatenating operators @@ -177,7 +177,7 @@ namespace Matchers { } std::string describe() const override { - return describe_multi_matcher(" or "_sr, m_matchers, std::index_sequence_for{}); + return describe_multi_matcher(" or ", m_matchers, std::index_sequence_for{}); } diff --git a/src/catch2/matchers/internal/catch_matchers_impl.hpp b/src/catch2/matchers/internal/catch_matchers_impl.hpp index 24a3f8b6..c8fa23ec 100644 --- a/src/catch2/matchers/internal/catch_matchers_impl.hpp +++ b/src/catch2/matchers/internal/catch_matchers_impl.hpp @@ -74,7 +74,7 @@ namespace Catch { /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CHECK_THAT( macroName, matcher, resultDisposition, arg ) \ do { \ - Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(arg) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(arg) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ INTERNAL_CATCH_TRY { \ catchAssertionHandler.handleExpr( Catch::makeMatchExpr( arg, matcher ) ); \ } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \ @@ -85,7 +85,7 @@ namespace Catch { /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_THROWS_MATCHES( macroName, exceptionType, resultDisposition, matcher, ... ) \ do { \ - Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) ", " CATCH_INTERNAL_STRINGIFY(exceptionType) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) ", " CATCH_INTERNAL_STRINGIFY(exceptionType) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ if( catchAssertionHandler.allowThrows() ) \ try { \ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ diff --git a/src/catch2/meson.build b/src/catch2/meson.build index 7116c85c..d776a322 100644 --- a/src/catch2/meson.build +++ b/src/catch2/meson.build @@ -132,7 +132,6 @@ internal_headers = [ 'internal/catch_stdstreams.hpp', 'internal/catch_stream_end_stop.hpp', 'internal/catch_string_manip.hpp', - 'internal/catch_stringref.hpp', 'internal/catch_tag_alias_registry.hpp', 'internal/catch_template_test_registry.hpp', 'internal/catch_test_case_info_hasher.hpp', @@ -242,7 +241,6 @@ internal_sources = files( 'internal/catch_startup_exception_registry.cpp', 'internal/catch_stdstreams.cpp', 'internal/catch_string_manip.cpp', - 'internal/catch_stringref.cpp', 'internal/catch_tag_alias_registry.cpp', 'internal/catch_test_case_info_hasher.cpp', 'internal/catch_test_case_registry_impl.cpp', diff --git a/src/catch2/reporters/catch_reporter_compact.cpp b/src/catch2/reporters/catch_reporter_compact.cpp index 6d2c8655..f2ac5f22 100644 --- a/src/catch2/reporters/catch_reporter_compact.cpp +++ b/src/catch2/reporters/catch_reporter_compact.cpp @@ -14,9 +14,9 @@ #include #include #include -#include #include +#include namespace Catch { namespace { @@ -25,11 +25,11 @@ namespace { static constexpr Colour::Code compactDimColour = Colour::FileName; #ifdef CATCH_PLATFORM_MAC - static constexpr Catch::StringRef compactFailedString = "FAILED"_sr; - static constexpr Catch::StringRef compactPassedString = "PASSED"_sr; + static constexpr std::string_view compactFailedString = "FAILED"; + static constexpr std::string_view compactPassedString = "PASSED"; #else - static constexpr Catch::StringRef compactFailedString = "failed"_sr; - static constexpr Catch::StringRef compactPassedString = "passed"_sr; + static constexpr std::string_view compactFailedString = "failed"; + static constexpr std::string_view compactPassedString = "passed"; #endif // Implementation of CompactReporter formatting @@ -63,7 +63,7 @@ public: break; case ResultWas::ExpressionFailed: if (result.isOk()) - printResultType(Colour::ResultSuccess, compactFailedString + " - but was ok"_sr); + printResultType(Colour::ResultSuccess, std::string(compactFailedString) + " - but was ok"); else printResultType(Colour::Error, compactFailedString); printOriginalExpression(); @@ -91,12 +91,12 @@ public: printRemainingMessages(); break; case ResultWas::Info: - printResultType(Colour::None, "info"_sr); + printResultType(Colour::None, "info"); printMessage(); printRemainingMessages(); break; case ResultWas::Warning: - printResultType(Colour::None, "warning"_sr); + printResultType(Colour::None, "warning"); printMessage(); printRemainingMessages(); break; @@ -106,7 +106,7 @@ public: printRemainingMessages(Colour::None); break; case ResultWas::ExplicitSkip: - printResultType(Colour::Skip, "skipped"_sr); + printResultType(Colour::Skip, "skipped"); printMessage(); printRemainingMessages(); break; @@ -125,7 +125,7 @@ private: << result.getSourceInfo() << ':'; } - void printResultType(Colour::Code colour, StringRef passOrFail) const { + void printResultType(Colour::Code colour, std::string_view passOrFail) const { if (!passOrFail.empty()) { stream << colourImpl->guardColour(colour) << ' ' << passOrFail; stream << ':'; @@ -174,7 +174,7 @@ private: const auto N = static_cast(itEnd - itMessage); stream << colourImpl->guardColour( colour ) << " with " - << pluralise( N, "message"_sr ) << ':'; + << pluralise( N, "message" ) << ':'; while (itMessage != itEnd) { // If this assertion is a warning ignore any INFO messages @@ -204,7 +204,7 @@ private: return "Reports test results on a single line, suitable for IDEs"; } - void CompactReporter::noMatchingTestCases( StringRef unmatchedSpec ) { + void CompactReporter::noMatchingTestCases( std::string_view unmatchedSpec ) { m_stream << "No test cases matched '" << unmatchedSpec << "'\n"; } diff --git a/src/catch2/reporters/catch_reporter_compact.hpp b/src/catch2/reporters/catch_reporter_compact.hpp index a6437c68..2c6f24a4 100644 --- a/src/catch2/reporters/catch_reporter_compact.hpp +++ b/src/catch2/reporters/catch_reporter_compact.hpp @@ -25,7 +25,7 @@ namespace Catch { static std::string getDescription(); - void noMatchingTestCases( StringRef unmatchedSpec ) override; + void noMatchingTestCases( std::string_view unmatchedSpec ) override; void testRunStarting( TestRunInfo const& _testInfo ) override; diff --git a/src/catch2/reporters/catch_reporter_console.cpp b/src/catch2/reporters/catch_reporter_console.cpp index acb4ae8e..7b4db4c9 100644 --- a/src/catch2/reporters/catch_reporter_console.cpp +++ b/src/catch2/reporters/catch_reporter_console.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -22,6 +21,7 @@ #include #include +#include #if defined(_MSC_VER) #pragma warning(push) @@ -57,78 +57,78 @@ public: switch (result.getResultType()) { case ResultWas::Ok: colour = Colour::Success; - passOrFail = "PASSED"_sr; + passOrFail = "PASSED"; //if( result.hasMessage() ) if (messages.size() == 1) - messageLabel = "with message"_sr; + messageLabel = "with message"; if (messages.size() > 1) - messageLabel = "with messages"_sr; + messageLabel = "with messages"; break; case ResultWas::ExpressionFailed: if (result.isOk()) { colour = Colour::Success; - passOrFail = "FAILED - but was ok"_sr; + passOrFail = "FAILED - but was ok"; } else { colour = Colour::Error; - passOrFail = "FAILED"_sr; + passOrFail = "FAILED"; } if (messages.size() == 1) - messageLabel = "with message"_sr; + messageLabel = "with message"; if (messages.size() > 1) - messageLabel = "with messages"_sr; + messageLabel = "with messages"; break; case ResultWas::ThrewException: colour = Colour::Error; - passOrFail = "FAILED"_sr; + passOrFail = "FAILED"; // todo switch switch (messages.size()) { case 0: - messageLabel = "due to unexpected exception with "_sr; + messageLabel = "due to unexpected exception with "; break; case 1: - messageLabel = "due to unexpected exception with message"_sr; + messageLabel = "due to unexpected exception with message"; break; default: - messageLabel = "due to unexpected exception with messages"_sr; + messageLabel = "due to unexpected exception with messages"; break; } break; case ResultWas::FatalErrorCondition: colour = Colour::Error; - passOrFail = "FAILED"_sr; - messageLabel = "due to a fatal error condition"_sr; + passOrFail = "FAILED"; + messageLabel = "due to a fatal error condition"; break; case ResultWas::DidntThrowException: colour = Colour::Error; - passOrFail = "FAILED"_sr; - messageLabel = "because no exception was thrown where one was expected"_sr; + passOrFail = "FAILED"; + messageLabel = "because no exception was thrown where one was expected"; break; case ResultWas::Info: - messageLabel = "info"_sr; + messageLabel = "info"; break; case ResultWas::Warning: - messageLabel = "warning"_sr; + messageLabel = "warning"; break; case ResultWas::ExplicitFailure: - passOrFail = "FAILED"_sr; + passOrFail = "FAILED"; colour = Colour::Error; if (messages.size() == 1) - messageLabel = "explicitly with message"_sr; + messageLabel = "explicitly with message"; if (messages.size() > 1) - messageLabel = "explicitly with messages"_sr; + messageLabel = "explicitly with messages"; break; case ResultWas::ExplicitSkip: colour = Colour::Skip; - passOrFail = "SKIPPED"_sr; + passOrFail = "SKIPPED"; if (messages.size() == 1) - messageLabel = "explicitly with message"_sr; + messageLabel = "explicitly with message"; if (messages.size() > 1) - messageLabel = "explicitly with messages"_sr; + messageLabel = "explicitly with messages"; break; // These cases are here to prevent compiler warnings case ResultWas::Unknown: case ResultWas::FailureBit: case ResultWas::Exception: - passOrFail = "** internal error **"_sr; + passOrFail = "** internal error **"; colour = Colour::Error; break; } @@ -185,8 +185,8 @@ private: AssertionStats const& stats; AssertionResult const& result; Colour::Code colour; - StringRef passOrFail; - StringRef messageLabel; + std::string_view passOrFail; + std::string_view messageLabel; std::vector const& messages; ColourImpl* colourImpl; bool printInfoMessages; @@ -263,20 +263,20 @@ public: return m_inNanoseconds; } } - StringRef unitsAsString() const { + std::string_view unitsAsString() const { switch (m_units) { case Unit::Nanoseconds: - return "ns"_sr; + return "ns"; case Unit::Microseconds: - return "us"_sr; + return "us"; case Unit::Milliseconds: - return "ms"_sr; + return "ms"; case Unit::Seconds: - return "s"_sr; + return "s"; case Unit::Minutes: - return "m"_sr; + return "m"; default: - return "** internal error **"_sr; + return "** internal error **"; } } @@ -411,11 +411,11 @@ std::string ConsoleReporter::getDescription() { return "Reports test results as plain lines of text"; } -void ConsoleReporter::noMatchingTestCases( StringRef unmatchedSpec ) { +void ConsoleReporter::noMatchingTestCases( std::string_view unmatchedSpec ) { m_stream << "No test cases matched '" << unmatchedSpec << "'\n"; } -void ConsoleReporter::reportInvalidTestSpec( StringRef arg ) { +void ConsoleReporter::reportInvalidTestSpec( std::string_view arg ) { m_stream << "Invalid Filter: " << arg << '\n'; } @@ -463,7 +463,7 @@ void ConsoleReporter::sectionEnded(SectionStats const& _sectionStats) { StreamingReporterBase::sectionEnded(_sectionStats); } -void ConsoleReporter::benchmarkPreparing( StringRef name ) { +void ConsoleReporter::benchmarkPreparing( std::string_view name ) { lazyPrintWithoutClosingBenchmarkTable(); auto nameCol = TextFlow::Column( static_cast( name ) ) @@ -506,7 +506,7 @@ void ConsoleReporter::benchmarkEnded(BenchmarkStats<> const& stats) { } } -void ConsoleReporter::benchmarkFailed( StringRef error ) { +void ConsoleReporter::benchmarkFailed( std::string_view error ) { auto guard = m_colour->guardColour( Colour::Red ).engage( m_stream ); (*m_tablePrinter) << "Benchmark failed (" << error << ')' diff --git a/src/catch2/reporters/catch_reporter_console.hpp b/src/catch2/reporters/catch_reporter_console.hpp index 86ecf432..e5ab9222 100644 --- a/src/catch2/reporters/catch_reporter_console.hpp +++ b/src/catch2/reporters/catch_reporter_console.hpp @@ -23,18 +23,18 @@ namespace Catch { ~ConsoleReporter() override; static std::string getDescription(); - void noMatchingTestCases( StringRef unmatchedSpec ) override; - void reportInvalidTestSpec( StringRef arg ) override; + void noMatchingTestCases( std::string_view unmatchedSpec ) override; + void reportInvalidTestSpec( std::string_view arg ) override; void assertionEnded(AssertionStats const& _assertionStats) override; void sectionStarting(SectionInfo const& _sectionInfo) override; void sectionEnded(SectionStats const& _sectionStats) override; - void benchmarkPreparing( StringRef name ) override; + void benchmarkPreparing( std::string_view name ) override; void benchmarkStarting(BenchmarkInfo const& info) override; void benchmarkEnded(BenchmarkStats<> const& stats) override; - void benchmarkFailed( StringRef error ) override; + void benchmarkFailed( std::string_view error ) override; void testCaseEnded(TestCaseStats const& _testCaseStats) override; void testRunEnded(TestRunStats const& _testRunStats) override; diff --git a/src/catch2/reporters/catch_reporter_cumulative_base.hpp b/src/catch2/reporters/catch_reporter_cumulative_base.hpp index 964e97b8..c3ee89ee 100644 --- a/src/catch2/reporters/catch_reporter_cumulative_base.hpp +++ b/src/catch2/reporters/catch_reporter_cumulative_base.hpp @@ -96,14 +96,14 @@ namespace Catch { {} ~CumulativeReporterBase() override; - void benchmarkPreparing( StringRef ) override {} + void benchmarkPreparing( std::string_view ) override {} void benchmarkStarting( BenchmarkInfo const& ) override {} void benchmarkEnded( BenchmarkStats<> const& benchmarkStats ) override; - void benchmarkFailed( StringRef ) override {} + void benchmarkFailed( std::string_view ) override {} - void noMatchingTestCases( StringRef ) override {} - void reportInvalidTestSpec( StringRef ) override {} - void fatalErrorEncountered( StringRef /*error*/ ) override {} + void noMatchingTestCases( std::string_view ) override {} + void reportInvalidTestSpec( std::string_view ) override {} + void fatalErrorEncountered( std::string_view /*error*/ ) override {} void testRunStarting( TestRunInfo const& ) override {} diff --git a/src/catch2/reporters/catch_reporter_event_listener.cpp b/src/catch2/reporters/catch_reporter_event_listener.cpp index e94063ba..a54eb975 100644 --- a/src/catch2/reporters/catch_reporter_event_listener.cpp +++ b/src/catch2/reporters/catch_reporter_event_listener.cpp @@ -10,12 +10,12 @@ namespace Catch { - void EventListenerBase::fatalErrorEncountered( StringRef ) {} + void EventListenerBase::fatalErrorEncountered( std::string_view ) {} - void EventListenerBase::benchmarkPreparing( StringRef ) {} + void EventListenerBase::benchmarkPreparing( std::string_view ) {} void EventListenerBase::benchmarkStarting( BenchmarkInfo const& ) {} void EventListenerBase::benchmarkEnded( BenchmarkStats<> const& ) {} - void EventListenerBase::benchmarkFailed( StringRef ) {} + void EventListenerBase::benchmarkFailed( std::string_view ) {} void EventListenerBase::assertionStarting( AssertionInfo const& ) {} @@ -26,8 +26,8 @@ namespace Catch { std::vector const& ) {} void EventListenerBase::listTests( std::vector const& ) {} void EventListenerBase::listTags( std::vector const& ) {} - void EventListenerBase::noMatchingTestCases( StringRef ) {} - void EventListenerBase::reportInvalidTestSpec( StringRef ) {} + void EventListenerBase::noMatchingTestCases( std::string_view ) {} + void EventListenerBase::reportInvalidTestSpec( std::string_view ) {} void EventListenerBase::testRunStarting( TestRunInfo const& ) {} void EventListenerBase::testCaseStarting( TestCaseInfo const& ) {} void EventListenerBase::testCasePartialStarting(TestCaseInfo const&, uint64_t) {} diff --git a/src/catch2/reporters/catch_reporter_event_listener.hpp b/src/catch2/reporters/catch_reporter_event_listener.hpp index 346263e2..aba310f8 100644 --- a/src/catch2/reporters/catch_reporter_event_listener.hpp +++ b/src/catch2/reporters/catch_reporter_event_listener.hpp @@ -23,13 +23,13 @@ namespace Catch { public: using IEventListener::IEventListener; - void reportInvalidTestSpec( StringRef unmatchedSpec ) override; - void fatalErrorEncountered( StringRef error ) override; + void reportInvalidTestSpec( std::string_view unmatchedSpec ) override; + void fatalErrorEncountered( std::string_view error ) override; - void benchmarkPreparing( StringRef name ) override; + void benchmarkPreparing( std::string_view name ) override; void benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) override; void benchmarkEnded( BenchmarkStats<> const& benchmarkStats ) override; - void benchmarkFailed( StringRef error ) override; + void benchmarkFailed( std::string_view error ) override; void assertionStarting( AssertionInfo const& assertionInfo ) override; void assertionEnded( AssertionStats const& assertionStats ) override; @@ -41,7 +41,7 @@ namespace Catch { void listTests( std::vector const& tests ) override; void listTags( std::vector const& tagInfos ) override; - void noMatchingTestCases( StringRef unmatchedSpec ) override; + void noMatchingTestCases( std::string_view unmatchedSpec ) override; void testRunStarting( TestRunInfo const& testRunInfo ) override; void testCaseStarting( TestCaseInfo const& testInfo ) override; void testCasePartialStarting( TestCaseInfo const& testInfo, diff --git a/src/catch2/reporters/catch_reporter_helpers.cpp b/src/catch2/reporters/catch_reporter_helpers.cpp index c710ac43..575d070d 100644 --- a/src/catch2/reporters/catch_reporter_helpers.cpp +++ b/src/catch2/reporters/catch_reporter_helpers.cpp @@ -213,7 +213,7 @@ namespace Catch { .width( CATCH_CONFIG_CONSOLE_WIDTH - 10 ); out << str << wrapper << '\n'; } - out << pluralise(tags.size(), "tag"_sr) << "\n\n" << std::flush; + out << pluralise(tags.size(), "tag") << "\n\n" << std::flush; } void defaultListTests(std::ostream& out, ColourImpl* streamColour, std::vector const& tests, bool isFiltered, Verbosity verbosity) { @@ -249,9 +249,9 @@ namespace Catch { } if (isFiltered) { - out << pluralise(tests.size(), "matching test case"_sr); + out << pluralise(tests.size(), "matching test case"); } else { - out << pluralise(tests.size(), "test case"_sr); + out << pluralise(tests.size(), "test case"); } out << "\n\n" << std::flush; } @@ -292,7 +292,7 @@ namespace Catch { void printSummaryRow( std::ostream& stream, ColourImpl& colour, - StringRef label, + std::string_view label, std::vector const& cols, std::size_t row ) { for ( auto const& col : cols ) { @@ -329,9 +329,9 @@ namespace Catch { stream << streamColour.guardColour( Colour::ResultSuccess ) << "All tests passed"; stream << " (" - << pluralise( totals.assertions.passed, "assertion"_sr ) + << pluralise( totals.assertions.passed, "assertion" ) << " in " - << pluralise( totals.testCases.passed, "test case"_sr ) + << pluralise( totals.testCases.passed, "test case" ) << ')' << '\n'; return; } @@ -357,8 +357,8 @@ namespace Catch { SummaryColumn( "failed as expected", Colour::ResultExpectedFailure ) .addRow( totals.testCases.failedButOk ) .addRow( totals.assertions.failedButOk ) ); - printSummaryRow( stream, streamColour, "test cases"_sr, columns, 0 ); - printSummaryRow( stream, streamColour, "assertions"_sr, columns, 1 ); + printSummaryRow( stream, streamColour, "test cases", columns, 0 ); + printSummaryRow( stream, streamColour, "assertions", columns, 1 ); } } // namespace Catch diff --git a/src/catch2/reporters/catch_reporter_json.cpp b/src/catch2/reporters/catch_reporter_json.cpp index 4328d560..5382196d 100644 --- a/src/catch2/reporters/catch_reporter_json.cpp +++ b/src/catch2/reporters/catch_reporter_json.cpp @@ -19,10 +19,10 @@ namespace Catch { void writeSourceInfo( JsonObjectWriter& writer, SourceLineInfo const& sourceInfo ) { auto source_location_writer = - writer.write( "source-location"_sr ).writeObject(); - source_location_writer.write( "filename"_sr ) + writer.write( "source-location" ).writeObject(); + source_location_writer.write( "filename" ) .write( sourceInfo.file ); - source_location_writer.write( "line"_sr ).write( sourceInfo.line ); + source_location_writer.write( "line" ).write( sourceInfo.line ); } void writeTags( JsonArrayWriter writer, std::vector const& tags ) { @@ -33,12 +33,12 @@ namespace Catch { void writeProperties( JsonArrayWriter writer, TestCaseInfo const& info ) { - if ( info.isHidden() ) { writer.write( "is-hidden"_sr ); } - if ( info.okToFail() ) { writer.write( "ok-to-fail"_sr ); } + if ( info.isHidden() ) { writer.write( "is-hidden" ); } + if ( info.okToFail() ) { writer.write( "ok-to-fail" ); } if ( info.expectedToFail() ) { - writer.write( "expected-to-fail"_sr ); + writer.write( "expected-to-fail" ); } - if ( info.throws() ) { writer.write( "throws"_sr ); } + if ( info.throws() ) { writer.write( "throws" ); } } } // namespace @@ -58,16 +58,16 @@ namespace Catch { m_writers.emplace( Writer::Object ); auto& writer = m_objectWriters.top(); - writer.write( "version"_sr ).write( 1 ); + writer.write( "version" ).write( 1 ); { - auto metadata_writer = writer.write( "metadata"_sr ).writeObject(); - metadata_writer.write( "name"_sr ).write( m_config->name() ); - metadata_writer.write( "rng-seed"_sr ).write( m_config->rngSeed() ); - metadata_writer.write( "catch2-version"_sr ) + auto metadata_writer = writer.write( "metadata" ).writeObject(); + metadata_writer.write( "name" ).write( m_config->name() ); + metadata_writer.write( "rng-seed" ).write( m_config->rngSeed() ); + metadata_writer.write( "catch2-version" ) .write( libraryVersion() ); if ( m_config->testSpec().hasFilters() ) { - metadata_writer.write( "filters"_sr ) + metadata_writer.write( "filters" ) .write( m_config->testSpec() ); } } @@ -88,7 +88,7 @@ namespace Catch { m_writers.emplace( Writer::Array ); return m_arrayWriters.top(); } - JsonArrayWriter& JsonReporter::startArray( StringRef key ) { + JsonArrayWriter& JsonReporter::startArray( std::string_view key ) { m_arrayWriters.emplace( m_objectWriters.top().write( key ).writeArray() ); m_writers.emplace( Writer::Array ); @@ -100,7 +100,7 @@ namespace Catch { m_writers.emplace( Writer::Object ); return m_objectWriters.top(); } - JsonObjectWriter& JsonReporter::startObject( StringRef key ) { + JsonObjectWriter& JsonReporter::startObject( std::string_view key ) { m_objectWriters.emplace( m_objectWriters.top().write( key ).writeObject() ); m_writers.emplace( Writer::Object ); @@ -123,7 +123,7 @@ namespace Catch { } void JsonReporter::startListing() { - if ( !m_startedListing ) { startObject( "listings"_sr ); } + if ( !m_startedListing ) { startObject( "listings" ); } m_startedListing = true; } void JsonReporter::endListing() { @@ -140,15 +140,15 @@ namespace Catch { endListing(); assert( isInside( Writer::Object ) ); - startObject( "test-run"_sr ); - startArray( "test-cases"_sr ); + startObject( "test-run" ); + startArray( "test-cases" ); } static void writeCounts( JsonObjectWriter&& writer, Counts const& counts ) { - writer.write( "passed"_sr ).write( counts.passed ); - writer.write( "failed"_sr ).write( counts.failed ); - writer.write( "fail-but-ok"_sr ).write( counts.failedButOk ); - writer.write( "skipped"_sr ).write( counts.skipped ); + writer.write( "passed" ).write( counts.passed ); + writer.write( "failed" ).write( counts.failed ); + writer.write( "fail-but-ok" ).write( counts.failedButOk ); + writer.write( "skipped" ).write( counts.skipped ); } void JsonReporter::testRunEnded(TestRunStats const& runStats) { @@ -158,10 +158,10 @@ namespace Catch { { auto totals = - m_objectWriters.top().write( "totals"_sr ).writeObject(); - writeCounts( totals.write( "assertions"_sr ).writeObject(), + m_objectWriters.top().write( "totals" ).writeObject(); + writeCounts( totals.write( "assertions" ).writeObject(), runStats.totals.assertions ); - writeCounts( totals.write( "test-cases"_sr ).writeObject(), + writeCounts( totals.write( "test-cases" ).writeObject(), runStats.totals.testCases ); } @@ -178,18 +178,18 @@ namespace Catch { // "test-info" prelude { auto testInfo = - m_objectWriters.top().write( "test-info"_sr ).writeObject(); + m_objectWriters.top().write( "test-info" ).writeObject(); // TODO: handle testName vs className!! - testInfo.write( "name"_sr ).write( tcInfo.name ); + testInfo.write( "name" ).write( tcInfo.name ); writeSourceInfo(testInfo, tcInfo.lineInfo); - writeTags( testInfo.write( "tags"_sr ).writeArray(), tcInfo.tags ); - writeProperties( testInfo.write( "properties"_sr ).writeArray(), + writeTags( testInfo.write( "tags" ).writeArray(), tcInfo.tags ); + writeProperties( testInfo.write( "properties" ).writeArray(), tcInfo ); } // Start the array for individual test runs (testCasePartial pairs) - startArray( "runs"_sr ); + startArray( "runs" ); } void JsonReporter::testCaseEnded( TestCaseStats const& tcStats ) { @@ -201,8 +201,8 @@ namespace Catch { { auto totals = - m_objectWriters.top().write( "totals"_sr ).writeObject(); - writeCounts( totals.write( "assertions"_sr ).writeObject(), + m_objectWriters.top().write( "totals" ).writeObject(); + writeCounts( totals.write( "assertions" ).writeObject(), tcStats.totals.assertions ); // We do not write the test case totals, because there will always be just one test case here. // TODO: overall "result" -> success, skip, fail here? Or in partial result? @@ -219,8 +219,8 @@ namespace Catch { void JsonReporter::testCasePartialStarting( TestCaseInfo const& /*tcInfo*/, uint64_t index ) { startObject(); - m_objectWriters.top().write( "run-idx"_sr ).write( index ); - startArray( "path"_sr ); + m_objectWriters.top().write( "run-idx" ).write( index ); + startArray( "path" ); // TODO: we want to delay most of the printing to the 'root' section // TODO: childSection key name? } @@ -232,18 +232,18 @@ namespace Catch { endArray(); if ( !tcStats.stdOut.empty() ) { m_objectWriters.top() - .write( "captured-stdout"_sr ) + .write( "captured-stdout" ) .write( tcStats.stdOut ); } if ( !tcStats.stdErr.empty() ) { m_objectWriters.top() - .write( "captured-stderr"_sr ) + .write( "captured-stderr" ) .write( tcStats.stdErr ); } { auto totals = - m_objectWriters.top().write( "totals"_sr ).writeObject(); - writeCounts( totals.write( "assertions"_sr ).writeObject(), + m_objectWriters.top().write( "totals" ).writeObject(); + writeCounts( totals.write( "assertions" ).writeObject(), tcStats.totals.assertions ); // We do not write the test case totals, because there will // always be just one test case here. @@ -261,8 +261,8 @@ namespace Catch { // We want to nest top level sections, even though it shares name // and source loc with the TEST_CASE auto& sectionObject = startObject(); - sectionObject.write( "kind"_sr ).write( "section"_sr ); - sectionObject.write( "name"_sr ).write( sectionInfo.name ); + sectionObject.write( "kind" ).write( "section" ); + sectionObject.write( "name" ).write( sectionInfo.name ); writeSourceInfo( m_objectWriters.top(), sectionInfo.lineInfo ); @@ -270,7 +270,7 @@ namespace Catch { // rather complex, but we could do it, and it would look // better for empty sections. OTOH, empty sections should // be rare. - startArray( "path"_sr ); + startArray( "path" ); } void JsonReporter::sectionEnded( SectionStats const& /*sectionStats */) { // End the subpath array @@ -293,10 +293,10 @@ namespace Catch { assert( isInside( Writer::Array ) ); auto assertionObject = m_arrayWriters.top().writeObject(); - assertionObject.write( "kind"_sr ).write( "assertion"_sr ); + assertionObject.write( "kind" ).write( "assertion" ); writeSourceInfo( assertionObject, assertionStats.assertionResult.getSourceInfo() ); - assertionObject.write( "status"_sr ) + assertionObject.write( "status" ) .write( assertionStats.assertionResult.isOk() ); // TODO: handling of result. // TODO: messages @@ -304,21 +304,21 @@ namespace Catch { } - void JsonReporter::benchmarkPreparing( StringRef name ) { (void)name; } + void JsonReporter::benchmarkPreparing( std::string_view name ) { (void)name; } void JsonReporter::benchmarkStarting( BenchmarkInfo const& ) {} void JsonReporter::benchmarkEnded( BenchmarkStats<> const& ) {} - void JsonReporter::benchmarkFailed( StringRef error ) { (void)error; } + void JsonReporter::benchmarkFailed( std::string_view error ) { (void)error; } void JsonReporter::listReporters( std::vector const& descriptions ) { startListing(); auto writer = - m_objectWriters.top().write( "reporters"_sr ).writeArray(); + m_objectWriters.top().write( "reporters" ).writeArray(); for ( auto const& desc : descriptions ) { auto desc_writer = writer.writeObject(); - desc_writer.write( "name"_sr ).write( desc.name ); - desc_writer.write( "description"_sr ).write( desc.description ); + desc_writer.write( "name" ).write( desc.name ); + desc_writer.write( "description" ).write( desc.description ); } } void JsonReporter::listListeners( @@ -326,27 +326,27 @@ namespace Catch { startListing(); auto writer = - m_objectWriters.top().write( "listeners"_sr ).writeArray(); + m_objectWriters.top().write( "listeners" ).writeArray(); for ( auto const& desc : descriptions ) { auto desc_writer = writer.writeObject(); - desc_writer.write( "name"_sr ).write( desc.name ); - desc_writer.write( "description"_sr ).write( desc.description ); + desc_writer.write( "name" ).write( desc.name ); + desc_writer.write( "description" ).write( desc.description ); } } void JsonReporter::listTests( std::vector const& tests ) { startListing(); - auto writer = m_objectWriters.top().write( "tests"_sr ).writeArray(); + auto writer = m_objectWriters.top().write( "tests" ).writeArray(); for ( auto const& test : tests ) { auto desc_writer = writer.writeObject(); auto const& info = test.getTestCaseInfo(); - desc_writer.write( "name"_sr ).write( info.name ); - desc_writer.write( "class-name"_sr ).write( info.className ); + desc_writer.write( "name" ).write( info.name ); + desc_writer.write( "class-name" ).write( info.className ); { - auto tag_writer = desc_writer.write( "tags"_sr ).writeArray(); + auto tag_writer = desc_writer.write( "tags" ).writeArray(); for ( auto const& tag : info.tags ) { tag_writer.write( tag.original ); } @@ -357,17 +357,17 @@ namespace Catch { void JsonReporter::listTags( std::vector const& tags ) { startListing(); - auto writer = m_objectWriters.top().write( "tags"_sr ).writeArray(); + auto writer = m_objectWriters.top().write( "tags" ).writeArray(); for ( auto const& tag : tags ) { auto tag_writer = writer.writeObject(); { auto aliases_writer = - tag_writer.write( "aliases"_sr ).writeArray(); + tag_writer.write( "aliases" ).writeArray(); for ( auto alias : tag.spellings ) { aliases_writer.write( alias ); } } - tag_writer.write( "count"_sr ).write( tag.count ); + tag_writer.write( "count" ).write( tag.count ); } } } // namespace Catch diff --git a/src/catch2/reporters/catch_reporter_json.hpp b/src/catch2/reporters/catch_reporter_json.hpp index b28aaf8d..1d4a6d2d 100644 --- a/src/catch2/reporters/catch_reporter_json.hpp +++ b/src/catch2/reporters/catch_reporter_json.hpp @@ -43,10 +43,10 @@ namespace Catch { //void testRunEndedCumulative() override; - void benchmarkPreparing( StringRef name ) override; + void benchmarkPreparing( std::string_view name ) override; void benchmarkStarting( BenchmarkInfo const& ) override; void benchmarkEnded( BenchmarkStats<> const& ) override; - void benchmarkFailed( StringRef error ) override; + void benchmarkFailed( std::string_view error ) override; void listReporters( std::vector const& descriptions ) override; @@ -63,10 +63,10 @@ namespace Catch { }; JsonArrayWriter& startArray(); - JsonArrayWriter& startArray( StringRef key ); + JsonArrayWriter& startArray( std::string_view key ); JsonObjectWriter& startObject(); - JsonObjectWriter& startObject( StringRef key ); + JsonObjectWriter& startObject( std::string_view key ); void endObject(); void endArray(); diff --git a/src/catch2/reporters/catch_reporter_junit.cpp b/src/catch2/reporters/catch_reporter_junit.cpp index df34f17b..1bbf29af 100644 --- a/src/catch2/reporters/catch_reporter_junit.cpp +++ b/src/catch2/reporters/catch_reporter_junit.cpp @@ -132,28 +132,28 @@ namespace Catch { XmlWriter::ScopedElement e = xml.scopedElement( "testsuite" ); TestRunStats const& stats = testRunNode.value; - xml.writeAttribute( "name"_sr, stats.runInfo.name ); - xml.writeAttribute( "errors"_sr, unexpectedExceptions ); - xml.writeAttribute( "failures"_sr, stats.totals.assertions.failed-unexpectedExceptions ); - xml.writeAttribute( "skipped"_sr, stats.totals.assertions.skipped ); - xml.writeAttribute( "tests"_sr, stats.totals.assertions.total() ); - xml.writeAttribute( "hostname"_sr, "tbd"_sr ); // !TBD + xml.writeAttribute( "name", stats.runInfo.name ); + xml.writeAttribute( "errors", unexpectedExceptions ); + xml.writeAttribute( "failures", stats.totals.assertions.failed-unexpectedExceptions ); + xml.writeAttribute( "skipped", stats.totals.assertions.skipped ); + xml.writeAttribute( "tests", stats.totals.assertions.total() ); + xml.writeAttribute( "hostname", "tbd" ); // !TBD if( m_config->showDurations() == ShowDurations::Never ) - xml.writeAttribute( "time"_sr, ""_sr ); + xml.writeAttribute( "time", "" ); else - xml.writeAttribute( "time"_sr, formatDuration( suiteTime ) ); - xml.writeAttribute( "timestamp"_sr, getCurrentTimestamp() ); + xml.writeAttribute( "time", formatDuration( suiteTime ) ); + xml.writeAttribute( "timestamp", getCurrentTimestamp() ); // Write properties { auto properties = xml.scopedElement("properties"); xml.scopedElement("property") - .writeAttribute("name"_sr, "random-seed"_sr) - .writeAttribute("value"_sr, m_config->rngSeed()); + .writeAttribute("name", "random-seed") + .writeAttribute("value", m_config->rngSeed()); if (m_config->testSpec().hasFilters()) { xml.scopedElement("property") - .writeAttribute("name"_sr, "filters"_sr) - .writeAttribute("value"_sr, m_config->testSpec()); + .writeAttribute("name", "filters") + .writeAttribute("value", m_config->testSpec()); } } @@ -204,19 +204,19 @@ namespace Catch { || !sectionNode.stdErr.empty() ) { XmlWriter::ScopedElement e = xml.scopedElement( "testcase" ); if( className.empty() ) { - xml.writeAttribute( "classname"_sr, name ); - xml.writeAttribute( "name"_sr, "root"_sr ); + xml.writeAttribute( "classname", name ); + xml.writeAttribute( "name", "root" ); } else { - xml.writeAttribute( "classname"_sr, className ); - xml.writeAttribute( "name"_sr, name ); + xml.writeAttribute( "classname", className ); + xml.writeAttribute( "name", name ); } - xml.writeAttribute( "time"_sr, formatDuration( sectionNode.stats.durationInSeconds ) ); + xml.writeAttribute( "time", formatDuration( sectionNode.stats.durationInSeconds ) ); // This is not ideal, but it should be enough to mimic gtest's // junit output. // Ideally the JUnit reporter would also handle `skipTest` // events and write those out appropriately. - xml.writeAttribute( "status"_sr, "run"_sr ); + xml.writeAttribute( "status", "run" ); if (sectionNode.stats.assertions.failedButOk) { xml.scopedElement("skipped") @@ -277,8 +277,8 @@ namespace Catch { XmlWriter::ScopedElement e = xml.scopedElement( elementName ); - xml.writeAttribute( "message"_sr, result.getExpression() ); - xml.writeAttribute( "type"_sr, result.getTestMacroName() ); + xml.writeAttribute( "message", result.getExpression() ); + xml.writeAttribute( "type", result.getTestMacroName() ); ReusableStringStream rss; if ( result.getResultType() == ResultWas::ExplicitSkip ) { diff --git a/src/catch2/reporters/catch_reporter_multi.cpp b/src/catch2/reporters/catch_reporter_multi.cpp index 6bf9bcbd..e74b1f65 100644 --- a/src/catch2/reporters/catch_reporter_multi.cpp +++ b/src/catch2/reporters/catch_reporter_multi.cpp @@ -44,25 +44,25 @@ namespace Catch { m_reporterLikes.push_back( CATCH_MOVE( reporter ) ); } - void MultiReporter::noMatchingTestCases( StringRef unmatchedSpec ) { + void MultiReporter::noMatchingTestCases( std::string_view unmatchedSpec ) { for ( auto& reporterish : m_reporterLikes ) { reporterish->noMatchingTestCases( unmatchedSpec ); } } - void MultiReporter::fatalErrorEncountered( StringRef error ) { + void MultiReporter::fatalErrorEncountered( std::string_view error ) { for ( auto& reporterish : m_reporterLikes ) { reporterish->fatalErrorEncountered( error ); } } - void MultiReporter::reportInvalidTestSpec( StringRef arg ) { + void MultiReporter::reportInvalidTestSpec( std::string_view arg ) { for ( auto& reporterish : m_reporterLikes ) { reporterish->reportInvalidTestSpec( arg ); } } - void MultiReporter::benchmarkPreparing( StringRef name ) { + void MultiReporter::benchmarkPreparing( std::string_view name ) { for (auto& reporterish : m_reporterLikes) { reporterish->benchmarkPreparing(name); } @@ -78,7 +78,7 @@ namespace Catch { } } - void MultiReporter::benchmarkFailed( StringRef error ) { + void MultiReporter::benchmarkFailed( std::string_view error ) { for (auto& reporterish : m_reporterLikes) { reporterish->benchmarkFailed(error); } diff --git a/src/catch2/reporters/catch_reporter_multi.hpp b/src/catch2/reporters/catch_reporter_multi.hpp index d206663e..6259447d 100644 --- a/src/catch2/reporters/catch_reporter_multi.hpp +++ b/src/catch2/reporters/catch_reporter_multi.hpp @@ -41,14 +41,14 @@ namespace Catch { public: // IEventListener - void noMatchingTestCases( StringRef unmatchedSpec ) override; - void fatalErrorEncountered( StringRef error ) override; - void reportInvalidTestSpec( StringRef arg ) override; + void noMatchingTestCases( std::string_view unmatchedSpec ) override; + void fatalErrorEncountered( std::string_view error ) override; + void reportInvalidTestSpec( std::string_view arg ) override; - void benchmarkPreparing( StringRef name ) override; + void benchmarkPreparing( std::string_view name ) override; void benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) override; void benchmarkEnded( BenchmarkStats<> const& benchmarkStats ) override; - void benchmarkFailed( StringRef error ) override; + void benchmarkFailed( std::string_view error ) override; void testRunStarting( TestRunInfo const& testRunInfo ) override; void testCaseStarting( TestCaseInfo const& testInfo ) override; diff --git a/src/catch2/reporters/catch_reporter_registrars.hpp b/src/catch2/reporters/catch_reporter_registrars.hpp index d971c456..9ad7cfe7 100644 --- a/src/catch2/reporters/catch_reporter_registrars.hpp +++ b/src/catch2/reporters/catch_reporter_registrars.hpp @@ -67,7 +67,7 @@ namespace Catch { class ListenerRegistrar { class TypedListenerFactory : public EventListenerFactory { - StringRef m_listenerName; + std::string_view m_listenerName; std::string getDescriptionImpl( std::true_type ) const { return T::getDescription(); @@ -78,14 +78,14 @@ namespace Catch { } public: - TypedListenerFactory( StringRef listenerName ): + TypedListenerFactory( std::string_view listenerName ): m_listenerName( listenerName ) {} IEventListenerPtr create( IConfig const* config ) const override { return Detail::make_unique( config ); } - StringRef getName() const override { + std::string_view getName() const override { return m_listenerName; } @@ -95,7 +95,7 @@ namespace Catch { }; public: - ListenerRegistrar(StringRef listenerName) { + ListenerRegistrar(std::string_view listenerName) { registerListenerImpl( Detail::make_unique(listenerName) ); } }; @@ -119,7 +119,7 @@ namespace Catch { namespace { \ const Catch::ListenerRegistrar \ INTERNAL_CATCH_UNIQUE_NAME( catch_internal_RegistrarFor )( \ - #listenerType##_catch_sr ); \ + #listenerType ); \ } \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION diff --git a/src/catch2/reporters/catch_reporter_sonarqube.cpp b/src/catch2/reporters/catch_reporter_sonarqube.cpp index 2c3eb1cd..33263734 100644 --- a/src/catch2/reporters/catch_reporter_sonarqube.cpp +++ b/src/catch2/reporters/catch_reporter_sonarqube.cpp @@ -36,11 +36,11 @@ namespace Catch { xml.writeComment( createMetadataString( *m_config ) ); xml.startElement("testExecutions"); - xml.writeAttribute("version"_sr, '1'); + xml.writeAttribute("version", '1'); } void SonarQubeReporter::writeRun( TestRunNode const& runNode ) { - std::map> testsPerFile; + std::map> testsPerFile; for ( auto const& child : runNode.children ) { testsPerFile[child->value.testInfo->lineInfo.file].push_back( @@ -52,9 +52,9 @@ namespace Catch { } } - void SonarQubeReporter::writeTestFile(StringRef filename, std::vector const& testCaseNodes) { + void SonarQubeReporter::writeTestFile(std::string_view filename, std::vector const& testCaseNodes) { XmlWriter::ScopedElement e = xml.scopedElement("file"); - xml.writeAttribute("path"_sr, filename); + xml.writeAttribute("path", filename); for (auto const& child : testCaseNodes) writeTestCase(*child); @@ -77,8 +77,8 @@ namespace Catch { || !sectionNode.stdOut.empty() || !sectionNode.stdErr.empty() ) { XmlWriter::ScopedElement e = xml.scopedElement("testCase"); - xml.writeAttribute("name"_sr, name); - xml.writeAttribute("duration"_sr, static_cast(sectionNode.stats.durationInSeconds * 1000)); + xml.writeAttribute("name", name); + xml.writeAttribute("duration", static_cast(sectionNode.stats.durationInSeconds * 1000)); writeAssertions(sectionNode, okToFail); } @@ -132,7 +132,7 @@ namespace Catch { ReusableStringStream messageRss; messageRss << result.getTestMacroName() << '(' << result.getExpression() << ')'; - xml.writeAttribute("message"_sr, messageRss.str()); + xml.writeAttribute("message", messageRss.str()); ReusableStringStream textRss; if ( result.getResultType() == ResultWas::ExplicitSkip ) { diff --git a/src/catch2/reporters/catch_reporter_sonarqube.hpp b/src/catch2/reporters/catch_reporter_sonarqube.hpp index 98803a2a..14776ea2 100644 --- a/src/catch2/reporters/catch_reporter_sonarqube.hpp +++ b/src/catch2/reporters/catch_reporter_sonarqube.hpp @@ -40,7 +40,7 @@ namespace Catch { void writeRun( TestRunNode const& runNode ); - void writeTestFile(StringRef filename, std::vector const& testCaseNodes); + void writeTestFile(std::string_view filename, std::vector const& testCaseNodes); void writeTestCase(TestCaseNode const& testCaseNode); diff --git a/src/catch2/reporters/catch_reporter_streaming_base.hpp b/src/catch2/reporters/catch_reporter_streaming_base.hpp index 5448000c..fdbfcad5 100644 --- a/src/catch2/reporters/catch_reporter_streaming_base.hpp +++ b/src/catch2/reporters/catch_reporter_streaming_base.hpp @@ -24,14 +24,14 @@ namespace Catch { {} ~StreamingReporterBase() override; - void benchmarkPreparing( StringRef ) override {} + void benchmarkPreparing( std::string_view ) override {} void benchmarkStarting( BenchmarkInfo const& ) override {} void benchmarkEnded( BenchmarkStats<> const& ) override {} - void benchmarkFailed( StringRef ) override {} + void benchmarkFailed( std::string_view ) override {} - void fatalErrorEncountered( StringRef /*error*/ ) override {} - void noMatchingTestCases( StringRef /*unmatchedSpec*/ ) override {} - void reportInvalidTestSpec( StringRef /*invalidArgument*/ ) override {} + void fatalErrorEncountered( std::string_view /*error*/ ) override {} + void noMatchingTestCases( std::string_view /*unmatchedSpec*/ ) override {} + void reportInvalidTestSpec( std::string_view /*invalidArgument*/ ) override {} void testRunStarting( TestRunInfo const& _testRunInfo ) override; @@ -61,7 +61,7 @@ namespace Catch { } protected: - TestRunInfo currentTestRunInfo{ "test run has not started yet"_sr }; + TestRunInfo currentTestRunInfo{ "test run has not started yet" }; TestCaseInfo const* currentTestCaseInfo = nullptr; //! Stack of all _active_ sections in the _current_ test case diff --git a/src/catch2/reporters/catch_reporter_tap.cpp b/src/catch2/reporters/catch_reporter_tap.cpp index d7e68bfd..75811258 100644 --- a/src/catch2/reporters/catch_reporter_tap.cpp +++ b/src/catch2/reporters/catch_reporter_tap.cpp @@ -21,8 +21,8 @@ namespace Catch { namespace { // Yes, this has to be outside the class and namespaced by naming. // Making older compiler happy is hard. - static constexpr StringRef tapFailedString = "not ok"_sr; - static constexpr StringRef tapPassedString = "ok"_sr; + static constexpr std::string_view tapFailedString = "not ok"; + static constexpr std::string_view tapPassedString = "ok"; static constexpr Colour::Code tapDimColour = Colour::FileName; class TapAssertionPrinter { @@ -66,42 +66,42 @@ namespace Catch { break; case ResultWas::ThrewException: printResultType(tapFailedString); - printIssue("unexpected exception with message:"_sr); + printIssue("unexpected exception with message:"); printMessage(); printExpressionWas(); printRemainingMessages(); break; case ResultWas::FatalErrorCondition: printResultType(tapFailedString); - printIssue("fatal error condition with message:"_sr); + printIssue("fatal error condition with message:"); printMessage(); printExpressionWas(); printRemainingMessages(); break; case ResultWas::DidntThrowException: printResultType(tapFailedString); - printIssue("expected exception, got none"_sr); + printIssue("expected exception, got none"); printExpressionWas(); printRemainingMessages(); break; case ResultWas::Info: - printResultType("info"_sr); + printResultType("info"); printMessage(); printRemainingMessages(); break; case ResultWas::Warning: - printResultType("warning"_sr); + printResultType("warning"); printMessage(); printRemainingMessages(); break; case ResultWas::ExplicitFailure: printResultType(tapFailedString); - printIssue("explicitly"_sr); + printIssue("explicitly"); printRemainingMessages(Colour::None); break; case ResultWas::ExplicitSkip: printResultType(tapPassedString); - printIssue(" # SKIP"_sr); + printIssue(" # SKIP"); printMessage(); printRemainingMessages(); break; @@ -109,19 +109,19 @@ namespace Catch { case ResultWas::Unknown: case ResultWas::FailureBit: case ResultWas::Exception: - printResultType("** internal error **"_sr); + printResultType("** internal error **"); break; } } private: - void printResultType(StringRef passOrFail) const { + void printResultType(std::string_view passOrFail) const { if (!passOrFail.empty()) { stream << passOrFail << ' ' << counter << " -"; } } - void printIssue(StringRef issue) const { + void printIssue(std::string_view issue) const { stream << ' ' << issue; } @@ -167,7 +167,7 @@ namespace Catch { const std::size_t N = static_cast(itEnd - itMessage); stream << colourImpl->guardColour( colour ) << " with " - << pluralise( N, "message"_sr ) << ':'; + << pluralise( N, "message" ) << ':'; for (; itMessage != itEnd; ) { // If this assertion is a warning ignore any INFO messages @@ -200,7 +200,7 @@ namespace Catch { << std::flush; } - void TAPReporter::noMatchingTestCases( StringRef unmatchedSpec ) { + void TAPReporter::noMatchingTestCases( std::string_view unmatchedSpec ) { m_stream << "# No test cases matched '" << unmatchedSpec << "'\n"; } diff --git a/src/catch2/reporters/catch_reporter_tap.hpp b/src/catch2/reporters/catch_reporter_tap.hpp index 4664928f..23b8d7a7 100644 --- a/src/catch2/reporters/catch_reporter_tap.hpp +++ b/src/catch2/reporters/catch_reporter_tap.hpp @@ -28,7 +28,7 @@ namespace Catch { void testRunStarting( TestRunInfo const& testInfo ) override; - void noMatchingTestCases( StringRef unmatchedSpec ) override; + void noMatchingTestCases( std::string_view unmatchedSpec ) override; void assertionEnded(AssertionStats const& _assertionStats) override; diff --git a/src/catch2/reporters/catch_reporter_teamcity.cpp b/src/catch2/reporters/catch_reporter_teamcity.cpp index 38aa55a6..e2fbee55 100644 --- a/src/catch2/reporters/catch_reporter_teamcity.cpp +++ b/src/catch2/reporters/catch_reporter_teamcity.cpp @@ -32,7 +32,7 @@ namespace Catch { .initialIndent(indent) << '\n'; } - std::string escape(StringRef str) { + std::string escape(std::string_view str) { std::string escaped = static_cast(str); replaceInPlace(escaped, "|", "||"); replaceInPlace(escaped, "'", "|'"); diff --git a/src/catch2/reporters/catch_reporter_xml.cpp b/src/catch2/reporters/catch_reporter_xml.cpp index 8b7b5a70..70613dae 100644 --- a/src/catch2/reporters/catch_reporter_xml.cpp +++ b/src/catch2/reporters/catch_reporter_xml.cpp @@ -45,8 +45,8 @@ namespace Catch { void XmlReporter::writeSourceInfo( SourceLineInfo const& sourceInfo ) { m_xml - .writeAttribute( "filename"_sr, sourceInfo.file ) - .writeAttribute( "line"_sr, sourceInfo.line ); + .writeAttribute( "filename", sourceInfo.file ) + .writeAttribute( "line", sourceInfo.line ); } void XmlReporter::testRunStarting( TestRunInfo const& testInfo ) { @@ -55,20 +55,20 @@ namespace Catch { if( !stylesheetRef.empty() ) m_xml.writeStylesheetRef( stylesheetRef ); m_xml.startElement("Catch2TestRun") - .writeAttribute("name"_sr, m_config->name()) - .writeAttribute("rng-seed"_sr, m_config->rngSeed()) - .writeAttribute("xml-format-version"_sr, 3) - .writeAttribute("catch2-version"_sr, libraryVersion()); + .writeAttribute("name", m_config->name()) + .writeAttribute("rng-seed", m_config->rngSeed()) + .writeAttribute("xml-format-version", 3) + .writeAttribute("catch2-version", libraryVersion()); if ( m_config->testSpec().hasFilters() ) { - m_xml.writeAttribute( "filters"_sr, m_config->testSpec() ); + m_xml.writeAttribute( "filters", m_config->testSpec() ); } } void XmlReporter::testCaseStarting( TestCaseInfo const& testInfo ) { StreamingReporterBase::testCaseStarting(testInfo); m_xml.startElement( "TestCase" ) - .writeAttribute( "name"_sr, trim( StringRef(testInfo.name) ) ) - .writeAttribute( "tags"_sr, testInfo.tagsAsString() ); + .writeAttribute( "name", trim( std::string_view(testInfo.name) ) ) + .writeAttribute( "tags", testInfo.tagsAsString() ); writeSourceInfo( testInfo.lineInfo ); @@ -81,7 +81,7 @@ namespace Catch { StreamingReporterBase::sectionStarting( sectionInfo ); if( m_sectionDepth++ > 0 ) { m_xml.startElement( "Section" ) - .writeAttribute( "name"_sr, trim( StringRef(sectionInfo.name) ) ); + .writeAttribute( "name", trim( std::string_view(sectionInfo.name) ) ); writeSourceInfo( sectionInfo.lineInfo ); m_xml.ensureTagClosed(); } @@ -117,8 +117,8 @@ namespace Catch { // Print the expression if there is one. if( result.hasExpression() ) { m_xml.startElement( "Expression" ) - .writeAttribute( "success"_sr, result.succeeded() ) - .writeAttribute( "type"_sr, result.getTestMacroName() ); + .writeAttribute( "success", result.succeeded() ) + .writeAttribute( "type", result.getTestMacroName() ); writeSourceInfo( result.getSourceInfo() ); @@ -174,13 +174,13 @@ namespace Catch { if ( --m_sectionDepth > 0 ) { { XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResults" ); - e.writeAttribute( "successes"_sr, sectionStats.assertions.passed ); - e.writeAttribute( "failures"_sr, sectionStats.assertions.failed ); - e.writeAttribute( "expectedFailures"_sr, sectionStats.assertions.failedButOk ); - e.writeAttribute( "skipped"_sr, sectionStats.assertions.skipped > 0 ); + e.writeAttribute( "successes", sectionStats.assertions.passed ); + e.writeAttribute( "failures", sectionStats.assertions.failed ); + e.writeAttribute( "expectedFailures", sectionStats.assertions.failedButOk ); + e.writeAttribute( "skipped", sectionStats.assertions.skipped > 0 ); if ( m_config->showDurations() == ShowDurations::Always ) - e.writeAttribute( "durationInSeconds"_sr, sectionStats.durationInSeconds ); + e.writeAttribute( "durationInSeconds", sectionStats.durationInSeconds ); } // Ends assertion tag m_xml.endElement(); @@ -190,15 +190,15 @@ namespace Catch { void XmlReporter::testCaseEnded( TestCaseStats const& testCaseStats ) { StreamingReporterBase::testCaseEnded( testCaseStats ); XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResult" ); - e.writeAttribute( "success"_sr, testCaseStats.totals.assertions.allOk() ); - e.writeAttribute( "skips"_sr, testCaseStats.totals.assertions.skipped ); + e.writeAttribute( "success", testCaseStats.totals.assertions.allOk() ); + e.writeAttribute( "skips", testCaseStats.totals.assertions.skipped ); if ( m_config->showDurations() == ShowDurations::Always ) - e.writeAttribute( "durationInSeconds"_sr, m_testCaseTimer.getElapsedSeconds() ); + e.writeAttribute( "durationInSeconds", m_testCaseTimer.getElapsedSeconds() ); if( !testCaseStats.stdOut.empty() ) - m_xml.scopedElement( "StdOut" ).writeText( trim( StringRef(testCaseStats.stdOut) ), XmlFormatting::Newline ); + m_xml.scopedElement( "StdOut" ).writeText( trim( std::string_view(testCaseStats.stdOut) ), XmlFormatting::Newline ); if( !testCaseStats.stdErr.empty() ) - m_xml.scopedElement( "StdErr" ).writeText( trim( StringRef(testCaseStats.stdErr) ), XmlFormatting::Newline ); + m_xml.scopedElement( "StdErr" ).writeText( trim( std::string_view(testCaseStats.stdErr) ), XmlFormatting::Newline ); m_xml.endElement(); } @@ -206,55 +206,55 @@ namespace Catch { void XmlReporter::testRunEnded( TestRunStats const& testRunStats ) { StreamingReporterBase::testRunEnded( testRunStats ); m_xml.scopedElement( "OverallResults" ) - .writeAttribute( "successes"_sr, testRunStats.totals.assertions.passed ) - .writeAttribute( "failures"_sr, testRunStats.totals.assertions.failed ) - .writeAttribute( "expectedFailures"_sr, testRunStats.totals.assertions.failedButOk ) - .writeAttribute( "skips"_sr, testRunStats.totals.assertions.skipped ); + .writeAttribute( "successes", testRunStats.totals.assertions.passed ) + .writeAttribute( "failures", testRunStats.totals.assertions.failed ) + .writeAttribute( "expectedFailures", testRunStats.totals.assertions.failedButOk ) + .writeAttribute( "skips", testRunStats.totals.assertions.skipped ); m_xml.scopedElement( "OverallResultsCases") - .writeAttribute( "successes"_sr, testRunStats.totals.testCases.passed ) - .writeAttribute( "failures"_sr, testRunStats.totals.testCases.failed ) - .writeAttribute( "expectedFailures"_sr, testRunStats.totals.testCases.failedButOk ) - .writeAttribute( "skips"_sr, testRunStats.totals.testCases.skipped ); + .writeAttribute( "successes", testRunStats.totals.testCases.passed ) + .writeAttribute( "failures", testRunStats.totals.testCases.failed ) + .writeAttribute( "expectedFailures", testRunStats.totals.testCases.failedButOk ) + .writeAttribute( "skips", testRunStats.totals.testCases.skipped ); m_xml.endElement(); } - void XmlReporter::benchmarkPreparing( StringRef name ) { + void XmlReporter::benchmarkPreparing( std::string_view name ) { m_xml.startElement("BenchmarkResults") - .writeAttribute("name"_sr, name); + .writeAttribute("name", name); } void XmlReporter::benchmarkStarting(BenchmarkInfo const &info) { - m_xml.writeAttribute("samples"_sr, info.samples) - .writeAttribute("resamples"_sr, info.resamples) - .writeAttribute("iterations"_sr, info.iterations) - .writeAttribute("clockResolution"_sr, info.clockResolution) - .writeAttribute("estimatedDuration"_sr, info.estimatedDuration) - .writeComment("All values in nano seconds"_sr); + m_xml.writeAttribute("samples", info.samples) + .writeAttribute("resamples", info.resamples) + .writeAttribute("iterations", info.iterations) + .writeAttribute("clockResolution", info.clockResolution) + .writeAttribute("estimatedDuration", info.estimatedDuration) + .writeComment("All values in nano seconds"); } void XmlReporter::benchmarkEnded(BenchmarkStats<> const& benchmarkStats) { m_xml.scopedElement("mean") - .writeAttribute("value"_sr, benchmarkStats.mean.point.count()) - .writeAttribute("lowerBound"_sr, benchmarkStats.mean.lower_bound.count()) - .writeAttribute("upperBound"_sr, benchmarkStats.mean.upper_bound.count()) - .writeAttribute("ci"_sr, benchmarkStats.mean.confidence_interval); + .writeAttribute("value", benchmarkStats.mean.point.count()) + .writeAttribute("lowerBound", benchmarkStats.mean.lower_bound.count()) + .writeAttribute("upperBound", benchmarkStats.mean.upper_bound.count()) + .writeAttribute("ci", benchmarkStats.mean.confidence_interval); m_xml.scopedElement("standardDeviation") - .writeAttribute("value"_sr, benchmarkStats.standardDeviation.point.count()) - .writeAttribute("lowerBound"_sr, benchmarkStats.standardDeviation.lower_bound.count()) - .writeAttribute("upperBound"_sr, benchmarkStats.standardDeviation.upper_bound.count()) - .writeAttribute("ci"_sr, benchmarkStats.standardDeviation.confidence_interval); + .writeAttribute("value", benchmarkStats.standardDeviation.point.count()) + .writeAttribute("lowerBound", benchmarkStats.standardDeviation.lower_bound.count()) + .writeAttribute("upperBound", benchmarkStats.standardDeviation.upper_bound.count()) + .writeAttribute("ci", benchmarkStats.standardDeviation.confidence_interval); m_xml.scopedElement("outliers") - .writeAttribute("variance"_sr, benchmarkStats.outlierVariance) - .writeAttribute("lowMild"_sr, benchmarkStats.outliers.low_mild) - .writeAttribute("lowSevere"_sr, benchmarkStats.outliers.low_severe) - .writeAttribute("highMild"_sr, benchmarkStats.outliers.high_mild) - .writeAttribute("highSevere"_sr, benchmarkStats.outliers.high_severe); + .writeAttribute("variance", benchmarkStats.outlierVariance) + .writeAttribute("lowMild", benchmarkStats.outliers.low_mild) + .writeAttribute("lowSevere", benchmarkStats.outliers.low_severe) + .writeAttribute("highMild", benchmarkStats.outliers.high_mild) + .writeAttribute("highSevere", benchmarkStats.outliers.high_severe); m_xml.endElement(); } - void XmlReporter::benchmarkFailed(StringRef error) { + void XmlReporter::benchmarkFailed(std::string_view error) { m_xml.scopedElement("failed"). - writeAttribute("message"_sr, error); + writeAttribute("message", error); m_xml.endElement(); } diff --git a/src/catch2/reporters/catch_reporter_xml.hpp b/src/catch2/reporters/catch_reporter_xml.hpp index 66f95a8e..349f4db6 100644 --- a/src/catch2/reporters/catch_reporter_xml.hpp +++ b/src/catch2/reporters/catch_reporter_xml.hpp @@ -43,10 +43,10 @@ namespace Catch { void testRunEnded(TestRunStats const& testRunStats) override; - void benchmarkPreparing( StringRef name ) override; + void benchmarkPreparing( std::string_view name ) override; void benchmarkStarting(BenchmarkInfo const&) override; void benchmarkEnded(BenchmarkStats<> const&) override; - void benchmarkFailed( StringRef error ) override; + void benchmarkFailed( std::string_view error ) override; void listReporters(std::vector const& descriptions) override; void listListeners(std::vector const& descriptions) override; diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel index 58c05205..9d0bb48e 100644 --- a/tests/BUILD.bazel +++ b/tests/BUILD.bazel @@ -38,7 +38,6 @@ cc_test( "SelfTest/IntrospectiveTests/Reporters.tests.cpp", "SelfTest/IntrospectiveTests/Sharding.tests.cpp", "SelfTest/IntrospectiveTests/Stream.tests.cpp", - "SelfTest/IntrospectiveTests/String.tests.cpp", "SelfTest/IntrospectiveTests/StringManip.tests.cpp", "SelfTest/IntrospectiveTests/Tag.tests.cpp", "SelfTest/IntrospectiveTests/TestCaseInfoHasher.tests.cpp", diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8f8a3755..69123819 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -92,7 +92,6 @@ set(TEST_SOURCES ${SELF_TEST_DIR}/IntrospectiveTests/TextFlow.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/Sharding.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/Stream.tests.cpp - ${SELF_TEST_DIR}/IntrospectiveTests/String.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/StringManip.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/Xml.tests.cpp ${SELF_TEST_DIR}/IntrospectiveTests/Traits.tests.cpp diff --git a/tests/SelfTest/Baselines/automake.sw.approved.txt b/tests/SelfTest/Baselines/automake.sw.approved.txt index 4a6886d6..e1fe4f5a 100644 --- a/tests/SelfTest/Baselines/automake.sw.approved.txt +++ b/tests/SelfTest/Baselines/automake.sw.approved.txt @@ -248,8 +248,6 @@ Message from section two :test-result: FAIL StartsWith string matcher :test-result: PASS Static arrays are convertible to string :test-result: PASS String matchers -:test-result: PASS StringRef -:test-result: PASS StringRef at compilation time :test-result: PASS Stringifying char arrays with statically known sizes - char :test-result: PASS Stringifying char arrays with statically known sizes - signed char :test-result: PASS Stringifying char arrays with statically known sizes - unsigned char diff --git a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt index b0d30b87..726dd769 100644 --- a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt @@ -241,8 +241,6 @@ :test-result: FAIL StartsWith string matcher :test-result: PASS Static arrays are convertible to string :test-result: PASS String matchers -:test-result: PASS StringRef -:test-result: PASS StringRef at compilation time :test-result: PASS Stringifying char arrays with statically known sizes - char :test-result: PASS Stringifying char arrays with statically known sizes - signed char :test-result: PASS Stringifying char arrays with statically known sizes - unsigned char diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt index fe41ba85..ea5bcf4c 100644 --- a/tests/SelfTest/Baselines/compact.sw.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.approved.txt @@ -562,9 +562,9 @@ Exception.tests.cpp:: failed: unexpected exception with message: 'c Exception.tests.cpp:: failed: unexpected exception with message: 'custom std exception' Approx.tests.cpp:: passed: 101.000001 != Approx(100).epsilon(0.01) for: 101.00000099999999748 != Approx( 100.0 ) Approx.tests.cpp:: passed: std::pow(10, -5) != Approx(std::pow(10, -7)) for: 0.00001 != Approx( 0.0000001 ) -ToString.tests.cpp:: passed: enumInfo->lookup(0) == "Value1" for: Value1 == "Value1" -ToString.tests.cpp:: passed: enumInfo->lookup(1) == "Value2" for: Value2 == "Value2" -ToString.tests.cpp:: passed: enumInfo->lookup(3) == "{** unexpected enum value **}" for: {** unexpected enum value **} +ToString.tests.cpp:: passed: enumInfo->lookup(0) == "Value1" for: "Value1" == "Value1" +ToString.tests.cpp:: passed: enumInfo->lookup(1) == "Value2" for: "Value2" == "Value2" +ToString.tests.cpp:: passed: enumInfo->lookup(3) == "{** unexpected enum value **}" for: "{** unexpected enum value **}" == "{** unexpected enum value **}" Skip.tests.cpp:: skipped: 'This generator is empty' @@ -1807,61 +1807,6 @@ Matchers.tests.cpp:: passed: testStringForMatching(), StartsWith( " Matchers.tests.cpp:: passed: testStringForMatching(), StartsWith( "THIS", Catch::CaseSensitive::No ) for: "this string contains 'abc' as a substring" starts with: "this" (case insensitive) Matchers.tests.cpp:: passed: testStringForMatching(), EndsWith( "substring" ) for: "this string contains 'abc' as a substring" ends with: "substring" Matchers.tests.cpp:: passed: testStringForMatching(), EndsWith( " SuBsTrInG", Catch::CaseSensitive::No ) for: "this string contains 'abc' as a substring" ends with: " substring" (case insensitive) -String.tests.cpp:: passed: empty.empty() for: true -String.tests.cpp:: passed: empty.size() == 0 for: 0 == 0 -String.tests.cpp:: passed: std::strcmp( empty.data(), "" ) == 0 for: 0 == 0 -String.tests.cpp:: passed: s.empty() == false for: false == false -String.tests.cpp:: passed: s.size() == 5 for: 5 == 5 -String.tests.cpp:: passed: std::strcmp( rawChars, "hello" ) == 0 for: 0 == 0 -String.tests.cpp:: passed: s.data() == rawChars for: "hello" == "hello" -String.tests.cpp:: passed: original == "original" -String.tests.cpp:: passed: original.data() -String.tests.cpp:: passed: original.begin() == copy.begin() for: "original string" == "original string" -String.tests.cpp:: passed: original.begin() == copy.begin() for: "original string" == "original string" -String.tests.cpp:: passed: ss.empty() == false for: false == false -String.tests.cpp:: passed: ss.size() == 5 for: 5 == 5 -String.tests.cpp:: passed: std::strncmp( ss.data(), "hello", 5 ) == 0 for: 0 == 0 -String.tests.cpp:: passed: ss == "hello" for: hello == "hello" -String.tests.cpp:: passed: ss.size() == 6 for: 6 == 6 -String.tests.cpp:: passed: std::strcmp( ss.data(), "world!" ) == 0 for: 0 == 0 -String.tests.cpp:: passed: s.data() == s2.data() for: "hello world!" == "hello world!" -String.tests.cpp:: passed: s.data() == ss.data() for: "hello world!" == "hello world!" -String.tests.cpp:: passed: s.substr(s.size() + 1, 123).empty() for: true -String.tests.cpp:: passed: std::strcmp(ss.data(), "world!") == 0 for: 0 == 0 -String.tests.cpp:: passed: s.substr(1'000'000, 1).empty() for: true -String.tests.cpp:: passed: reinterpret_cast(buffer1) != reinterpret_cast(buffer2) for: "Hello" != "Hello" -String.tests.cpp:: passed: left == right for: Hello == Hello -String.tests.cpp:: passed: left != left.substr(0, 3) for: Hello != Hel -String.tests.cpp:: passed: sr == "a standard string" for: a standard string == "a standard string" -String.tests.cpp:: passed: sr.size() == stdStr.size() for: 17 == 17 -String.tests.cpp:: passed: sr == "a standard string" for: a standard string == "a standard string" -String.tests.cpp:: passed: sr.size() == stdStr.size() for: 17 == 17 -String.tests.cpp:: passed: sr == "a standard string" for: a standard string == "a standard string" -String.tests.cpp:: passed: sr.size() == stdStr.size() for: 17 == 17 -String.tests.cpp:: passed: stdStr == "a stringref" for: "a stringref" == "a stringref" -String.tests.cpp:: passed: stdStr.size() == sr.size() for: 11 == 11 -String.tests.cpp:: passed: stdStr == "a stringref" for: "a stringref" == "a stringref" -String.tests.cpp:: passed: stdStr.size() == sr.size() for: 11 == 11 -String.tests.cpp:: passed: lhs == "some string += the stringref contents" for: "some string += the stringref contents" -== -"some string += the stringref contents" -String.tests.cpp:: passed: together == "abrakadabra" for: "abrakadabra" == "abrakadabra" -String.tests.cpp:: passed: with 1 message: 'empty.size() == 0' -String.tests.cpp:: passed: with 1 message: 'empty.begin() == empty.end()' -String.tests.cpp:: passed: with 1 message: 'stringref.size() == 3' -String.tests.cpp:: passed: with 1 message: 'stringref.data() == abc' -String.tests.cpp:: passed: with 1 message: 'stringref.begin() == abc' -String.tests.cpp:: passed: with 1 message: 'stringref.begin() != stringref.end()' -String.tests.cpp:: passed: with 1 message: 'stringref.substr(10, 0).empty()' -String.tests.cpp:: passed: with 1 message: 'stringref.substr(2, 1).data() == abc + 2' -String.tests.cpp:: passed: with 1 message: 'stringref[1] == 'b'' -String.tests.cpp:: passed: with 1 message: 'shortened.size() == 2' -String.tests.cpp:: passed: with 1 message: 'shortened.data() == abc' -String.tests.cpp:: passed: with 1 message: 'shortened.begin() != shortened.end()' -String.tests.cpp:: passed: with 1 message: '!(sr1.empty())' -String.tests.cpp:: passed: with 1 message: 'sr1.size() == 3' -String.tests.cpp:: passed: with 1 message: 'sr2.empty()' -String.tests.cpp:: passed: with 1 message: 'sr2.size() == 0' ToString.tests.cpp:: passed: ::Catch::Detail::stringify( with_null_terminator ) == R"("abc")"s for: ""abc"" == ""abc"" ToString.tests.cpp:: passed: ::Catch::Detail::stringify( no_null_terminator ) == R"("abc")"s for: ""abc"" == ""abc"" ToString.tests.cpp:: passed: ::Catch::Detail::stringify( with_null_terminator ) == R"("abc")"s for: ""abc"" == ""abc"" @@ -1902,7 +1847,7 @@ Tag.tests.cpp:: passed: registry.add( "[the @ is not at the start]" Tag.tests.cpp:: passed: registry.add( "@no square bracket at start]", "", Catch::SourceLineInfo( "file", 3 ) ) Tag.tests.cpp:: passed: registry.add( "[@no square bracket at end", "", Catch::SourceLineInfo( "file", 3 ) ) Tag.tests.cpp:: passed: testCase.tags.size() == 2 for: 2 == 2 -Tag.tests.cpp:: passed: testCase.tags, VectorContains( Tag( "tag with spaces" ) ) && VectorContains( Tag( "I said \"good day\" sir!"_catch_sr ) ) for: { {?}, {?} } ( Contains: {?} and Contains: {?} ) +Tag.tests.cpp:: passed: testCase.tags, VectorContains( Tag( "tag with spaces" ) ) && VectorContains( Tag( "I said \"good day\" sir!" ) ) for: { {?}, {?} } ( Contains: {?} and Contains: {?} ) Class.tests.cpp:: passed: Template_Fixture::m_a == 1 for: 1 == 1 Class.tests.cpp:: passed: Template_Fixture::m_a == 1 for: 1 == 1 Class.tests.cpp:: passed: Template_Fixture::m_a == 1 for: 1.0 == 1 @@ -2169,18 +2114,18 @@ StringManip.tests.cpp:: passed: trim(std::string(trailing_whitespac StringManip.tests.cpp:: passed: trim(std::string(whitespace_at_both_ends)) == no_whitespace for: "There is no extra whitespace here" == "There is no extra whitespace here" -StringManip.tests.cpp:: passed: trim(StringRef(no_whitespace)) == StringRef(no_whitespace) for: There is no extra whitespace here +StringManip.tests.cpp:: passed: trim(std::string_view(no_whitespace)) == std::string_view(no_whitespace) for: "There is no extra whitespace here" == -There is no extra whitespace here -StringManip.tests.cpp:: passed: trim(StringRef(leading_whitespace)) == StringRef(no_whitespace) for: There is no extra whitespace here +"There is no extra whitespace here" +StringManip.tests.cpp:: passed: trim(std::string_view(leading_whitespace)) == std::string_view(no_whitespace) for: "There is no extra whitespace here" == -There is no extra whitespace here -StringManip.tests.cpp:: passed: trim(StringRef(trailing_whitespace)) == StringRef(no_whitespace) for: There is no extra whitespace here +"There is no extra whitespace here" +StringManip.tests.cpp:: passed: trim(std::string_view(trailing_whitespace)) == std::string_view(no_whitespace) for: "There is no extra whitespace here" == -There is no extra whitespace here -StringManip.tests.cpp:: passed: trim(StringRef(whitespace_at_both_ends)) == StringRef(no_whitespace) for: There is no extra whitespace here +"There is no extra whitespace here" +StringManip.tests.cpp:: passed: trim(std::string_view(whitespace_at_both_ends)) == std::string_view(no_whitespace) for: "There is no extra whitespace here" == -There is no extra whitespace here +"There is no extra whitespace here" MatchersRanges.tests.cpp:: passed: array_int_a, RangeEquals( c_array ) for: { 1, 2, 3 } elements are { 1, 2, 3 } MatchersRanges.tests.cpp:: passed: array_int_a, UnorderedRangeEquals( c_array ) for: { 1, 2, 3 } unordered elements are { 1, 2, 3 } MatchersRanges.tests.cpp:: passed: array_int_3, !RangeEquals( array_int_4 ) for: { 1, 2, 3 } not elements are { 1, 2, 3, 4 } @@ -2646,13 +2591,13 @@ Tricky.tests.cpp:: passed: ptr.get() == 0 for: 0 == 0 ToStringPair.tests.cpp:: passed: ::Catch::Detail::stringify( pair ) == "{ { 42, \"Arthur\" }, { \"Ford\", 24 } }" for: "{ { 42, "Arthur" }, { "Ford", 24 } }" == "{ { 42, "Arthur" }, { "Ford", 24 } }" -ToString.tests.cpp:: passed: parseEnums( "" ), Equals( std::vector{} ) for: { } Equals: { } -ToString.tests.cpp:: passed: parseEnums( "ClassName::EnumName::Value1" ), Equals(std::vector{"Value1"} ) for: { Value1 } Equals: { Value1 } -ToString.tests.cpp:: passed: parseEnums( "Value1" ), Equals( std::vector{"Value1"} ) for: { Value1 } Equals: { Value1 } -ToString.tests.cpp:: passed: parseEnums( "EnumName::Value1" ), Equals(std::vector{"Value1"} ) for: { Value1 } Equals: { Value1 } -ToString.tests.cpp:: passed: parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2" ), Equals( std::vector{"Value1", "Value2"} ) for: { Value1, Value2 } Equals: { Value1, Value2 } -ToString.tests.cpp:: passed: parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2, ClassName::EnumName::Value3" ), Equals( std::vector{"Value1", "Value2", "Value3"} ) for: { Value1, Value2, Value3 } Equals: { Value1, Value2, Value3 } -ToString.tests.cpp:: passed: parseEnums( "ClassName::EnumName::Value1,ClassName::EnumName::Value2 , ClassName::EnumName::Value3" ), Equals( std::vector{"Value1", "Value2", "Value3"} ) for: { Value1, Value2, Value3 } Equals: { Value1, Value2, Value3 } +ToString.tests.cpp:: passed: parseEnums( "" ), Equals( std::vector{} ) for: { } Equals: { } +ToString.tests.cpp:: passed: parseEnums( "ClassName::EnumName::Value1" ), Equals(std::vector{"Value1"} ) for: { "Value1" } Equals: { "Value1" } +ToString.tests.cpp:: passed: parseEnums( "Value1" ), Equals( std::vector{"Value1"} ) for: { "Value1" } Equals: { "Value1" } +ToString.tests.cpp:: passed: parseEnums( "EnumName::Value1" ), Equals(std::vector{"Value1"} ) for: { "Value1" } Equals: { "Value1" } +ToString.tests.cpp:: passed: parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2" ), Equals( std::vector{"Value1", "Value2"} ) for: { "Value1", "Value2" } Equals: { "Value1", "Value2" } +ToString.tests.cpp:: passed: parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2, ClassName::EnumName::Value3" ), Equals( std::vector{"Value1", "Value2", "Value3"} ) for: { "Value1", "Value2", "Value3" } Equals: { "Value1", "Value2", "Value3" } +ToString.tests.cpp:: passed: parseEnums( "ClassName::EnumName::Value1,ClassName::EnumName::Value2 , ClassName::EnumName::Value3" ), Equals( std::vector{"Value1", "Value2", "Value3"} ) for: { "Value1", "Value2", "Value3" } Equals: { "Value1", "Value2", "Value3" } Tricky.tests.cpp:: passed: p == 0 for: 0 == 0 Message.tests.cpp:: passed: true with 1 message: 'this MAY be seen IF info is printed for passing assertions' Message.tests.cpp:: failed: false with 2 messages: 'this SHOULD be seen' and 'this SHOULD also be seen' @@ -2719,16 +2664,16 @@ Skip.tests.cpp:: skipped: Skip.tests.cpp:: passed: Misc.tests.cpp:: failed: false with 1 message: '3' Message.tests.cpp:: failed: false with 2 messages: 'hi' and 'i := 7' -Tag.tests.cpp:: passed: testcase.tags, VectorContains( Tag( "magic-tag" ) ) && VectorContains( Tag( "."_catch_sr ) ) for: { {?}, {?} } ( Contains: {?} and Contains: {?} ) +Tag.tests.cpp:: passed: testcase.tags, VectorContains( Tag( "magic-tag" ) ) && VectorContains( Tag( "." ) ) for: { {?}, {?} } ( Contains: {?} and Contains: {?} ) Skip.tests.cpp:: skipped: 'skipping because answer = 43' -StringManip.tests.cpp:: passed: splitStringRef("", ','), Equals(std::vector()) for: { } Equals: { } -StringManip.tests.cpp:: passed: splitStringRef("abc", ','), Equals(std::vector{"abc"}) for: { abc } Equals: { abc } -StringManip.tests.cpp:: passed: splitStringRef("abc,def", ','), Equals(std::vector{"abc", "def"}) for: { abc, def } Equals: { abc, def } +StringManip.tests.cpp:: passed: splitStringRef("", ','), Equals(std::vector()) for: { } Equals: { } +StringManip.tests.cpp:: passed: splitStringRef("abc", ','), Equals(std::vector{"abc"}) for: { "abc" } Equals: { "abc" } +StringManip.tests.cpp:: passed: splitStringRef("abc,def", ','), Equals(std::vector{"abc", "def"}) for: { "abc", "def" } Equals: { "abc", "def" } Message.tests.cpp:: failed: false with 4 messages: 'Count 1 to 3...' and '1' and '2' and '3' Message.tests.cpp:: failed: false with 4 messages: 'Count 4 to 6...' and '4' and '5' and '6' StringManip.tests.cpp:: passed: !(startsWith("", 'c')) for: !false StringManip.tests.cpp:: passed: startsWith(std::string("abc"), 'a') for: true -StringManip.tests.cpp:: passed: startsWith("def"_catch_sr, 'd') for: true +StringManip.tests.cpp:: passed: startsWith("def", 'd') for: true ToStringGeneral.tests.cpp:: passed: Catch::Detail::stringify( emptyMap ) == "{ }" for: "{ }" == "{ }" ToStringGeneral.tests.cpp:: passed: Catch::Detail::stringify( map ) == "{ { \"one\", 1 } }" for: "{ { "one", 1 } }" == "{ { "one", 1 } }" ToStringGeneral.tests.cpp:: passed: Catch::Detail::stringify( map ) == "{ { \"abc\", 1 }, { \"def\", 2 }, { \"ghi\", 3 } }" for: "{ { "abc", 1 }, { "def", 2 }, { "ghi", 3 } }" @@ -2788,7 +2733,7 @@ Generators.tests.cpp:: passed: strlen(std::get<0>(data)) == static_ Generators.tests.cpp:: passed: strlen(std::get<0>(data)) == static_cast(std::get<1>(data)) for: 5 == 5 Generators.tests.cpp:: passed: strlen(std::get<0>(data)) == static_cast(std::get<1>(data)) for: 6 == 6 Tag.tests.cpp:: passed: testcase.tags.size() == 1 for: 1 == 1 -Tag.tests.cpp:: passed: testcase.tags[0].original == "magic.tag"_catch_sr for: magic.tag == magic.tag +Tag.tests.cpp:: passed: testcase.tags[0].original == "magic.tag" for: "magic.tag" == "magic.tag" Skip.tests.cpp:: skipped: Exception.tests.cpp:: failed: unexpected exception with message: 'Why would you throw a std::string?' Misc.tests.cpp:: passed: result == "\"wide load\"" for: ""wide load"" == ""wide load"" @@ -2888,7 +2833,7 @@ InternalBenchmark.tests.cpp:: passed: med == 18. for: 18.0 == 18.0 InternalBenchmark.tests.cpp:: passed: q3 == 23. for: 23.0 == 23.0 Misc.tests.cpp:: passed: Misc.tests.cpp:: passed: -test cases: 435 | 317 passed | 95 failed | 6 skipped | 17 failed as expected -assertions: 2303 | 2105 passed | 157 failed | 41 failed as expected +test cases: 433 | 315 passed | 95 failed | 6 skipped | 17 failed as expected +assertions: 2250 | 2052 passed | 157 failed | 41 failed as expected diff --git a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt index eb8ecd60..5698d406 100644 --- a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt @@ -560,9 +560,9 @@ Exception.tests.cpp:: failed: unexpected exception with message: 'c Exception.tests.cpp:: failed: unexpected exception with message: 'custom std exception' Approx.tests.cpp:: passed: 101.000001 != Approx(100).epsilon(0.01) for: 101.00000099999999748 != Approx( 100.0 ) Approx.tests.cpp:: passed: std::pow(10, -5) != Approx(std::pow(10, -7)) for: 0.00001 != Approx( 0.0000001 ) -ToString.tests.cpp:: passed: enumInfo->lookup(0) == "Value1" for: Value1 == "Value1" -ToString.tests.cpp:: passed: enumInfo->lookup(1) == "Value2" for: Value2 == "Value2" -ToString.tests.cpp:: passed: enumInfo->lookup(3) == "{** unexpected enum value **}" for: {** unexpected enum value **} +ToString.tests.cpp:: passed: enumInfo->lookup(0) == "Value1" for: "Value1" == "Value1" +ToString.tests.cpp:: passed: enumInfo->lookup(1) == "Value2" for: "Value2" == "Value2" +ToString.tests.cpp:: passed: enumInfo->lookup(3) == "{** unexpected enum value **}" for: "{** unexpected enum value **}" == "{** unexpected enum value **}" Skip.tests.cpp:: skipped: 'This generator is empty' @@ -1800,61 +1800,6 @@ Matchers.tests.cpp:: passed: testStringForMatching(), StartsWith( " Matchers.tests.cpp:: passed: testStringForMatching(), StartsWith( "THIS", Catch::CaseSensitive::No ) for: "this string contains 'abc' as a substring" starts with: "this" (case insensitive) Matchers.tests.cpp:: passed: testStringForMatching(), EndsWith( "substring" ) for: "this string contains 'abc' as a substring" ends with: "substring" Matchers.tests.cpp:: passed: testStringForMatching(), EndsWith( " SuBsTrInG", Catch::CaseSensitive::No ) for: "this string contains 'abc' as a substring" ends with: " substring" (case insensitive) -String.tests.cpp:: passed: empty.empty() for: true -String.tests.cpp:: passed: empty.size() == 0 for: 0 == 0 -String.tests.cpp:: passed: std::strcmp( empty.data(), "" ) == 0 for: 0 == 0 -String.tests.cpp:: passed: s.empty() == false for: false == false -String.tests.cpp:: passed: s.size() == 5 for: 5 == 5 -String.tests.cpp:: passed: std::strcmp( rawChars, "hello" ) == 0 for: 0 == 0 -String.tests.cpp:: passed: s.data() == rawChars for: "hello" == "hello" -String.tests.cpp:: passed: original == "original" -String.tests.cpp:: passed: original.data() -String.tests.cpp:: passed: original.begin() == copy.begin() for: "original string" == "original string" -String.tests.cpp:: passed: original.begin() == copy.begin() for: "original string" == "original string" -String.tests.cpp:: passed: ss.empty() == false for: false == false -String.tests.cpp:: passed: ss.size() == 5 for: 5 == 5 -String.tests.cpp:: passed: std::strncmp( ss.data(), "hello", 5 ) == 0 for: 0 == 0 -String.tests.cpp:: passed: ss == "hello" for: hello == "hello" -String.tests.cpp:: passed: ss.size() == 6 for: 6 == 6 -String.tests.cpp:: passed: std::strcmp( ss.data(), "world!" ) == 0 for: 0 == 0 -String.tests.cpp:: passed: s.data() == s2.data() for: "hello world!" == "hello world!" -String.tests.cpp:: passed: s.data() == ss.data() for: "hello world!" == "hello world!" -String.tests.cpp:: passed: s.substr(s.size() + 1, 123).empty() for: true -String.tests.cpp:: passed: std::strcmp(ss.data(), "world!") == 0 for: 0 == 0 -String.tests.cpp:: passed: s.substr(1'000'000, 1).empty() for: true -String.tests.cpp:: passed: reinterpret_cast(buffer1) != reinterpret_cast(buffer2) for: "Hello" != "Hello" -String.tests.cpp:: passed: left == right for: Hello == Hello -String.tests.cpp:: passed: left != left.substr(0, 3) for: Hello != Hel -String.tests.cpp:: passed: sr == "a standard string" for: a standard string == "a standard string" -String.tests.cpp:: passed: sr.size() == stdStr.size() for: 17 == 17 -String.tests.cpp:: passed: sr == "a standard string" for: a standard string == "a standard string" -String.tests.cpp:: passed: sr.size() == stdStr.size() for: 17 == 17 -String.tests.cpp:: passed: sr == "a standard string" for: a standard string == "a standard string" -String.tests.cpp:: passed: sr.size() == stdStr.size() for: 17 == 17 -String.tests.cpp:: passed: stdStr == "a stringref" for: "a stringref" == "a stringref" -String.tests.cpp:: passed: stdStr.size() == sr.size() for: 11 == 11 -String.tests.cpp:: passed: stdStr == "a stringref" for: "a stringref" == "a stringref" -String.tests.cpp:: passed: stdStr.size() == sr.size() for: 11 == 11 -String.tests.cpp:: passed: lhs == "some string += the stringref contents" for: "some string += the stringref contents" -== -"some string += the stringref contents" -String.tests.cpp:: passed: together == "abrakadabra" for: "abrakadabra" == "abrakadabra" -String.tests.cpp:: passed: with 1 message: 'empty.size() == 0' -String.tests.cpp:: passed: with 1 message: 'empty.begin() == empty.end()' -String.tests.cpp:: passed: with 1 message: 'stringref.size() == 3' -String.tests.cpp:: passed: with 1 message: 'stringref.data() == abc' -String.tests.cpp:: passed: with 1 message: 'stringref.begin() == abc' -String.tests.cpp:: passed: with 1 message: 'stringref.begin() != stringref.end()' -String.tests.cpp:: passed: with 1 message: 'stringref.substr(10, 0).empty()' -String.tests.cpp:: passed: with 1 message: 'stringref.substr(2, 1).data() == abc + 2' -String.tests.cpp:: passed: with 1 message: 'stringref[1] == 'b'' -String.tests.cpp:: passed: with 1 message: 'shortened.size() == 2' -String.tests.cpp:: passed: with 1 message: 'shortened.data() == abc' -String.tests.cpp:: passed: with 1 message: 'shortened.begin() != shortened.end()' -String.tests.cpp:: passed: with 1 message: '!(sr1.empty())' -String.tests.cpp:: passed: with 1 message: 'sr1.size() == 3' -String.tests.cpp:: passed: with 1 message: 'sr2.empty()' -String.tests.cpp:: passed: with 1 message: 'sr2.size() == 0' ToString.tests.cpp:: passed: ::Catch::Detail::stringify( with_null_terminator ) == R"("abc")"s for: ""abc"" == ""abc"" ToString.tests.cpp:: passed: ::Catch::Detail::stringify( no_null_terminator ) == R"("abc")"s for: ""abc"" == ""abc"" ToString.tests.cpp:: passed: ::Catch::Detail::stringify( with_null_terminator ) == R"("abc")"s for: ""abc"" == ""abc"" @@ -1895,7 +1840,7 @@ Tag.tests.cpp:: passed: registry.add( "[the @ is not at the start]" Tag.tests.cpp:: passed: registry.add( "@no square bracket at start]", "", Catch::SourceLineInfo( "file", 3 ) ) Tag.tests.cpp:: passed: registry.add( "[@no square bracket at end", "", Catch::SourceLineInfo( "file", 3 ) ) Tag.tests.cpp:: passed: testCase.tags.size() == 2 for: 2 == 2 -Tag.tests.cpp:: passed: testCase.tags, VectorContains( Tag( "tag with spaces" ) ) && VectorContains( Tag( "I said \"good day\" sir!"_catch_sr ) ) for: { {?}, {?} } ( Contains: {?} and Contains: {?} ) +Tag.tests.cpp:: passed: testCase.tags, VectorContains( Tag( "tag with spaces" ) ) && VectorContains( Tag( "I said \"good day\" sir!" ) ) for: { {?}, {?} } ( Contains: {?} and Contains: {?} ) Class.tests.cpp:: passed: Template_Fixture::m_a == 1 for: 1 == 1 Class.tests.cpp:: passed: Template_Fixture::m_a == 1 for: 1 == 1 Class.tests.cpp:: passed: Template_Fixture::m_a == 1 for: 1.0 == 1 @@ -2162,18 +2107,18 @@ StringManip.tests.cpp:: passed: trim(std::string(trailing_whitespac StringManip.tests.cpp:: passed: trim(std::string(whitespace_at_both_ends)) == no_whitespace for: "There is no extra whitespace here" == "There is no extra whitespace here" -StringManip.tests.cpp:: passed: trim(StringRef(no_whitespace)) == StringRef(no_whitespace) for: There is no extra whitespace here +StringManip.tests.cpp:: passed: trim(std::string_view(no_whitespace)) == std::string_view(no_whitespace) for: "There is no extra whitespace here" == -There is no extra whitespace here -StringManip.tests.cpp:: passed: trim(StringRef(leading_whitespace)) == StringRef(no_whitespace) for: There is no extra whitespace here +"There is no extra whitespace here" +StringManip.tests.cpp:: passed: trim(std::string_view(leading_whitespace)) == std::string_view(no_whitespace) for: "There is no extra whitespace here" == -There is no extra whitespace here -StringManip.tests.cpp:: passed: trim(StringRef(trailing_whitespace)) == StringRef(no_whitespace) for: There is no extra whitespace here +"There is no extra whitespace here" +StringManip.tests.cpp:: passed: trim(std::string_view(trailing_whitespace)) == std::string_view(no_whitespace) for: "There is no extra whitespace here" == -There is no extra whitespace here -StringManip.tests.cpp:: passed: trim(StringRef(whitespace_at_both_ends)) == StringRef(no_whitespace) for: There is no extra whitespace here +"There is no extra whitespace here" +StringManip.tests.cpp:: passed: trim(std::string_view(whitespace_at_both_ends)) == std::string_view(no_whitespace) for: "There is no extra whitespace here" == -There is no extra whitespace here +"There is no extra whitespace here" MatchersRanges.tests.cpp:: passed: array_int_a, RangeEquals( c_array ) for: { 1, 2, 3 } elements are { 1, 2, 3 } MatchersRanges.tests.cpp:: passed: array_int_a, UnorderedRangeEquals( c_array ) for: { 1, 2, 3 } unordered elements are { 1, 2, 3 } MatchersRanges.tests.cpp:: passed: array_int_3, !RangeEquals( array_int_4 ) for: { 1, 2, 3 } not elements are { 1, 2, 3, 4 } @@ -2635,13 +2580,13 @@ Tricky.tests.cpp:: passed: ptr.get() == 0 for: 0 == 0 ToStringPair.tests.cpp:: passed: ::Catch::Detail::stringify( pair ) == "{ { 42, \"Arthur\" }, { \"Ford\", 24 } }" for: "{ { 42, "Arthur" }, { "Ford", 24 } }" == "{ { 42, "Arthur" }, { "Ford", 24 } }" -ToString.tests.cpp:: passed: parseEnums( "" ), Equals( std::vector{} ) for: { } Equals: { } -ToString.tests.cpp:: passed: parseEnums( "ClassName::EnumName::Value1" ), Equals(std::vector{"Value1"} ) for: { Value1 } Equals: { Value1 } -ToString.tests.cpp:: passed: parseEnums( "Value1" ), Equals( std::vector{"Value1"} ) for: { Value1 } Equals: { Value1 } -ToString.tests.cpp:: passed: parseEnums( "EnumName::Value1" ), Equals(std::vector{"Value1"} ) for: { Value1 } Equals: { Value1 } -ToString.tests.cpp:: passed: parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2" ), Equals( std::vector{"Value1", "Value2"} ) for: { Value1, Value2 } Equals: { Value1, Value2 } -ToString.tests.cpp:: passed: parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2, ClassName::EnumName::Value3" ), Equals( std::vector{"Value1", "Value2", "Value3"} ) for: { Value1, Value2, Value3 } Equals: { Value1, Value2, Value3 } -ToString.tests.cpp:: passed: parseEnums( "ClassName::EnumName::Value1,ClassName::EnumName::Value2 , ClassName::EnumName::Value3" ), Equals( std::vector{"Value1", "Value2", "Value3"} ) for: { Value1, Value2, Value3 } Equals: { Value1, Value2, Value3 } +ToString.tests.cpp:: passed: parseEnums( "" ), Equals( std::vector{} ) for: { } Equals: { } +ToString.tests.cpp:: passed: parseEnums( "ClassName::EnumName::Value1" ), Equals(std::vector{"Value1"} ) for: { "Value1" } Equals: { "Value1" } +ToString.tests.cpp:: passed: parseEnums( "Value1" ), Equals( std::vector{"Value1"} ) for: { "Value1" } Equals: { "Value1" } +ToString.tests.cpp:: passed: parseEnums( "EnumName::Value1" ), Equals(std::vector{"Value1"} ) for: { "Value1" } Equals: { "Value1" } +ToString.tests.cpp:: passed: parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2" ), Equals( std::vector{"Value1", "Value2"} ) for: { "Value1", "Value2" } Equals: { "Value1", "Value2" } +ToString.tests.cpp:: passed: parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2, ClassName::EnumName::Value3" ), Equals( std::vector{"Value1", "Value2", "Value3"} ) for: { "Value1", "Value2", "Value3" } Equals: { "Value1", "Value2", "Value3" } +ToString.tests.cpp:: passed: parseEnums( "ClassName::EnumName::Value1,ClassName::EnumName::Value2 , ClassName::EnumName::Value3" ), Equals( std::vector{"Value1", "Value2", "Value3"} ) for: { "Value1", "Value2", "Value3" } Equals: { "Value1", "Value2", "Value3" } Tricky.tests.cpp:: passed: p == 0 for: 0 == 0 Message.tests.cpp:: passed: true with 1 message: 'this MAY be seen IF info is printed for passing assertions' Message.tests.cpp:: failed: false with 2 messages: 'this SHOULD be seen' and 'this SHOULD also be seen' @@ -2708,16 +2653,16 @@ Skip.tests.cpp:: skipped: Skip.tests.cpp:: passed: Misc.tests.cpp:: failed: false with 1 message: '3' Message.tests.cpp:: failed: false with 2 messages: 'hi' and 'i := 7' -Tag.tests.cpp:: passed: testcase.tags, VectorContains( Tag( "magic-tag" ) ) && VectorContains( Tag( "."_catch_sr ) ) for: { {?}, {?} } ( Contains: {?} and Contains: {?} ) +Tag.tests.cpp:: passed: testcase.tags, VectorContains( Tag( "magic-tag" ) ) && VectorContains( Tag( "." ) ) for: { {?}, {?} } ( Contains: {?} and Contains: {?} ) Skip.tests.cpp:: skipped: 'skipping because answer = 43' -StringManip.tests.cpp:: passed: splitStringRef("", ','), Equals(std::vector()) for: { } Equals: { } -StringManip.tests.cpp:: passed: splitStringRef("abc", ','), Equals(std::vector{"abc"}) for: { abc } Equals: { abc } -StringManip.tests.cpp:: passed: splitStringRef("abc,def", ','), Equals(std::vector{"abc", "def"}) for: { abc, def } Equals: { abc, def } +StringManip.tests.cpp:: passed: splitStringRef("", ','), Equals(std::vector()) for: { } Equals: { } +StringManip.tests.cpp:: passed: splitStringRef("abc", ','), Equals(std::vector{"abc"}) for: { "abc" } Equals: { "abc" } +StringManip.tests.cpp:: passed: splitStringRef("abc,def", ','), Equals(std::vector{"abc", "def"}) for: { "abc", "def" } Equals: { "abc", "def" } Message.tests.cpp:: failed: false with 4 messages: 'Count 1 to 3...' and '1' and '2' and '3' Message.tests.cpp:: failed: false with 4 messages: 'Count 4 to 6...' and '4' and '5' and '6' StringManip.tests.cpp:: passed: !(startsWith("", 'c')) for: !false StringManip.tests.cpp:: passed: startsWith(std::string("abc"), 'a') for: true -StringManip.tests.cpp:: passed: startsWith("def"_catch_sr, 'd') for: true +StringManip.tests.cpp:: passed: startsWith("def", 'd') for: true ToStringGeneral.tests.cpp:: passed: Catch::Detail::stringify( emptyMap ) == "{ }" for: "{ }" == "{ }" ToStringGeneral.tests.cpp:: passed: Catch::Detail::stringify( map ) == "{ { \"one\", 1 } }" for: "{ { "one", 1 } }" == "{ { "one", 1 } }" ToStringGeneral.tests.cpp:: passed: Catch::Detail::stringify( map ) == "{ { \"abc\", 1 }, { \"def\", 2 }, { \"ghi\", 3 } }" for: "{ { "abc", 1 }, { "def", 2 }, { "ghi", 3 } }" @@ -2777,7 +2722,7 @@ Generators.tests.cpp:: passed: strlen(std::get<0>(data)) == static_ Generators.tests.cpp:: passed: strlen(std::get<0>(data)) == static_cast(std::get<1>(data)) for: 5 == 5 Generators.tests.cpp:: passed: strlen(std::get<0>(data)) == static_cast(std::get<1>(data)) for: 6 == 6 Tag.tests.cpp:: passed: testcase.tags.size() == 1 for: 1 == 1 -Tag.tests.cpp:: passed: testcase.tags[0].original == "magic.tag"_catch_sr for: magic.tag == magic.tag +Tag.tests.cpp:: passed: testcase.tags[0].original == "magic.tag" for: "magic.tag" == "magic.tag" Skip.tests.cpp:: skipped: Exception.tests.cpp:: failed: unexpected exception with message: 'Why would you throw a std::string?' Misc.tests.cpp:: passed: result == "\"wide load\"" for: ""wide load"" == ""wide load"" @@ -2877,7 +2822,7 @@ InternalBenchmark.tests.cpp:: passed: med == 18. for: 18.0 == 18.0 InternalBenchmark.tests.cpp:: passed: q3 == 23. for: 23.0 == 23.0 Misc.tests.cpp:: passed: Misc.tests.cpp:: passed: -test cases: 435 | 317 passed | 95 failed | 6 skipped | 17 failed as expected -assertions: 2303 | 2105 passed | 157 failed | 41 failed as expected +test cases: 433 | 315 passed | 95 failed | 6 skipped | 17 failed as expected +assertions: 2250 | 2052 passed | 157 failed | 41 failed as expected diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt index c1512db5..82c8bb5e 100644 --- a/tests/SelfTest/Baselines/console.std.approved.txt +++ b/tests/SelfTest/Baselines/console.std.approved.txt @@ -1719,6 +1719,6 @@ due to unexpected exception with message: Why would you throw a std::string? =============================================================================== -test cases: 435 | 335 passed | 76 failed | 7 skipped | 17 failed as expected -assertions: 2282 | 2105 passed | 136 failed | 41 failed as expected +test cases: 433 | 333 passed | 76 failed | 7 skipped | 17 failed as expected +assertions: 2229 | 2052 passed | 136 failed | 41 failed as expected diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt index 28e344fb..4f7459b5 100644 --- a/tests/SelfTest/Baselines/console.sw.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.approved.txt @@ -4157,17 +4157,17 @@ ToString.tests.cpp: ToString.tests.cpp:: PASSED: CHECK( enumInfo->lookup(0) == "Value1" ) with expansion: - Value1 == "Value1" + "Value1" == "Value1" ToString.tests.cpp:: PASSED: CHECK( enumInfo->lookup(1) == "Value2" ) with expansion: - Value2 == "Value2" + "Value2" == "Value2" ToString.tests.cpp:: PASSED: CHECK( enumInfo->lookup(3) == "{** unexpected enum value **}" ) with expansion: - {** unexpected enum value **} + "{** unexpected enum value **}" == "{** unexpected enum value **}" @@ -11458,419 +11458,6 @@ with expansion: "this string contains 'abc' as a substring" ends with: " substring" (case insensitive) -------------------------------------------------------------------------------- -StringRef - Empty string -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( empty.empty() ) -with expansion: - true - -String.tests.cpp:: PASSED: - REQUIRE( empty.size() == 0 ) -with expansion: - 0 == 0 - -String.tests.cpp:: PASSED: - REQUIRE( std::strcmp( empty.data(), "" ) == 0 ) -with expansion: - 0 == 0 - -------------------------------------------------------------------------------- -StringRef - From string literal -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( s.empty() == false ) -with expansion: - false == false - -String.tests.cpp:: PASSED: - REQUIRE( s.size() == 5 ) -with expansion: - 5 == 5 - -String.tests.cpp:: PASSED: - REQUIRE( std::strcmp( rawChars, "hello" ) == 0 ) -with expansion: - 0 == 0 - -String.tests.cpp:: PASSED: - REQUIRE( s.data() == rawChars ) -with expansion: - "hello" == "hello" - -------------------------------------------------------------------------------- -StringRef - From sub-string -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( original == "original" ) - -String.tests.cpp:: PASSED: - REQUIRE_NOTHROW( original.data() ) - -------------------------------------------------------------------------------- -StringRef - Copy construction is shallow -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( original.begin() == copy.begin() ) -with expansion: - "original string" == "original string" - -------------------------------------------------------------------------------- -StringRef - Copy assignment is shallow -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( original.begin() == copy.begin() ) -with expansion: - "original string" == "original string" - -------------------------------------------------------------------------------- -StringRef - Substrings - zero-based substring -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( ss.empty() == false ) -with expansion: - false == false - -String.tests.cpp:: PASSED: - REQUIRE( ss.size() == 5 ) -with expansion: - 5 == 5 - -String.tests.cpp:: PASSED: - REQUIRE( std::strncmp( ss.data(), "hello", 5 ) == 0 ) -with expansion: - 0 == 0 - -String.tests.cpp:: PASSED: - REQUIRE( ss == "hello" ) -with expansion: - hello == "hello" - -------------------------------------------------------------------------------- -StringRef - Substrings - non-zero-based substring -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( ss.size() == 6 ) -with expansion: - 6 == 6 - -String.tests.cpp:: PASSED: - REQUIRE( std::strcmp( ss.data(), "world!" ) == 0 ) -with expansion: - 0 == 0 - -------------------------------------------------------------------------------- -StringRef - Substrings - Pointer values of full refs should match -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( s.data() == s2.data() ) -with expansion: - "hello world!" == "hello world!" - -------------------------------------------------------------------------------- -StringRef - Substrings - Pointer values of substring refs should also match -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( s.data() == ss.data() ) -with expansion: - "hello world!" == "hello world!" - -------------------------------------------------------------------------------- -StringRef - Substrings - Past the end substring -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( s.substr(s.size() + 1, 123).empty() ) -with expansion: - true - -------------------------------------------------------------------------------- -StringRef - Substrings - Substring off the end are trimmed -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( std::strcmp(ss.data(), "world!") == 0 ) -with expansion: - 0 == 0 - -------------------------------------------------------------------------------- -StringRef - Substrings - substring start after the end is empty -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( s.substr(1'000'000, 1).empty() ) -with expansion: - true - -------------------------------------------------------------------------------- -StringRef - Comparisons are deep -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - CHECK( reinterpret_cast(buffer1) != reinterpret_cast(buffer2) ) -with expansion: - "Hello" != "Hello" - -String.tests.cpp:: PASSED: - REQUIRE( left == right ) -with expansion: - Hello == Hello - -String.tests.cpp:: PASSED: - REQUIRE( left != left.substr(0, 3) ) -with expansion: - Hello != Hel - -------------------------------------------------------------------------------- -StringRef - from std::string - implicitly constructed -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( sr == "a standard string" ) -with expansion: - a standard string == "a standard string" - -String.tests.cpp:: PASSED: - REQUIRE( sr.size() == stdStr.size() ) -with expansion: - 17 == 17 - -------------------------------------------------------------------------------- -StringRef - from std::string - explicitly constructed -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( sr == "a standard string" ) -with expansion: - a standard string == "a standard string" - -String.tests.cpp:: PASSED: - REQUIRE( sr.size() == stdStr.size() ) -with expansion: - 17 == 17 - -------------------------------------------------------------------------------- -StringRef - from std::string - assigned -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( sr == "a standard string" ) -with expansion: - a standard string == "a standard string" - -String.tests.cpp:: PASSED: - REQUIRE( sr.size() == stdStr.size() ) -with expansion: - 17 == 17 - -------------------------------------------------------------------------------- -StringRef - to std::string - explicitly constructed -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( stdStr == "a stringref" ) -with expansion: - "a stringref" == "a stringref" - -String.tests.cpp:: PASSED: - REQUIRE( stdStr.size() == sr.size() ) -with expansion: - 11 == 11 - -------------------------------------------------------------------------------- -StringRef - to std::string - assigned -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( stdStr == "a stringref" ) -with expansion: - "a stringref" == "a stringref" - -String.tests.cpp:: PASSED: - REQUIRE( stdStr.size() == sr.size() ) -with expansion: - 11 == 11 - -------------------------------------------------------------------------------- -StringRef - std::string += StringRef -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( lhs == "some string += the stringref contents" ) -with expansion: - "some string += the stringref contents" - == - "some string += the stringref contents" - -------------------------------------------------------------------------------- -StringRef - StringRef + StringRef -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( together == "abrakadabra" ) -with expansion: - "abrakadabra" == "abrakadabra" - -------------------------------------------------------------------------------- -StringRef at compilation time - Simple constructors -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: -with message: - empty.size() == 0 - -String.tests.cpp:: PASSED: -with message: - empty.begin() == empty.end() - -String.tests.cpp:: PASSED: -with message: - stringref.size() == 3 - -String.tests.cpp:: PASSED: -with message: - stringref.data() == abc - -String.tests.cpp:: PASSED: -with message: - stringref.begin() == abc - -String.tests.cpp:: PASSED: -with message: - stringref.begin() != stringref.end() - -String.tests.cpp:: PASSED: -with message: - stringref.substr(10, 0).empty() - -String.tests.cpp:: PASSED: -with message: - stringref.substr(2, 1).data() == abc + 2 - -String.tests.cpp:: PASSED: -with message: - stringref[1] == 'b' - -String.tests.cpp:: PASSED: -with message: - shortened.size() == 2 - -String.tests.cpp:: PASSED: -with message: - shortened.data() == abc - -String.tests.cpp:: PASSED: -with message: - shortened.begin() != shortened.end() - -------------------------------------------------------------------------------- -StringRef at compilation time - UDL construction -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: -with message: - !(sr1.empty()) - -String.tests.cpp:: PASSED: -with message: - sr1.size() == 3 - -String.tests.cpp:: PASSED: -with message: - sr2.empty() - -String.tests.cpp:: PASSED: -with message: - sr2.size() == 0 - ------------------------------------------------------------------------------- Stringifying char arrays with statically known sizes - char ------------------------------------------------------------------------------- @@ -12058,7 +11645,7 @@ with expansion: 2 == 2 Tag.tests.cpp:: PASSED: - REQUIRE_THAT( testCase.tags, VectorContains( Tag( "tag with spaces" ) ) && VectorContains( Tag( "I said \"good day\" sir!"_catch_sr ) ) ) + REQUIRE_THAT( testCase.tags, VectorContains( Tag( "tag with spaces" ) ) && VectorContains( Tag( "I said \"good day\" sir!" ) ) ) with expansion: { {?}, {?} } ( Contains: {?} and Contains: {?} ) @@ -14085,32 +13672,32 @@ with expansion: "There is no extra whitespace here" StringManip.tests.cpp:: PASSED: - REQUIRE( trim(StringRef(no_whitespace)) == StringRef(no_whitespace) ) + REQUIRE( trim(std::string_view(no_whitespace)) == std::string_view(no_whitespace) ) with expansion: - There is no extra whitespace here + "There is no extra whitespace here" == - There is no extra whitespace here + "There is no extra whitespace here" StringManip.tests.cpp:: PASSED: - REQUIRE( trim(StringRef(leading_whitespace)) == StringRef(no_whitespace) ) + REQUIRE( trim(std::string_view(leading_whitespace)) == std::string_view(no_whitespace) ) with expansion: - There is no extra whitespace here + "There is no extra whitespace here" == - There is no extra whitespace here + "There is no extra whitespace here" StringManip.tests.cpp:: PASSED: - REQUIRE( trim(StringRef(trailing_whitespace)) == StringRef(no_whitespace) ) + REQUIRE( trim(std::string_view(trailing_whitespace)) == std::string_view(no_whitespace) ) with expansion: - There is no extra whitespace here + "There is no extra whitespace here" == - There is no extra whitespace here + "There is no extra whitespace here" StringManip.tests.cpp:: PASSED: - REQUIRE( trim(StringRef(whitespace_at_both_ends)) == StringRef(no_whitespace) ) + REQUIRE( trim(std::string_view(whitespace_at_both_ends)) == std::string_view(no_whitespace) ) with expansion: - There is no extra whitespace here + "There is no extra whitespace here" == - There is no extra whitespace here + "There is no extra whitespace here" ------------------------------------------------------------------------------- Type conversions of RangeEquals and similar @@ -17569,7 +17156,7 @@ ToString.tests.cpp: ............................................................................... ToString.tests.cpp:: PASSED: - CHECK_THAT( parseEnums( "" ), Equals( std::vector{} ) ) + CHECK_THAT( parseEnums( "" ), Equals( std::vector{} ) ) with expansion: { } Equals: { } @@ -17581,19 +17168,19 @@ ToString.tests.cpp: ............................................................................... ToString.tests.cpp:: PASSED: - CHECK_THAT( parseEnums( "ClassName::EnumName::Value1" ), Equals(std::vector{"Value1"} ) ) + CHECK_THAT( parseEnums( "ClassName::EnumName::Value1" ), Equals(std::vector{"Value1"} ) ) with expansion: - { Value1 } Equals: { Value1 } + { "Value1" } Equals: { "Value1" } ToString.tests.cpp:: PASSED: - CHECK_THAT( parseEnums( "Value1" ), Equals( std::vector{"Value1"} ) ) + CHECK_THAT( parseEnums( "Value1" ), Equals( std::vector{"Value1"} ) ) with expansion: - { Value1 } Equals: { Value1 } + { "Value1" } Equals: { "Value1" } ToString.tests.cpp:: PASSED: - CHECK_THAT( parseEnums( "EnumName::Value1" ), Equals(std::vector{"Value1"} ) ) + CHECK_THAT( parseEnums( "EnumName::Value1" ), Equals(std::vector{"Value1"} ) ) with expansion: - { Value1 } Equals: { Value1 } + { "Value1" } Equals: { "Value1" } ------------------------------------------------------------------------------- parseEnums @@ -17603,19 +17190,19 @@ ToString.tests.cpp: ............................................................................... ToString.tests.cpp:: PASSED: - CHECK_THAT( parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2" ), Equals( std::vector{"Value1", "Value2"} ) ) + CHECK_THAT( parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2" ), Equals( std::vector{"Value1", "Value2"} ) ) with expansion: - { Value1, Value2 } Equals: { Value1, Value2 } + { "Value1", "Value2" } Equals: { "Value1", "Value2" } ToString.tests.cpp:: PASSED: - CHECK_THAT( parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2, ClassName::EnumName::Value3" ), Equals( std::vector{"Value1", "Value2", "Value3"} ) ) + CHECK_THAT( parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2, ClassName::EnumName::Value3" ), Equals( std::vector{"Value1", "Value2", "Value3"} ) ) with expansion: - { Value1, Value2, Value3 } Equals: { Value1, Value2, Value3 } + { "Value1", "Value2", "Value3" } Equals: { "Value1", "Value2", "Value3" } ToString.tests.cpp:: PASSED: - CHECK_THAT( parseEnums( "ClassName::EnumName::Value1,ClassName::EnumName::Value2 , ClassName::EnumName::Value3" ), Equals( std::vector{"Value1", "Value2", "Value3"} ) ) + CHECK_THAT( parseEnums( "ClassName::EnumName::Value1,ClassName::EnumName::Value2 , ClassName::EnumName::Value3" ), Equals( std::vector{"Value1", "Value2", "Value3"} ) ) with expansion: - { Value1, Value2, Value3 } Equals: { Value1, Value2, Value3 } + { "Value1", "Value2", "Value3" } Equals: { "Value1", "Value2", "Value3" } ------------------------------------------------------------------------------- pointer to class @@ -18110,7 +17697,7 @@ Tag.tests.cpp: ............................................................................... Tag.tests.cpp:: PASSED: - REQUIRE_THAT( testcase.tags, VectorContains( Tag( "magic-tag" ) ) && VectorContains( Tag( "."_catch_sr ) ) ) + REQUIRE_THAT( testcase.tags, VectorContains( Tag( "magic-tag" ) ) && VectorContains( Tag( "." ) ) ) with expansion: { {?}, {?} } ( Contains: {?} and Contains: {?} ) @@ -18131,19 +17718,19 @@ StringManip.tests.cpp: ............................................................................... StringManip.tests.cpp:: PASSED: - CHECK_THAT( splitStringRef("", ','), Equals(std::vector()) ) + CHECK_THAT( splitStringRef("", ','), Equals(std::vector()) ) with expansion: { } Equals: { } StringManip.tests.cpp:: PASSED: - CHECK_THAT( splitStringRef("abc", ','), Equals(std::vector{"abc"}) ) + CHECK_THAT( splitStringRef("abc", ','), Equals(std::vector{"abc"}) ) with expansion: - { abc } Equals: { abc } + { "abc" } Equals: { "abc" } StringManip.tests.cpp:: PASSED: - CHECK_THAT( splitStringRef("abc,def", ','), Equals(std::vector{"abc", "def"}) ) + CHECK_THAT( splitStringRef("abc,def", ','), Equals(std::vector{"abc", "def"}) ) with expansion: - { abc, def } Equals: { abc, def } + { "abc", "def" } Equals: { "abc", "def" } ------------------------------------------------------------------------------- stacks unscoped info in loops @@ -18184,7 +17771,7 @@ with expansion: true StringManip.tests.cpp:: PASSED: - CHECK( startsWith("def"_catch_sr, 'd') ) + CHECK( startsWith("def", 'd') ) with expansion: true @@ -18560,9 +18147,9 @@ with expansion: 1 == 1 Tag.tests.cpp:: PASSED: - REQUIRE( testcase.tags[0].original == "magic.tag"_catch_sr ) + REQUIRE( testcase.tags[0].original == "magic.tag" ) with expansion: - magic.tag == magic.tag + "magic.tag" == "magic.tag" ------------------------------------------------------------------------------- tests can be skipped dynamically at runtime @@ -19295,6 +18882,6 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 435 | 317 passed | 95 failed | 6 skipped | 17 failed as expected -assertions: 2303 | 2105 passed | 157 failed | 41 failed as expected +test cases: 433 | 315 passed | 95 failed | 6 skipped | 17 failed as expected +assertions: 2250 | 2052 passed | 157 failed | 41 failed as expected diff --git a/tests/SelfTest/Baselines/console.sw.multi.approved.txt b/tests/SelfTest/Baselines/console.sw.multi.approved.txt index fa4ee763..5a0d3d2d 100644 --- a/tests/SelfTest/Baselines/console.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.multi.approved.txt @@ -4155,17 +4155,17 @@ ToString.tests.cpp: ToString.tests.cpp:: PASSED: CHECK( enumInfo->lookup(0) == "Value1" ) with expansion: - Value1 == "Value1" + "Value1" == "Value1" ToString.tests.cpp:: PASSED: CHECK( enumInfo->lookup(1) == "Value2" ) with expansion: - Value2 == "Value2" + "Value2" == "Value2" ToString.tests.cpp:: PASSED: CHECK( enumInfo->lookup(3) == "{** unexpected enum value **}" ) with expansion: - {** unexpected enum value **} + "{** unexpected enum value **}" == "{** unexpected enum value **}" @@ -11451,419 +11451,6 @@ with expansion: "this string contains 'abc' as a substring" ends with: " substring" (case insensitive) -------------------------------------------------------------------------------- -StringRef - Empty string -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( empty.empty() ) -with expansion: - true - -String.tests.cpp:: PASSED: - REQUIRE( empty.size() == 0 ) -with expansion: - 0 == 0 - -String.tests.cpp:: PASSED: - REQUIRE( std::strcmp( empty.data(), "" ) == 0 ) -with expansion: - 0 == 0 - -------------------------------------------------------------------------------- -StringRef - From string literal -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( s.empty() == false ) -with expansion: - false == false - -String.tests.cpp:: PASSED: - REQUIRE( s.size() == 5 ) -with expansion: - 5 == 5 - -String.tests.cpp:: PASSED: - REQUIRE( std::strcmp( rawChars, "hello" ) == 0 ) -with expansion: - 0 == 0 - -String.tests.cpp:: PASSED: - REQUIRE( s.data() == rawChars ) -with expansion: - "hello" == "hello" - -------------------------------------------------------------------------------- -StringRef - From sub-string -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( original == "original" ) - -String.tests.cpp:: PASSED: - REQUIRE_NOTHROW( original.data() ) - -------------------------------------------------------------------------------- -StringRef - Copy construction is shallow -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( original.begin() == copy.begin() ) -with expansion: - "original string" == "original string" - -------------------------------------------------------------------------------- -StringRef - Copy assignment is shallow -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( original.begin() == copy.begin() ) -with expansion: - "original string" == "original string" - -------------------------------------------------------------------------------- -StringRef - Substrings - zero-based substring -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( ss.empty() == false ) -with expansion: - false == false - -String.tests.cpp:: PASSED: - REQUIRE( ss.size() == 5 ) -with expansion: - 5 == 5 - -String.tests.cpp:: PASSED: - REQUIRE( std::strncmp( ss.data(), "hello", 5 ) == 0 ) -with expansion: - 0 == 0 - -String.tests.cpp:: PASSED: - REQUIRE( ss == "hello" ) -with expansion: - hello == "hello" - -------------------------------------------------------------------------------- -StringRef - Substrings - non-zero-based substring -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( ss.size() == 6 ) -with expansion: - 6 == 6 - -String.tests.cpp:: PASSED: - REQUIRE( std::strcmp( ss.data(), "world!" ) == 0 ) -with expansion: - 0 == 0 - -------------------------------------------------------------------------------- -StringRef - Substrings - Pointer values of full refs should match -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( s.data() == s2.data() ) -with expansion: - "hello world!" == "hello world!" - -------------------------------------------------------------------------------- -StringRef - Substrings - Pointer values of substring refs should also match -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( s.data() == ss.data() ) -with expansion: - "hello world!" == "hello world!" - -------------------------------------------------------------------------------- -StringRef - Substrings - Past the end substring -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( s.substr(s.size() + 1, 123).empty() ) -with expansion: - true - -------------------------------------------------------------------------------- -StringRef - Substrings - Substring off the end are trimmed -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( std::strcmp(ss.data(), "world!") == 0 ) -with expansion: - 0 == 0 - -------------------------------------------------------------------------------- -StringRef - Substrings - substring start after the end is empty -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( s.substr(1'000'000, 1).empty() ) -with expansion: - true - -------------------------------------------------------------------------------- -StringRef - Comparisons are deep -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - CHECK( reinterpret_cast(buffer1) != reinterpret_cast(buffer2) ) -with expansion: - "Hello" != "Hello" - -String.tests.cpp:: PASSED: - REQUIRE( left == right ) -with expansion: - Hello == Hello - -String.tests.cpp:: PASSED: - REQUIRE( left != left.substr(0, 3) ) -with expansion: - Hello != Hel - -------------------------------------------------------------------------------- -StringRef - from std::string - implicitly constructed -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( sr == "a standard string" ) -with expansion: - a standard string == "a standard string" - -String.tests.cpp:: PASSED: - REQUIRE( sr.size() == stdStr.size() ) -with expansion: - 17 == 17 - -------------------------------------------------------------------------------- -StringRef - from std::string - explicitly constructed -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( sr == "a standard string" ) -with expansion: - a standard string == "a standard string" - -String.tests.cpp:: PASSED: - REQUIRE( sr.size() == stdStr.size() ) -with expansion: - 17 == 17 - -------------------------------------------------------------------------------- -StringRef - from std::string - assigned -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( sr == "a standard string" ) -with expansion: - a standard string == "a standard string" - -String.tests.cpp:: PASSED: - REQUIRE( sr.size() == stdStr.size() ) -with expansion: - 17 == 17 - -------------------------------------------------------------------------------- -StringRef - to std::string - explicitly constructed -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( stdStr == "a stringref" ) -with expansion: - "a stringref" == "a stringref" - -String.tests.cpp:: PASSED: - REQUIRE( stdStr.size() == sr.size() ) -with expansion: - 11 == 11 - -------------------------------------------------------------------------------- -StringRef - to std::string - assigned -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( stdStr == "a stringref" ) -with expansion: - "a stringref" == "a stringref" - -String.tests.cpp:: PASSED: - REQUIRE( stdStr.size() == sr.size() ) -with expansion: - 11 == 11 - -------------------------------------------------------------------------------- -StringRef - std::string += StringRef -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( lhs == "some string += the stringref contents" ) -with expansion: - "some string += the stringref contents" - == - "some string += the stringref contents" - -------------------------------------------------------------------------------- -StringRef - StringRef + StringRef -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: - REQUIRE( together == "abrakadabra" ) -with expansion: - "abrakadabra" == "abrakadabra" - -------------------------------------------------------------------------------- -StringRef at compilation time - Simple constructors -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: -with message: - empty.size() == 0 - -String.tests.cpp:: PASSED: -with message: - empty.begin() == empty.end() - -String.tests.cpp:: PASSED: -with message: - stringref.size() == 3 - -String.tests.cpp:: PASSED: -with message: - stringref.data() == abc - -String.tests.cpp:: PASSED: -with message: - stringref.begin() == abc - -String.tests.cpp:: PASSED: -with message: - stringref.begin() != stringref.end() - -String.tests.cpp:: PASSED: -with message: - stringref.substr(10, 0).empty() - -String.tests.cpp:: PASSED: -with message: - stringref.substr(2, 1).data() == abc + 2 - -String.tests.cpp:: PASSED: -with message: - stringref[1] == 'b' - -String.tests.cpp:: PASSED: -with message: - shortened.size() == 2 - -String.tests.cpp:: PASSED: -with message: - shortened.data() == abc - -String.tests.cpp:: PASSED: -with message: - shortened.begin() != shortened.end() - -------------------------------------------------------------------------------- -StringRef at compilation time - UDL construction -------------------------------------------------------------------------------- -String.tests.cpp: -............................................................................... - -String.tests.cpp:: PASSED: -with message: - !(sr1.empty()) - -String.tests.cpp:: PASSED: -with message: - sr1.size() == 3 - -String.tests.cpp:: PASSED: -with message: - sr2.empty() - -String.tests.cpp:: PASSED: -with message: - sr2.size() == 0 - ------------------------------------------------------------------------------- Stringifying char arrays with statically known sizes - char ------------------------------------------------------------------------------- @@ -12051,7 +11638,7 @@ with expansion: 2 == 2 Tag.tests.cpp:: PASSED: - REQUIRE_THAT( testCase.tags, VectorContains( Tag( "tag with spaces" ) ) && VectorContains( Tag( "I said \"good day\" sir!"_catch_sr ) ) ) + REQUIRE_THAT( testCase.tags, VectorContains( Tag( "tag with spaces" ) ) && VectorContains( Tag( "I said \"good day\" sir!" ) ) ) with expansion: { {?}, {?} } ( Contains: {?} and Contains: {?} ) @@ -14078,32 +13665,32 @@ with expansion: "There is no extra whitespace here" StringManip.tests.cpp:: PASSED: - REQUIRE( trim(StringRef(no_whitespace)) == StringRef(no_whitespace) ) + REQUIRE( trim(std::string_view(no_whitespace)) == std::string_view(no_whitespace) ) with expansion: - There is no extra whitespace here + "There is no extra whitespace here" == - There is no extra whitespace here + "There is no extra whitespace here" StringManip.tests.cpp:: PASSED: - REQUIRE( trim(StringRef(leading_whitespace)) == StringRef(no_whitespace) ) + REQUIRE( trim(std::string_view(leading_whitespace)) == std::string_view(no_whitespace) ) with expansion: - There is no extra whitespace here + "There is no extra whitespace here" == - There is no extra whitespace here + "There is no extra whitespace here" StringManip.tests.cpp:: PASSED: - REQUIRE( trim(StringRef(trailing_whitespace)) == StringRef(no_whitespace) ) + REQUIRE( trim(std::string_view(trailing_whitespace)) == std::string_view(no_whitespace) ) with expansion: - There is no extra whitespace here + "There is no extra whitespace here" == - There is no extra whitespace here + "There is no extra whitespace here" StringManip.tests.cpp:: PASSED: - REQUIRE( trim(StringRef(whitespace_at_both_ends)) == StringRef(no_whitespace) ) + REQUIRE( trim(std::string_view(whitespace_at_both_ends)) == std::string_view(no_whitespace) ) with expansion: - There is no extra whitespace here + "There is no extra whitespace here" == - There is no extra whitespace here + "There is no extra whitespace here" ------------------------------------------------------------------------------- Type conversions of RangeEquals and similar @@ -17558,7 +17145,7 @@ ToString.tests.cpp: ............................................................................... ToString.tests.cpp:: PASSED: - CHECK_THAT( parseEnums( "" ), Equals( std::vector{} ) ) + CHECK_THAT( parseEnums( "" ), Equals( std::vector{} ) ) with expansion: { } Equals: { } @@ -17570,19 +17157,19 @@ ToString.tests.cpp: ............................................................................... ToString.tests.cpp:: PASSED: - CHECK_THAT( parseEnums( "ClassName::EnumName::Value1" ), Equals(std::vector{"Value1"} ) ) + CHECK_THAT( parseEnums( "ClassName::EnumName::Value1" ), Equals(std::vector{"Value1"} ) ) with expansion: - { Value1 } Equals: { Value1 } + { "Value1" } Equals: { "Value1" } ToString.tests.cpp:: PASSED: - CHECK_THAT( parseEnums( "Value1" ), Equals( std::vector{"Value1"} ) ) + CHECK_THAT( parseEnums( "Value1" ), Equals( std::vector{"Value1"} ) ) with expansion: - { Value1 } Equals: { Value1 } + { "Value1" } Equals: { "Value1" } ToString.tests.cpp:: PASSED: - CHECK_THAT( parseEnums( "EnumName::Value1" ), Equals(std::vector{"Value1"} ) ) + CHECK_THAT( parseEnums( "EnumName::Value1" ), Equals(std::vector{"Value1"} ) ) with expansion: - { Value1 } Equals: { Value1 } + { "Value1" } Equals: { "Value1" } ------------------------------------------------------------------------------- parseEnums @@ -17592,19 +17179,19 @@ ToString.tests.cpp: ............................................................................... ToString.tests.cpp:: PASSED: - CHECK_THAT( parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2" ), Equals( std::vector{"Value1", "Value2"} ) ) + CHECK_THAT( parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2" ), Equals( std::vector{"Value1", "Value2"} ) ) with expansion: - { Value1, Value2 } Equals: { Value1, Value2 } + { "Value1", "Value2" } Equals: { "Value1", "Value2" } ToString.tests.cpp:: PASSED: - CHECK_THAT( parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2, ClassName::EnumName::Value3" ), Equals( std::vector{"Value1", "Value2", "Value3"} ) ) + CHECK_THAT( parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2, ClassName::EnumName::Value3" ), Equals( std::vector{"Value1", "Value2", "Value3"} ) ) with expansion: - { Value1, Value2, Value3 } Equals: { Value1, Value2, Value3 } + { "Value1", "Value2", "Value3" } Equals: { "Value1", "Value2", "Value3" } ToString.tests.cpp:: PASSED: - CHECK_THAT( parseEnums( "ClassName::EnumName::Value1,ClassName::EnumName::Value2 , ClassName::EnumName::Value3" ), Equals( std::vector{"Value1", "Value2", "Value3"} ) ) + CHECK_THAT( parseEnums( "ClassName::EnumName::Value1,ClassName::EnumName::Value2 , ClassName::EnumName::Value3" ), Equals( std::vector{"Value1", "Value2", "Value3"} ) ) with expansion: - { Value1, Value2, Value3 } Equals: { Value1, Value2, Value3 } + { "Value1", "Value2", "Value3" } Equals: { "Value1", "Value2", "Value3" } ------------------------------------------------------------------------------- pointer to class @@ -18099,7 +17686,7 @@ Tag.tests.cpp: ............................................................................... Tag.tests.cpp:: PASSED: - REQUIRE_THAT( testcase.tags, VectorContains( Tag( "magic-tag" ) ) && VectorContains( Tag( "."_catch_sr ) ) ) + REQUIRE_THAT( testcase.tags, VectorContains( Tag( "magic-tag" ) ) && VectorContains( Tag( "." ) ) ) with expansion: { {?}, {?} } ( Contains: {?} and Contains: {?} ) @@ -18120,19 +17707,19 @@ StringManip.tests.cpp: ............................................................................... StringManip.tests.cpp:: PASSED: - CHECK_THAT( splitStringRef("", ','), Equals(std::vector()) ) + CHECK_THAT( splitStringRef("", ','), Equals(std::vector()) ) with expansion: { } Equals: { } StringManip.tests.cpp:: PASSED: - CHECK_THAT( splitStringRef("abc", ','), Equals(std::vector{"abc"}) ) + CHECK_THAT( splitStringRef("abc", ','), Equals(std::vector{"abc"}) ) with expansion: - { abc } Equals: { abc } + { "abc" } Equals: { "abc" } StringManip.tests.cpp:: PASSED: - CHECK_THAT( splitStringRef("abc,def", ','), Equals(std::vector{"abc", "def"}) ) + CHECK_THAT( splitStringRef("abc,def", ','), Equals(std::vector{"abc", "def"}) ) with expansion: - { abc, def } Equals: { abc, def } + { "abc", "def" } Equals: { "abc", "def" } ------------------------------------------------------------------------------- stacks unscoped info in loops @@ -18173,7 +17760,7 @@ with expansion: true StringManip.tests.cpp:: PASSED: - CHECK( startsWith("def"_catch_sr, 'd') ) + CHECK( startsWith("def", 'd') ) with expansion: true @@ -18549,9 +18136,9 @@ with expansion: 1 == 1 Tag.tests.cpp:: PASSED: - REQUIRE( testcase.tags[0].original == "magic.tag"_catch_sr ) + REQUIRE( testcase.tags[0].original == "magic.tag" ) with expansion: - magic.tag == magic.tag + "magic.tag" == "magic.tag" ------------------------------------------------------------------------------- tests can be skipped dynamically at runtime @@ -19284,6 +18871,6 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 435 | 317 passed | 95 failed | 6 skipped | 17 failed as expected -assertions: 2303 | 2105 passed | 157 failed | 41 failed as expected +test cases: 433 | 315 passed | 95 failed | 6 skipped | 17 failed as expected +assertions: 2250 | 2052 passed | 157 failed | 41 failed as expected diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt index c12b6178..e4e23b3e 100644 --- a/tests/SelfTest/Baselines/junit.sw.approved.txt +++ b/tests/SelfTest/Baselines/junit.sw.approved.txt @@ -1,7 +1,7 @@ - + @@ -1487,33 +1487,6 @@ at Matchers.tests.cpp: - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt index e844ca6c..370dc892 100644 --- a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt @@ -1,6 +1,6 @@ - + @@ -1486,33 +1486,6 @@ at Matchers.tests.cpp: - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt index d79abd37..8001b8b8 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt @@ -312,35 +312,6 @@ at AssertionHandler.tests.cpp: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt index 98a06c14..56878756 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt @@ -311,35 +311,6 @@ at AssertionHandler.tests.cpp: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt index 28427811..086bf9f2 100644 --- a/tests/SelfTest/Baselines/tap.sw.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.approved.txt @@ -1025,11 +1025,11 @@ ok {test-number} - 101.000001 != Approx(100).epsilon(0.01) for: 101.000000999999 # Default scale is invisible to comparison ok {test-number} - std::pow(10, -5) != Approx(std::pow(10, -7)) for: 0.00001 != Approx( 0.0000001 ) # Directly creating an EnumInfo -ok {test-number} - enumInfo->lookup(0) == "Value1" for: Value1 == "Value1" +ok {test-number} - enumInfo->lookup(0) == "Value1" for: "Value1" == "Value1" # Directly creating an EnumInfo -ok {test-number} - enumInfo->lookup(1) == "Value2" for: Value2 == "Value2" +ok {test-number} - enumInfo->lookup(1) == "Value2" for: "Value2" == "Value2" # Directly creating an EnumInfo -ok {test-number} - enumInfo->lookup(3) == "{** unexpected enum value **}" for: {** unexpected enum value **} == "{** unexpected enum value **}" +ok {test-number} - enumInfo->lookup(3) == "{** unexpected enum value **}" for: "{** unexpected enum value **}" == "{** unexpected enum value **}" # Empty generators can SKIP in constructor ok {test-number} - # SKIP 'This generator is empty' # Empty stream name opens cout stream @@ -2721,112 +2721,6 @@ ok {test-number} - testStringForMatching(), StartsWith( "THIS", Catch::CaseSensi ok {test-number} - testStringForMatching(), EndsWith( "substring" ) for: "this string contains 'abc' as a substring" ends with: "substring" # String matchers ok {test-number} - testStringForMatching(), EndsWith( " SuBsTrInG", Catch::CaseSensitive::No ) for: "this string contains 'abc' as a substring" ends with: " substring" (case insensitive) -# StringRef -ok {test-number} - empty.empty() for: true -# StringRef -ok {test-number} - empty.size() == 0 for: 0 == 0 -# StringRef -ok {test-number} - std::strcmp( empty.data(), "" ) == 0 for: 0 == 0 -# StringRef -ok {test-number} - s.empty() == false for: false == false -# StringRef -ok {test-number} - s.size() == 5 for: 5 == 5 -# StringRef -ok {test-number} - std::strcmp( rawChars, "hello" ) == 0 for: 0 == 0 -# StringRef -ok {test-number} - s.data() == rawChars for: "hello" == "hello" -# StringRef -ok {test-number} - original == "original" -# StringRef -ok {test-number} - original.data() -# StringRef -ok {test-number} - original.begin() == copy.begin() for: "original string" == "original string" -# StringRef -ok {test-number} - original.begin() == copy.begin() for: "original string" == "original string" -# StringRef -ok {test-number} - ss.empty() == false for: false == false -# StringRef -ok {test-number} - ss.size() == 5 for: 5 == 5 -# StringRef -ok {test-number} - std::strncmp( ss.data(), "hello", 5 ) == 0 for: 0 == 0 -# StringRef -ok {test-number} - ss == "hello" for: hello == "hello" -# StringRef -ok {test-number} - ss.size() == 6 for: 6 == 6 -# StringRef -ok {test-number} - std::strcmp( ss.data(), "world!" ) == 0 for: 0 == 0 -# StringRef -ok {test-number} - s.data() == s2.data() for: "hello world!" == "hello world!" -# StringRef -ok {test-number} - s.data() == ss.data() for: "hello world!" == "hello world!" -# StringRef -ok {test-number} - s.substr(s.size() + 1, 123).empty() for: true -# StringRef -ok {test-number} - std::strcmp(ss.data(), "world!") == 0 for: 0 == 0 -# StringRef -ok {test-number} - s.substr(1'000'000, 1).empty() for: true -# StringRef -ok {test-number} - reinterpret_cast(buffer1) != reinterpret_cast(buffer2) for: "Hello" != "Hello" -# StringRef -ok {test-number} - left == right for: Hello == Hello -# StringRef -ok {test-number} - left != left.substr(0, 3) for: Hello != Hel -# StringRef -ok {test-number} - sr == "a standard string" for: a standard string == "a standard string" -# StringRef -ok {test-number} - sr.size() == stdStr.size() for: 17 == 17 -# StringRef -ok {test-number} - sr == "a standard string" for: a standard string == "a standard string" -# StringRef -ok {test-number} - sr.size() == stdStr.size() for: 17 == 17 -# StringRef -ok {test-number} - sr == "a standard string" for: a standard string == "a standard string" -# StringRef -ok {test-number} - sr.size() == stdStr.size() for: 17 == 17 -# StringRef -ok {test-number} - stdStr == "a stringref" for: "a stringref" == "a stringref" -# StringRef -ok {test-number} - stdStr.size() == sr.size() for: 11 == 11 -# StringRef -ok {test-number} - stdStr == "a stringref" for: "a stringref" == "a stringref" -# StringRef -ok {test-number} - stdStr.size() == sr.size() for: 11 == 11 -# StringRef -ok {test-number} - lhs == "some string += the stringref contents" for: "some string += the stringref contents" == "some string += the stringref contents" -# StringRef -ok {test-number} - together == "abrakadabra" for: "abrakadabra" == "abrakadabra" -# StringRef at compilation time -ok {test-number} - with 1 message: 'empty.size() == 0' -# StringRef at compilation time -ok {test-number} - with 1 message: 'empty.begin() == empty.end()' -# StringRef at compilation time -ok {test-number} - with 1 message: 'stringref.size() == 3' -# StringRef at compilation time -ok {test-number} - with 1 message: 'stringref.data() == abc' -# StringRef at compilation time -ok {test-number} - with 1 message: 'stringref.begin() == abc' -# StringRef at compilation time -ok {test-number} - with 1 message: 'stringref.begin() != stringref.end()' -# StringRef at compilation time -ok {test-number} - with 1 message: 'stringref.substr(10, 0).empty()' -# StringRef at compilation time -ok {test-number} - with 1 message: 'stringref.substr(2, 1).data() == abc + 2' -# StringRef at compilation time -ok {test-number} - with 1 message: 'stringref[1] == 'b'' -# StringRef at compilation time -ok {test-number} - with 1 message: 'shortened.size() == 2' -# StringRef at compilation time -ok {test-number} - with 1 message: 'shortened.data() == abc' -# StringRef at compilation time -ok {test-number} - with 1 message: 'shortened.begin() != shortened.end()' -# StringRef at compilation time -ok {test-number} - with 1 message: '!(sr1.empty())' -# StringRef at compilation time -ok {test-number} - with 1 message: 'sr1.size() == 3' -# StringRef at compilation time -ok {test-number} - with 1 message: 'sr2.empty()' -# StringRef at compilation time -ok {test-number} - with 1 message: 'sr2.size() == 0' # Stringifying char arrays with statically known sizes - char ok {test-number} - ::Catch::Detail::stringify( with_null_terminator ) == R"("abc")"s for: ""abc"" == ""abc"" # Stringifying char arrays with statically known sizes - char @@ -2874,7 +2768,7 @@ ok {test-number} - registry.add( "[@no square bracket at end", "", Catch::Source # Tags with spaces and non-alphanumerical characters are accepted ok {test-number} - testCase.tags.size() == 2 for: 2 == 2 # Tags with spaces and non-alphanumerical characters are accepted -ok {test-number} - testCase.tags, VectorContains( Tag( "tag with spaces" ) ) && VectorContains( Tag( "I said \"good day\" sir!"_catch_sr ) ) for: { {?}, {?} } ( Contains: {?} and Contains: {?} ) +ok {test-number} - testCase.tags, VectorContains( Tag( "tag with spaces" ) ) && VectorContains( Tag( "I said \"good day\" sir!" ) ) for: { {?}, {?} } ( Contains: {?} and Contains: {?} ) # Template test case method with test types specified inside std::tuple - MyTypes - 0 ok {test-number} - Template_Fixture::m_a == 1 for: 1 == 1 # Template test case method with test types specified inside std::tuple - MyTypes - 1 @@ -3362,13 +3256,13 @@ ok {test-number} - trim(std::string(trailing_whitespace)) == no_whitespace for: # Trim strings ok {test-number} - trim(std::string(whitespace_at_both_ends)) == no_whitespace for: "There is no extra whitespace here" == "There is no extra whitespace here" # Trim strings -ok {test-number} - trim(StringRef(no_whitespace)) == StringRef(no_whitespace) for: There is no extra whitespace here == There is no extra whitespace here +ok {test-number} - trim(std::string_view(no_whitespace)) == std::string_view(no_whitespace) for: "There is no extra whitespace here" == "There is no extra whitespace here" # Trim strings -ok {test-number} - trim(StringRef(leading_whitespace)) == StringRef(no_whitespace) for: There is no extra whitespace here == There is no extra whitespace here +ok {test-number} - trim(std::string_view(leading_whitespace)) == std::string_view(no_whitespace) for: "There is no extra whitespace here" == "There is no extra whitespace here" # Trim strings -ok {test-number} - trim(StringRef(trailing_whitespace)) == StringRef(no_whitespace) for: There is no extra whitespace here == There is no extra whitespace here +ok {test-number} - trim(std::string_view(trailing_whitespace)) == std::string_view(no_whitespace) for: "There is no extra whitespace here" == "There is no extra whitespace here" # Trim strings -ok {test-number} - trim(StringRef(whitespace_at_both_ends)) == StringRef(no_whitespace) for: There is no extra whitespace here == There is no extra whitespace here +ok {test-number} - trim(std::string_view(whitespace_at_both_ends)) == std::string_view(no_whitespace) for: "There is no extra whitespace here" == "There is no extra whitespace here" # Type conversions of RangeEquals and similar ok {test-number} - array_int_a, RangeEquals( c_array ) for: { 1, 2, 3 } elements are { 1, 2, 3 } # Type conversions of RangeEquals and similar @@ -4216,19 +4110,19 @@ ok {test-number} - ptr.get() == 0 for: 0 == 0 # pair > -> toString ok {test-number} - ::Catch::Detail::stringify( pair ) == "{ { 42, \"Arthur\" }, { \"Ford\", 24 } }" for: "{ { 42, "Arthur" }, { "Ford", 24 } }" == "{ { 42, "Arthur" }, { "Ford", 24 } }" # parseEnums -ok {test-number} - parseEnums( "" ), Equals( std::vector{} ) for: { } Equals: { } +ok {test-number} - parseEnums( "" ), Equals( std::vector{} ) for: { } Equals: { } # parseEnums -ok {test-number} - parseEnums( "ClassName::EnumName::Value1" ), Equals(std::vector{"Value1"} ) for: { Value1 } Equals: { Value1 } +ok {test-number} - parseEnums( "ClassName::EnumName::Value1" ), Equals(std::vector{"Value1"} ) for: { "Value1" } Equals: { "Value1" } # parseEnums -ok {test-number} - parseEnums( "Value1" ), Equals( std::vector{"Value1"} ) for: { Value1 } Equals: { Value1 } +ok {test-number} - parseEnums( "Value1" ), Equals( std::vector{"Value1"} ) for: { "Value1" } Equals: { "Value1" } # parseEnums -ok {test-number} - parseEnums( "EnumName::Value1" ), Equals(std::vector{"Value1"} ) for: { Value1 } Equals: { Value1 } +ok {test-number} - parseEnums( "EnumName::Value1" ), Equals(std::vector{"Value1"} ) for: { "Value1" } Equals: { "Value1" } # parseEnums -ok {test-number} - parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2" ), Equals( std::vector{"Value1", "Value2"} ) for: { Value1, Value2 } Equals: { Value1, Value2 } +ok {test-number} - parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2" ), Equals( std::vector{"Value1", "Value2"} ) for: { "Value1", "Value2" } Equals: { "Value1", "Value2" } # parseEnums -ok {test-number} - parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2, ClassName::EnumName::Value3" ), Equals( std::vector{"Value1", "Value2", "Value3"} ) for: { Value1, Value2, Value3 } Equals: { Value1, Value2, Value3 } +ok {test-number} - parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2, ClassName::EnumName::Value3" ), Equals( std::vector{"Value1", "Value2", "Value3"} ) for: { "Value1", "Value2", "Value3" } Equals: { "Value1", "Value2", "Value3" } # parseEnums -ok {test-number} - parseEnums( "ClassName::EnumName::Value1,ClassName::EnumName::Value2 , ClassName::EnumName::Value3" ), Equals( std::vector{"Value1", "Value2", "Value3"} ) for: { Value1, Value2, Value3 } Equals: { Value1, Value2, Value3 } +ok {test-number} - parseEnums( "ClassName::EnumName::Value1,ClassName::EnumName::Value2 , ClassName::EnumName::Value3" ), Equals( std::vector{"Value1", "Value2", "Value3"} ) for: { "Value1", "Value2", "Value3" } Equals: { "Value1", "Value2", "Value3" } # pointer to class ok {test-number} - p == 0 for: 0 == 0 # print unscoped info if passing unscoped info is printed @@ -4362,15 +4256,15 @@ not ok {test-number} - false with 1 message: '3' # sends information to INFO not ok {test-number} - false with 2 messages: 'hi' and 'i := 7' # shortened hide tags are split apart -ok {test-number} - testcase.tags, VectorContains( Tag( "magic-tag" ) ) && VectorContains( Tag( "."_catch_sr ) ) for: { {?}, {?} } ( Contains: {?} and Contains: {?} ) +ok {test-number} - testcase.tags, VectorContains( Tag( "magic-tag" ) ) && VectorContains( Tag( "." ) ) for: { {?}, {?} } ( Contains: {?} and Contains: {?} ) # skipped tests can optionally provide a reason ok {test-number} - # SKIP 'skipping because answer = 43' # splitString -ok {test-number} - splitStringRef("", ','), Equals(std::vector()) for: { } Equals: { } +ok {test-number} - splitStringRef("", ','), Equals(std::vector()) for: { } Equals: { } # splitString -ok {test-number} - splitStringRef("abc", ','), Equals(std::vector{"abc"}) for: { abc } Equals: { abc } +ok {test-number} - splitStringRef("abc", ','), Equals(std::vector{"abc"}) for: { "abc" } Equals: { "abc" } # splitString -ok {test-number} - splitStringRef("abc,def", ','), Equals(std::vector{"abc", "def"}) for: { abc, def } Equals: { abc, def } +ok {test-number} - splitStringRef("abc,def", ','), Equals(std::vector{"abc", "def"}) for: { "abc", "def" } Equals: { "abc", "def" } # stacks unscoped info in loops not ok {test-number} - false with 4 messages: 'Count 1 to 3...' and '1' and '2' and '3' # stacks unscoped info in loops @@ -4380,7 +4274,7 @@ ok {test-number} - !(startsWith("", 'c')) for: !false # startsWith ok {test-number} - startsWith(std::string("abc"), 'a') for: true # startsWith -ok {test-number} - startsWith("def"_catch_sr, 'd') for: true +ok {test-number} - startsWith("def", 'd') for: true # std::map is convertible string ok {test-number} - Catch::Detail::stringify( emptyMap ) == "{ }" for: "{ }" == "{ }" # std::map is convertible string @@ -4448,7 +4342,7 @@ ok {test-number} - strlen(std::get<0>(data)) == static_cast(std::get<1>( # tags with dots in later positions are not parsed as hidden ok {test-number} - testcase.tags.size() == 1 for: 1 == 1 # tags with dots in later positions are not parsed as hidden -ok {test-number} - testcase.tags[0].original == "magic.tag"_catch_sr for: magic.tag == magic.tag +ok {test-number} - testcase.tags[0].original == "magic.tag" for: "magic.tag" == "magic.tag" # tests can be skipped dynamically at runtime ok {test-number} - # SKIP # thrown std::strings are translated @@ -4627,5 +4521,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0 ok {test-number} - # xmlentitycheck ok {test-number} - -1..2315 +1..2262 diff --git a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt index 811a516f..94834701 100644 --- a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt @@ -1023,11 +1023,11 @@ ok {test-number} - 101.000001 != Approx(100).epsilon(0.01) for: 101.000000999999 # Default scale is invisible to comparison ok {test-number} - std::pow(10, -5) != Approx(std::pow(10, -7)) for: 0.00001 != Approx( 0.0000001 ) # Directly creating an EnumInfo -ok {test-number} - enumInfo->lookup(0) == "Value1" for: Value1 == "Value1" +ok {test-number} - enumInfo->lookup(0) == "Value1" for: "Value1" == "Value1" # Directly creating an EnumInfo -ok {test-number} - enumInfo->lookup(1) == "Value2" for: Value2 == "Value2" +ok {test-number} - enumInfo->lookup(1) == "Value2" for: "Value2" == "Value2" # Directly creating an EnumInfo -ok {test-number} - enumInfo->lookup(3) == "{** unexpected enum value **}" for: {** unexpected enum value **} == "{** unexpected enum value **}" +ok {test-number} - enumInfo->lookup(3) == "{** unexpected enum value **}" for: "{** unexpected enum value **}" == "{** unexpected enum value **}" # Empty generators can SKIP in constructor ok {test-number} - # SKIP 'This generator is empty' # Empty stream name opens cout stream @@ -2714,112 +2714,6 @@ ok {test-number} - testStringForMatching(), StartsWith( "THIS", Catch::CaseSensi ok {test-number} - testStringForMatching(), EndsWith( "substring" ) for: "this string contains 'abc' as a substring" ends with: "substring" # String matchers ok {test-number} - testStringForMatching(), EndsWith( " SuBsTrInG", Catch::CaseSensitive::No ) for: "this string contains 'abc' as a substring" ends with: " substring" (case insensitive) -# StringRef -ok {test-number} - empty.empty() for: true -# StringRef -ok {test-number} - empty.size() == 0 for: 0 == 0 -# StringRef -ok {test-number} - std::strcmp( empty.data(), "" ) == 0 for: 0 == 0 -# StringRef -ok {test-number} - s.empty() == false for: false == false -# StringRef -ok {test-number} - s.size() == 5 for: 5 == 5 -# StringRef -ok {test-number} - std::strcmp( rawChars, "hello" ) == 0 for: 0 == 0 -# StringRef -ok {test-number} - s.data() == rawChars for: "hello" == "hello" -# StringRef -ok {test-number} - original == "original" -# StringRef -ok {test-number} - original.data() -# StringRef -ok {test-number} - original.begin() == copy.begin() for: "original string" == "original string" -# StringRef -ok {test-number} - original.begin() == copy.begin() for: "original string" == "original string" -# StringRef -ok {test-number} - ss.empty() == false for: false == false -# StringRef -ok {test-number} - ss.size() == 5 for: 5 == 5 -# StringRef -ok {test-number} - std::strncmp( ss.data(), "hello", 5 ) == 0 for: 0 == 0 -# StringRef -ok {test-number} - ss == "hello" for: hello == "hello" -# StringRef -ok {test-number} - ss.size() == 6 for: 6 == 6 -# StringRef -ok {test-number} - std::strcmp( ss.data(), "world!" ) == 0 for: 0 == 0 -# StringRef -ok {test-number} - s.data() == s2.data() for: "hello world!" == "hello world!" -# StringRef -ok {test-number} - s.data() == ss.data() for: "hello world!" == "hello world!" -# StringRef -ok {test-number} - s.substr(s.size() + 1, 123).empty() for: true -# StringRef -ok {test-number} - std::strcmp(ss.data(), "world!") == 0 for: 0 == 0 -# StringRef -ok {test-number} - s.substr(1'000'000, 1).empty() for: true -# StringRef -ok {test-number} - reinterpret_cast(buffer1) != reinterpret_cast(buffer2) for: "Hello" != "Hello" -# StringRef -ok {test-number} - left == right for: Hello == Hello -# StringRef -ok {test-number} - left != left.substr(0, 3) for: Hello != Hel -# StringRef -ok {test-number} - sr == "a standard string" for: a standard string == "a standard string" -# StringRef -ok {test-number} - sr.size() == stdStr.size() for: 17 == 17 -# StringRef -ok {test-number} - sr == "a standard string" for: a standard string == "a standard string" -# StringRef -ok {test-number} - sr.size() == stdStr.size() for: 17 == 17 -# StringRef -ok {test-number} - sr == "a standard string" for: a standard string == "a standard string" -# StringRef -ok {test-number} - sr.size() == stdStr.size() for: 17 == 17 -# StringRef -ok {test-number} - stdStr == "a stringref" for: "a stringref" == "a stringref" -# StringRef -ok {test-number} - stdStr.size() == sr.size() for: 11 == 11 -# StringRef -ok {test-number} - stdStr == "a stringref" for: "a stringref" == "a stringref" -# StringRef -ok {test-number} - stdStr.size() == sr.size() for: 11 == 11 -# StringRef -ok {test-number} - lhs == "some string += the stringref contents" for: "some string += the stringref contents" == "some string += the stringref contents" -# StringRef -ok {test-number} - together == "abrakadabra" for: "abrakadabra" == "abrakadabra" -# StringRef at compilation time -ok {test-number} - with 1 message: 'empty.size() == 0' -# StringRef at compilation time -ok {test-number} - with 1 message: 'empty.begin() == empty.end()' -# StringRef at compilation time -ok {test-number} - with 1 message: 'stringref.size() == 3' -# StringRef at compilation time -ok {test-number} - with 1 message: 'stringref.data() == abc' -# StringRef at compilation time -ok {test-number} - with 1 message: 'stringref.begin() == abc' -# StringRef at compilation time -ok {test-number} - with 1 message: 'stringref.begin() != stringref.end()' -# StringRef at compilation time -ok {test-number} - with 1 message: 'stringref.substr(10, 0).empty()' -# StringRef at compilation time -ok {test-number} - with 1 message: 'stringref.substr(2, 1).data() == abc + 2' -# StringRef at compilation time -ok {test-number} - with 1 message: 'stringref[1] == 'b'' -# StringRef at compilation time -ok {test-number} - with 1 message: 'shortened.size() == 2' -# StringRef at compilation time -ok {test-number} - with 1 message: 'shortened.data() == abc' -# StringRef at compilation time -ok {test-number} - with 1 message: 'shortened.begin() != shortened.end()' -# StringRef at compilation time -ok {test-number} - with 1 message: '!(sr1.empty())' -# StringRef at compilation time -ok {test-number} - with 1 message: 'sr1.size() == 3' -# StringRef at compilation time -ok {test-number} - with 1 message: 'sr2.empty()' -# StringRef at compilation time -ok {test-number} - with 1 message: 'sr2.size() == 0' # Stringifying char arrays with statically known sizes - char ok {test-number} - ::Catch::Detail::stringify( with_null_terminator ) == R"("abc")"s for: ""abc"" == ""abc"" # Stringifying char arrays with statically known sizes - char @@ -2867,7 +2761,7 @@ ok {test-number} - registry.add( "[@no square bracket at end", "", Catch::Source # Tags with spaces and non-alphanumerical characters are accepted ok {test-number} - testCase.tags.size() == 2 for: 2 == 2 # Tags with spaces and non-alphanumerical characters are accepted -ok {test-number} - testCase.tags, VectorContains( Tag( "tag with spaces" ) ) && VectorContains( Tag( "I said \"good day\" sir!"_catch_sr ) ) for: { {?}, {?} } ( Contains: {?} and Contains: {?} ) +ok {test-number} - testCase.tags, VectorContains( Tag( "tag with spaces" ) ) && VectorContains( Tag( "I said \"good day\" sir!" ) ) for: { {?}, {?} } ( Contains: {?} and Contains: {?} ) # Template test case method with test types specified inside std::tuple - MyTypes - 0 ok {test-number} - Template_Fixture::m_a == 1 for: 1 == 1 # Template test case method with test types specified inside std::tuple - MyTypes - 1 @@ -3355,13 +3249,13 @@ ok {test-number} - trim(std::string(trailing_whitespace)) == no_whitespace for: # Trim strings ok {test-number} - trim(std::string(whitespace_at_both_ends)) == no_whitespace for: "There is no extra whitespace here" == "There is no extra whitespace here" # Trim strings -ok {test-number} - trim(StringRef(no_whitespace)) == StringRef(no_whitespace) for: There is no extra whitespace here == There is no extra whitespace here +ok {test-number} - trim(std::string_view(no_whitespace)) == std::string_view(no_whitespace) for: "There is no extra whitespace here" == "There is no extra whitespace here" # Trim strings -ok {test-number} - trim(StringRef(leading_whitespace)) == StringRef(no_whitespace) for: There is no extra whitespace here == There is no extra whitespace here +ok {test-number} - trim(std::string_view(leading_whitespace)) == std::string_view(no_whitespace) for: "There is no extra whitespace here" == "There is no extra whitespace here" # Trim strings -ok {test-number} - trim(StringRef(trailing_whitespace)) == StringRef(no_whitespace) for: There is no extra whitespace here == There is no extra whitespace here +ok {test-number} - trim(std::string_view(trailing_whitespace)) == std::string_view(no_whitespace) for: "There is no extra whitespace here" == "There is no extra whitespace here" # Trim strings -ok {test-number} - trim(StringRef(whitespace_at_both_ends)) == StringRef(no_whitespace) for: There is no extra whitespace here == There is no extra whitespace here +ok {test-number} - trim(std::string_view(whitespace_at_both_ends)) == std::string_view(no_whitespace) for: "There is no extra whitespace here" == "There is no extra whitespace here" # Type conversions of RangeEquals and similar ok {test-number} - array_int_a, RangeEquals( c_array ) for: { 1, 2, 3 } elements are { 1, 2, 3 } # Type conversions of RangeEquals and similar @@ -4205,19 +4099,19 @@ ok {test-number} - ptr.get() == 0 for: 0 == 0 # pair > -> toString ok {test-number} - ::Catch::Detail::stringify( pair ) == "{ { 42, \"Arthur\" }, { \"Ford\", 24 } }" for: "{ { 42, "Arthur" }, { "Ford", 24 } }" == "{ { 42, "Arthur" }, { "Ford", 24 } }" # parseEnums -ok {test-number} - parseEnums( "" ), Equals( std::vector{} ) for: { } Equals: { } +ok {test-number} - parseEnums( "" ), Equals( std::vector{} ) for: { } Equals: { } # parseEnums -ok {test-number} - parseEnums( "ClassName::EnumName::Value1" ), Equals(std::vector{"Value1"} ) for: { Value1 } Equals: { Value1 } +ok {test-number} - parseEnums( "ClassName::EnumName::Value1" ), Equals(std::vector{"Value1"} ) for: { "Value1" } Equals: { "Value1" } # parseEnums -ok {test-number} - parseEnums( "Value1" ), Equals( std::vector{"Value1"} ) for: { Value1 } Equals: { Value1 } +ok {test-number} - parseEnums( "Value1" ), Equals( std::vector{"Value1"} ) for: { "Value1" } Equals: { "Value1" } # parseEnums -ok {test-number} - parseEnums( "EnumName::Value1" ), Equals(std::vector{"Value1"} ) for: { Value1 } Equals: { Value1 } +ok {test-number} - parseEnums( "EnumName::Value1" ), Equals(std::vector{"Value1"} ) for: { "Value1" } Equals: { "Value1" } # parseEnums -ok {test-number} - parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2" ), Equals( std::vector{"Value1", "Value2"} ) for: { Value1, Value2 } Equals: { Value1, Value2 } +ok {test-number} - parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2" ), Equals( std::vector{"Value1", "Value2"} ) for: { "Value1", "Value2" } Equals: { "Value1", "Value2" } # parseEnums -ok {test-number} - parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2, ClassName::EnumName::Value3" ), Equals( std::vector{"Value1", "Value2", "Value3"} ) for: { Value1, Value2, Value3 } Equals: { Value1, Value2, Value3 } +ok {test-number} - parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2, ClassName::EnumName::Value3" ), Equals( std::vector{"Value1", "Value2", "Value3"} ) for: { "Value1", "Value2", "Value3" } Equals: { "Value1", "Value2", "Value3" } # parseEnums -ok {test-number} - parseEnums( "ClassName::EnumName::Value1,ClassName::EnumName::Value2 , ClassName::EnumName::Value3" ), Equals( std::vector{"Value1", "Value2", "Value3"} ) for: { Value1, Value2, Value3 } Equals: { Value1, Value2, Value3 } +ok {test-number} - parseEnums( "ClassName::EnumName::Value1,ClassName::EnumName::Value2 , ClassName::EnumName::Value3" ), Equals( std::vector{"Value1", "Value2", "Value3"} ) for: { "Value1", "Value2", "Value3" } Equals: { "Value1", "Value2", "Value3" } # pointer to class ok {test-number} - p == 0 for: 0 == 0 # print unscoped info if passing unscoped info is printed @@ -4351,15 +4245,15 @@ not ok {test-number} - false with 1 message: '3' # sends information to INFO not ok {test-number} - false with 2 messages: 'hi' and 'i := 7' # shortened hide tags are split apart -ok {test-number} - testcase.tags, VectorContains( Tag( "magic-tag" ) ) && VectorContains( Tag( "."_catch_sr ) ) for: { {?}, {?} } ( Contains: {?} and Contains: {?} ) +ok {test-number} - testcase.tags, VectorContains( Tag( "magic-tag" ) ) && VectorContains( Tag( "." ) ) for: { {?}, {?} } ( Contains: {?} and Contains: {?} ) # skipped tests can optionally provide a reason ok {test-number} - # SKIP 'skipping because answer = 43' # splitString -ok {test-number} - splitStringRef("", ','), Equals(std::vector()) for: { } Equals: { } +ok {test-number} - splitStringRef("", ','), Equals(std::vector()) for: { } Equals: { } # splitString -ok {test-number} - splitStringRef("abc", ','), Equals(std::vector{"abc"}) for: { abc } Equals: { abc } +ok {test-number} - splitStringRef("abc", ','), Equals(std::vector{"abc"}) for: { "abc" } Equals: { "abc" } # splitString -ok {test-number} - splitStringRef("abc,def", ','), Equals(std::vector{"abc", "def"}) for: { abc, def } Equals: { abc, def } +ok {test-number} - splitStringRef("abc,def", ','), Equals(std::vector{"abc", "def"}) for: { "abc", "def" } Equals: { "abc", "def" } # stacks unscoped info in loops not ok {test-number} - false with 4 messages: 'Count 1 to 3...' and '1' and '2' and '3' # stacks unscoped info in loops @@ -4369,7 +4263,7 @@ ok {test-number} - !(startsWith("", 'c')) for: !false # startsWith ok {test-number} - startsWith(std::string("abc"), 'a') for: true # startsWith -ok {test-number} - startsWith("def"_catch_sr, 'd') for: true +ok {test-number} - startsWith("def", 'd') for: true # std::map is convertible string ok {test-number} - Catch::Detail::stringify( emptyMap ) == "{ }" for: "{ }" == "{ }" # std::map is convertible string @@ -4437,7 +4331,7 @@ ok {test-number} - strlen(std::get<0>(data)) == static_cast(std::get<1>( # tags with dots in later positions are not parsed as hidden ok {test-number} - testcase.tags.size() == 1 for: 1 == 1 # tags with dots in later positions are not parsed as hidden -ok {test-number} - testcase.tags[0].original == "magic.tag"_catch_sr for: magic.tag == magic.tag +ok {test-number} - testcase.tags[0].original == "magic.tag" for: "magic.tag" == "magic.tag" # tests can be skipped dynamically at runtime ok {test-number} - # SKIP # thrown std::strings are translated @@ -4616,5 +4510,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0 ok {test-number} - # xmlentitycheck ok {test-number} - -1..2315 +1..2262 diff --git a/tests/SelfTest/Baselines/teamcity.sw.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.approved.txt index 853f3d80..b6847f2a 100644 --- a/tests/SelfTest/Baselines/teamcity.sw.approved.txt +++ b/tests/SelfTest/Baselines/teamcity.sw.approved.txt @@ -617,10 +617,6 @@ ##teamcity[testFinished name='Static arrays are convertible to string' duration="{duration}"] ##teamcity[testStarted name='String matchers'] ##teamcity[testFinished name='String matchers' duration="{duration}"] -##teamcity[testStarted name='StringRef'] -##teamcity[testFinished name='StringRef' duration="{duration}"] -##teamcity[testStarted name='StringRef at compilation time'] -##teamcity[testFinished name='StringRef at compilation time' duration="{duration}"] ##teamcity[testStarted name='Stringifying char arrays with statically known sizes - char'] ##teamcity[testFinished name='Stringifying char arrays with statically known sizes - char' duration="{duration}"] ##teamcity[testStarted name='Stringifying char arrays with statically known sizes - signed char'] diff --git a/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt index 10e318de..916adb4a 100644 --- a/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt @@ -617,10 +617,6 @@ ##teamcity[testFinished name='Static arrays are convertible to string' duration="{duration}"] ##teamcity[testStarted name='String matchers'] ##teamcity[testFinished name='String matchers' duration="{duration}"] -##teamcity[testStarted name='StringRef'] -##teamcity[testFinished name='StringRef' duration="{duration}"] -##teamcity[testStarted name='StringRef at compilation time'] -##teamcity[testFinished name='StringRef at compilation time' duration="{duration}"] ##teamcity[testStarted name='Stringifying char arrays with statically known sizes - char'] ##teamcity[testFinished name='Stringifying char arrays with statically known sizes - char' duration="{duration}"] ##teamcity[testStarted name='Stringifying char arrays with statically known sizes - signed char'] diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt index 98c04b4a..06dd2bb6 100644 --- a/tests/SelfTest/Baselines/xml.sw.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.approved.txt @@ -4619,7 +4619,7 @@ C enumInfo->lookup(0) == "Value1" - Value1 == "Value1" + "Value1" == "Value1" @@ -4627,7 +4627,7 @@ C enumInfo->lookup(1) == "Value2" - Value2 == "Value2" + "Value2" == "Value2" @@ -4635,7 +4635,7 @@ C enumInfo->lookup(3) == "{** unexpected enum value **}" - {** unexpected enum value **} + "{** unexpected enum value **}" == "{** unexpected enum value **}" @@ -13429,412 +13429,6 @@ Message from section two - -
- - - empty.empty() - - - true - - - - - empty.size() == 0 - - - 0 == 0 - - - - - std::strcmp( empty.data(), "" ) == 0 - - - 0 == 0 - - - -
-
- - - s.empty() == false - - - false == false - - - - - s.size() == 5 - - - 5 == 5 - - - - - std::strcmp( rawChars, "hello" ) == 0 - - - 0 == 0 - - - - - s.data() == rawChars - - - "hello" == "hello" - - - -
-
- - - original == "original" - - - original == "original" - - - - - original.data() - - - original.data() - - - -
-
- - - original.begin() == copy.begin() - - - "original string" == "original string" - - - -
-
- - - original.begin() == copy.begin() - - - "original string" == "original string" - - - -
-
-
- - - ss.empty() == false - - - false == false - - - - - ss.size() == 5 - - - 5 == 5 - - - - - std::strncmp( ss.data(), "hello", 5 ) == 0 - - - 0 == 0 - - - - - ss == "hello" - - - hello == "hello" - - - -
- -
-
-
- - - ss.size() == 6 - - - 6 == 6 - - - - - std::strcmp( ss.data(), "world!" ) == 0 - - - 0 == 0 - - - -
- -
-
-
- - - s.data() == s2.data() - - - "hello world!" == "hello world!" - - - -
- -
-
-
- - - s.data() == ss.data() - - - "hello world!" == "hello world!" - - - -
- -
-
-
- - - s.substr(s.size() + 1, 123).empty() - - - true - - - -
- -
-
-
- - - std::strcmp(ss.data(), "world!") == 0 - - - 0 == 0 - - - -
- -
-
-
- - - s.substr(1'000'000, 1).empty() - - - true - - - -
- -
-
- - - reinterpret_cast<char*>(buffer1) != reinterpret_cast<char*>(buffer2) - - - "Hello" != "Hello" - - - - - left == right - - - Hello == Hello - - - - - left != left.substr(0, 3) - - - Hello != Hel - - - -
-
-
- - - sr == "a standard string" - - - a standard string == "a standard string" - - - - - sr.size() == stdStr.size() - - - 17 == 17 - - - -
- -
-
-
- - - sr == "a standard string" - - - a standard string == "a standard string" - - - - - sr.size() == stdStr.size() - - - 17 == 17 - - - -
- -
-
-
- - - sr == "a standard string" - - - a standard string == "a standard string" - - - - - sr.size() == stdStr.size() - - - 17 == 17 - - - -
- -
-
-
- - - stdStr == "a stringref" - - - "a stringref" == "a stringref" - - - - - stdStr.size() == sr.size() - - - 11 == 11 - - - -
- -
-
-
- - - stdStr == "a stringref" - - - "a stringref" == "a stringref" - - - - - stdStr.size() == sr.size() - - - 11 == 11 - - - -
- -
-
- - - lhs == "some string += the stringref contents" - - - "some string += the stringref contents" -== -"some string += the stringref contents" - - - -
-
- - - together == "abrakadabra" - - - "abrakadabra" == "abrakadabra" - - - -
- -
- -
- -
-
- -
- -
@@ -14069,7 +13663,7 @@ Message from section two - testCase.tags, VectorContains( Tag( "tag with spaces" ) ) && VectorContains( Tag( "I said \"good day\" sir!"_catch_sr ) ) + testCase.tags, VectorContains( Tag( "tag with spaces" ) ) && VectorContains( Tag( "I said \"good day\" sir!" ) ) { {?}, {?} } ( Contains: {?} and Contains: {?} ) @@ -16270,42 +15864,42 @@ Message from section two - trim(StringRef(no_whitespace)) == StringRef(no_whitespace) + trim(std::string_view(no_whitespace)) == std::string_view(no_whitespace) - There is no extra whitespace here + "There is no extra whitespace here" == -There is no extra whitespace here +"There is no extra whitespace here" - trim(StringRef(leading_whitespace)) == StringRef(no_whitespace) + trim(std::string_view(leading_whitespace)) == std::string_view(no_whitespace) - There is no extra whitespace here + "There is no extra whitespace here" == -There is no extra whitespace here +"There is no extra whitespace here" - trim(StringRef(trailing_whitespace)) == StringRef(no_whitespace) + trim(std::string_view(trailing_whitespace)) == std::string_view(no_whitespace) - There is no extra whitespace here + "There is no extra whitespace here" == -There is no extra whitespace here +"There is no extra whitespace here" - trim(StringRef(whitespace_at_both_ends)) == StringRef(no_whitespace) + trim(std::string_view(whitespace_at_both_ends)) == std::string_view(no_whitespace) - There is no extra whitespace here + "There is no extra whitespace here" == -There is no extra whitespace here +"There is no extra whitespace here" @@ -20331,7 +19925,7 @@ Approx( -1.95996398454005449 )
- parseEnums( "" ), Equals( std::vector<Catch::StringRef>{} ) + parseEnums( "" ), Equals( std::vector<std::string_view>{} ) { } Equals: { } @@ -20342,26 +19936,26 @@ Approx( -1.95996398454005449 )
- parseEnums( "ClassName::EnumName::Value1" ), Equals(std::vector<Catch::StringRef>{"Value1"} ) + parseEnums( "ClassName::EnumName::Value1" ), Equals(std::vector<std::string_view>{"Value1"} ) - { Value1 } Equals: { Value1 } + { "Value1" } Equals: { "Value1" } - parseEnums( "Value1" ), Equals( std::vector<Catch::StringRef>{"Value1"} ) + parseEnums( "Value1" ), Equals( std::vector<std::string_view>{"Value1"} ) - { Value1 } Equals: { Value1 } + { "Value1" } Equals: { "Value1" } - parseEnums( "EnumName::Value1" ), Equals(std::vector<Catch::StringRef>{"Value1"} ) + parseEnums( "EnumName::Value1" ), Equals(std::vector<std::string_view>{"Value1"} ) - { Value1 } Equals: { Value1 } + { "Value1" } Equals: { "Value1" } @@ -20369,26 +19963,26 @@ Approx( -1.95996398454005449 )
- parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2" ), Equals( std::vector<Catch::StringRef>{"Value1", "Value2"} ) + parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2" ), Equals( std::vector<std::string_view>{"Value1", "Value2"} ) - { Value1, Value2 } Equals: { Value1, Value2 } + { "Value1", "Value2" } Equals: { "Value1", "Value2" } - parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2, ClassName::EnumName::Value3" ), Equals( std::vector<Catch::StringRef>{"Value1", "Value2", "Value3"} ) + parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2, ClassName::EnumName::Value3" ), Equals( std::vector<std::string_view>{"Value1", "Value2", "Value3"} ) - { Value1, Value2, Value3 } Equals: { Value1, Value2, Value3 } + { "Value1", "Value2", "Value3" } Equals: { "Value1", "Value2", "Value3" } - parseEnums( "ClassName::EnumName::Value1,ClassName::EnumName::Value2 , ClassName::EnumName::Value3" ), Equals( std::vector<Catch::StringRef>{"Value1", "Value2", "Value3"} ) + parseEnums( "ClassName::EnumName::Value1,ClassName::EnumName::Value2 , ClassName::EnumName::Value3" ), Equals( std::vector<std::string_view>{"Value1", "Value2", "Value3"} ) - { Value1, Value2, Value3 } Equals: { Value1, Value2, Value3 } + { "Value1", "Value2", "Value3" } Equals: { "Value1", "Value2", "Value3" } @@ -21017,7 +20611,7 @@ Approx( -1.95996398454005449 ) - testcase.tags, VectorContains( Tag( "magic-tag" ) ) && VectorContains( Tag( "."_catch_sr ) ) + testcase.tags, VectorContains( Tag( "magic-tag" ) ) && VectorContains( Tag( "." ) ) { {?}, {?} } ( Contains: {?} and Contains: {?} ) @@ -21034,7 +20628,7 @@ Approx( -1.95996398454005449 ) - splitStringRef("", ','), Equals(std::vector<StringRef>()) + splitStringRef("", ','), Equals(std::vector<std::string_view>()) { } Equals: { } @@ -21042,18 +20636,18 @@ Approx( -1.95996398454005449 ) - splitStringRef("abc", ','), Equals(std::vector<StringRef>{"abc"}) + splitStringRef("abc", ','), Equals(std::vector<std::string_view>{"abc"}) - { abc } Equals: { abc } + { "abc" } Equals: { "abc" } - splitStringRef("abc,def", ','), Equals(std::vector<StringRef>{"abc", "def"}) + splitStringRef("abc,def", ','), Equals(std::vector<std::string_view>{"abc", "def"}) - { abc, def } Equals: { abc, def } + { "abc", "def" } Equals: { "abc", "def" } @@ -21120,7 +20714,7 @@ Approx( -1.95996398454005449 ) - startsWith("def"_catch_sr, 'd') + startsWith("def", 'd') true @@ -21493,10 +21087,10 @@ Approx( -1.95996398454005449 ) - testcase.tags[0].original == "magic.tag"_catch_sr + testcase.tags[0].original == "magic.tag" - magic.tag == magic.tag + "magic.tag" == "magic.tag" @@ -22324,6 +21918,6 @@ Approx( -1.95996398454005449 )
- - + + diff --git a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt index 9e3d3db5..241fde9f 100644 --- a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt @@ -4619,7 +4619,7 @@ C enumInfo->lookup(0) == "Value1" - Value1 == "Value1" + "Value1" == "Value1" @@ -4627,7 +4627,7 @@ C enumInfo->lookup(1) == "Value2" - Value2 == "Value2" + "Value2" == "Value2" @@ -4635,7 +4635,7 @@ C enumInfo->lookup(3) == "{** unexpected enum value **}" - {** unexpected enum value **} + "{** unexpected enum value **}" == "{** unexpected enum value **}" @@ -13429,412 +13429,6 @@ Message from section two - -
- - - empty.empty() - - - true - - - - - empty.size() == 0 - - - 0 == 0 - - - - - std::strcmp( empty.data(), "" ) == 0 - - - 0 == 0 - - - -
-
- - - s.empty() == false - - - false == false - - - - - s.size() == 5 - - - 5 == 5 - - - - - std::strcmp( rawChars, "hello" ) == 0 - - - 0 == 0 - - - - - s.data() == rawChars - - - "hello" == "hello" - - - -
-
- - - original == "original" - - - original == "original" - - - - - original.data() - - - original.data() - - - -
-
- - - original.begin() == copy.begin() - - - "original string" == "original string" - - - -
-
- - - original.begin() == copy.begin() - - - "original string" == "original string" - - - -
-
-
- - - ss.empty() == false - - - false == false - - - - - ss.size() == 5 - - - 5 == 5 - - - - - std::strncmp( ss.data(), "hello", 5 ) == 0 - - - 0 == 0 - - - - - ss == "hello" - - - hello == "hello" - - - -
- -
-
-
- - - ss.size() == 6 - - - 6 == 6 - - - - - std::strcmp( ss.data(), "world!" ) == 0 - - - 0 == 0 - - - -
- -
-
-
- - - s.data() == s2.data() - - - "hello world!" == "hello world!" - - - -
- -
-
-
- - - s.data() == ss.data() - - - "hello world!" == "hello world!" - - - -
- -
-
-
- - - s.substr(s.size() + 1, 123).empty() - - - true - - - -
- -
-
-
- - - std::strcmp(ss.data(), "world!") == 0 - - - 0 == 0 - - - -
- -
-
-
- - - s.substr(1'000'000, 1).empty() - - - true - - - -
- -
-
- - - reinterpret_cast<char*>(buffer1) != reinterpret_cast<char*>(buffer2) - - - "Hello" != "Hello" - - - - - left == right - - - Hello == Hello - - - - - left != left.substr(0, 3) - - - Hello != Hel - - - -
-
-
- - - sr == "a standard string" - - - a standard string == "a standard string" - - - - - sr.size() == stdStr.size() - - - 17 == 17 - - - -
- -
-
-
- - - sr == "a standard string" - - - a standard string == "a standard string" - - - - - sr.size() == stdStr.size() - - - 17 == 17 - - - -
- -
-
-
- - - sr == "a standard string" - - - a standard string == "a standard string" - - - - - sr.size() == stdStr.size() - - - 17 == 17 - - - -
- -
-
-
- - - stdStr == "a stringref" - - - "a stringref" == "a stringref" - - - - - stdStr.size() == sr.size() - - - 11 == 11 - - - -
- -
-
-
- - - stdStr == "a stringref" - - - "a stringref" == "a stringref" - - - - - stdStr.size() == sr.size() - - - 11 == 11 - - - -
- -
-
- - - lhs == "some string += the stringref contents" - - - "some string += the stringref contents" -== -"some string += the stringref contents" - - - -
-
- - - together == "abrakadabra" - - - "abrakadabra" == "abrakadabra" - - - -
- -
- -
- -
-
- -
- -
@@ -14069,7 +13663,7 @@ Message from section two - testCase.tags, VectorContains( Tag( "tag with spaces" ) ) && VectorContains( Tag( "I said \"good day\" sir!"_catch_sr ) ) + testCase.tags, VectorContains( Tag( "tag with spaces" ) ) && VectorContains( Tag( "I said \"good day\" sir!" ) ) { {?}, {?} } ( Contains: {?} and Contains: {?} ) @@ -16270,42 +15864,42 @@ Message from section two - trim(StringRef(no_whitespace)) == StringRef(no_whitespace) + trim(std::string_view(no_whitespace)) == std::string_view(no_whitespace) - There is no extra whitespace here + "There is no extra whitespace here" == -There is no extra whitespace here +"There is no extra whitespace here" - trim(StringRef(leading_whitespace)) == StringRef(no_whitespace) + trim(std::string_view(leading_whitespace)) == std::string_view(no_whitespace) - There is no extra whitespace here + "There is no extra whitespace here" == -There is no extra whitespace here +"There is no extra whitespace here" - trim(StringRef(trailing_whitespace)) == StringRef(no_whitespace) + trim(std::string_view(trailing_whitespace)) == std::string_view(no_whitespace) - There is no extra whitespace here + "There is no extra whitespace here" == -There is no extra whitespace here +"There is no extra whitespace here" - trim(StringRef(whitespace_at_both_ends)) == StringRef(no_whitespace) + trim(std::string_view(whitespace_at_both_ends)) == std::string_view(no_whitespace) - There is no extra whitespace here + "There is no extra whitespace here" == -There is no extra whitespace here +"There is no extra whitespace here" @@ -20330,7 +19924,7 @@ Approx( -1.95996398454005449 )
- parseEnums( "" ), Equals( std::vector<Catch::StringRef>{} ) + parseEnums( "" ), Equals( std::vector<std::string_view>{} ) { } Equals: { } @@ -20341,26 +19935,26 @@ Approx( -1.95996398454005449 )
- parseEnums( "ClassName::EnumName::Value1" ), Equals(std::vector<Catch::StringRef>{"Value1"} ) + parseEnums( "ClassName::EnumName::Value1" ), Equals(std::vector<std::string_view>{"Value1"} ) - { Value1 } Equals: { Value1 } + { "Value1" } Equals: { "Value1" } - parseEnums( "Value1" ), Equals( std::vector<Catch::StringRef>{"Value1"} ) + parseEnums( "Value1" ), Equals( std::vector<std::string_view>{"Value1"} ) - { Value1 } Equals: { Value1 } + { "Value1" } Equals: { "Value1" } - parseEnums( "EnumName::Value1" ), Equals(std::vector<Catch::StringRef>{"Value1"} ) + parseEnums( "EnumName::Value1" ), Equals(std::vector<std::string_view>{"Value1"} ) - { Value1 } Equals: { Value1 } + { "Value1" } Equals: { "Value1" } @@ -20368,26 +19962,26 @@ Approx( -1.95996398454005449 )
- parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2" ), Equals( std::vector<Catch::StringRef>{"Value1", "Value2"} ) + parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2" ), Equals( std::vector<std::string_view>{"Value1", "Value2"} ) - { Value1, Value2 } Equals: { Value1, Value2 } + { "Value1", "Value2" } Equals: { "Value1", "Value2" } - parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2, ClassName::EnumName::Value3" ), Equals( std::vector<Catch::StringRef>{"Value1", "Value2", "Value3"} ) + parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2, ClassName::EnumName::Value3" ), Equals( std::vector<std::string_view>{"Value1", "Value2", "Value3"} ) - { Value1, Value2, Value3 } Equals: { Value1, Value2, Value3 } + { "Value1", "Value2", "Value3" } Equals: { "Value1", "Value2", "Value3" } - parseEnums( "ClassName::EnumName::Value1,ClassName::EnumName::Value2 , ClassName::EnumName::Value3" ), Equals( std::vector<Catch::StringRef>{"Value1", "Value2", "Value3"} ) + parseEnums( "ClassName::EnumName::Value1,ClassName::EnumName::Value2 , ClassName::EnumName::Value3" ), Equals( std::vector<std::string_view>{"Value1", "Value2", "Value3"} ) - { Value1, Value2, Value3 } Equals: { Value1, Value2, Value3 } + { "Value1", "Value2", "Value3" } Equals: { "Value1", "Value2", "Value3" } @@ -21016,7 +20610,7 @@ Approx( -1.95996398454005449 ) - testcase.tags, VectorContains( Tag( "magic-tag" ) ) && VectorContains( Tag( "."_catch_sr ) ) + testcase.tags, VectorContains( Tag( "magic-tag" ) ) && VectorContains( Tag( "." ) ) { {?}, {?} } ( Contains: {?} and Contains: {?} ) @@ -21033,7 +20627,7 @@ Approx( -1.95996398454005449 ) - splitStringRef("", ','), Equals(std::vector<StringRef>()) + splitStringRef("", ','), Equals(std::vector<std::string_view>()) { } Equals: { } @@ -21041,18 +20635,18 @@ Approx( -1.95996398454005449 ) - splitStringRef("abc", ','), Equals(std::vector<StringRef>{"abc"}) + splitStringRef("abc", ','), Equals(std::vector<std::string_view>{"abc"}) - { abc } Equals: { abc } + { "abc" } Equals: { "abc" } - splitStringRef("abc,def", ','), Equals(std::vector<StringRef>{"abc", "def"}) + splitStringRef("abc,def", ','), Equals(std::vector<std::string_view>{"abc", "def"}) - { abc, def } Equals: { abc, def } + { "abc", "def" } Equals: { "abc", "def" } @@ -21119,7 +20713,7 @@ Approx( -1.95996398454005449 ) - startsWith("def"_catch_sr, 'd') + startsWith("def", 'd') true @@ -21492,10 +21086,10 @@ Approx( -1.95996398454005449 ) - testcase.tags[0].original == "magic.tag"_catch_sr + testcase.tags[0].original == "magic.tag" - magic.tag == magic.tag + "magic.tag" == "magic.tag" @@ -22323,6 +21917,6 @@ Approx( -1.95996398454005449 )
- - + + diff --git a/tests/SelfTest/IntrospectiveTests/AssertionHandler.tests.cpp b/tests/SelfTest/IntrospectiveTests/AssertionHandler.tests.cpp index 15966a07..1a6b2d3a 100644 --- a/tests/SelfTest/IntrospectiveTests/AssertionHandler.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/AssertionHandler.tests.cpp @@ -10,7 +10,7 @@ TEST_CASE( "Incomplete AssertionHandler", "[assertion-handler][!shouldfail]" ) { Catch::AssertionHandler catchAssertionHandler( - "REQUIRE"_catch_sr, + "REQUIRE", CATCH_INTERNAL_LINEINFO, "Dummy", Catch::ResultDisposition::Normal ); diff --git a/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp b/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp index 5ef7dc51..9243d63b 100644 --- a/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp @@ -446,11 +446,11 @@ TEST_CASE( "Generators can stringify their elements", auto generator = Catch::Generators::FixedValuesGenerator( { 1, 2, 3 } ); - REQUIRE( generator.currentElementAsString() == "1"_catch_sr ); + REQUIRE( generator.currentElementAsString() == "1" ); REQUIRE( generator.countedNext() ); - REQUIRE( generator.currentElementAsString() == "2"_catch_sr ); + REQUIRE( generator.currentElementAsString() == "2" ); REQUIRE( generator.countedNext() ); - REQUIRE( generator.currentElementAsString() == "3"_catch_sr ); + REQUIRE( generator.currentElementAsString() == "3" ); } namespace { @@ -481,9 +481,9 @@ namespace { TEST_CASE( "Generators can override element stringification", "[generators][approvals]" ) { CustomStringifyGenerator generator; - REQUIRE( generator.currentElementAsString() == "first"_catch_sr ); + REQUIRE( generator.currentElementAsString() == "first" ); REQUIRE( generator.countedNext() ); - REQUIRE( generator.currentElementAsString() == "second"_catch_sr ); + REQUIRE( generator.currentElementAsString() == "second" ); } namespace { @@ -519,11 +519,11 @@ namespace { TEST_CASE( "Generator element stringification is cached", "[generators][approvals]" ) { StringifyCountingGenerator generator; - REQUIRE( generator.currentElementAsString() == "first"_catch_sr ); - REQUIRE( generator.currentElementAsString() == "first"_catch_sr ); - REQUIRE( generator.currentElementAsString() == "first"_catch_sr ); - REQUIRE( generator.currentElementAsString() == "first"_catch_sr ); - REQUIRE( generator.currentElementAsString() == "first"_catch_sr ); + REQUIRE( generator.currentElementAsString() == "first" ); + REQUIRE( generator.currentElementAsString() == "first" ); + REQUIRE( generator.currentElementAsString() == "first" ); + REQUIRE( generator.currentElementAsString() == "first" ); + REQUIRE( generator.currentElementAsString() == "first" ); REQUIRE( generator.stringificationCalls() == 1 ); } diff --git a/tests/SelfTest/IntrospectiveTests/PartTracker.tests.cpp b/tests/SelfTest/IntrospectiveTests/PartTracker.tests.cpp index c13ec573..ad628e55 100644 --- a/tests/SelfTest/IntrospectiveTests/PartTracker.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/PartTracker.tests.cpp @@ -14,7 +14,7 @@ using namespace Catch; namespace { -Catch::TestCaseTracking::NameAndLocationRef makeNAL( StringRef name ) { +Catch::TestCaseTracking::NameAndLocationRef makeNAL( std::string_view name ) { return Catch::TestCaseTracking::NameAndLocationRef( name, Catch::SourceLineInfo("",0) ); } } diff --git a/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp b/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp index 86ba1175..e419d903 100644 --- a/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp @@ -53,7 +53,7 @@ TEST_CASE( "The default listing implementation write to provided stream", StringIStream sstream; SECTION( "Listing tags" ) { std::vector tags(1); - tags[0].add("fakeTag"_catch_sr); + tags[0].add("fakeTag"); Catch::defaultListTags(sstream.stream(), tags, false); auto listingString = sstream.str(); @@ -72,7 +72,7 @@ TEST_CASE( "The default listing implementation write to provided stream", SECTION( "Listing tests" ) { Catch::TestCaseInfo fakeInfo{ ""s, - { "fake test name"_catch_sr, "[fakeTestTag]"_catch_sr }, + { "fake test name", "[fakeTestTag]" }, { "fake-file.cpp", 123456789 } }; std::vector tests({ {&fakeInfo, nullptr} }); auto colour = Catch::makeColourImpl( Catch::ColourMode::None, &sstream); @@ -85,7 +85,7 @@ TEST_CASE( "The default listing implementation write to provided stream", } SECTION( "Listing listeners" ) { std::vector listeners( - { { "fakeListener"_catch_sr, "fake description" } } ); + { { "fakeListener", "fake description" } } ); Catch::defaultListListeners( sstream.stream(), listeners ); auto listingString = sstream.str(); @@ -117,7 +117,7 @@ TEST_CASE( "Reporter's write listings to provided stream", "[reporters]" ) { DYNAMIC_SECTION( factory.first << " reporter lists tags" ) { std::vector tags(1); - tags[0].add("fakeTag"_catch_sr); + tags[0].add("fakeTag"); reporter->listTags(tags); auto listingString = sstreamRef.str(); @@ -136,7 +136,7 @@ TEST_CASE( "Reporter's write listings to provided stream", "[reporters]" ) { DYNAMIC_SECTION( factory.first << " reporter lists tests" ) { Catch::TestCaseInfo fakeInfo{ ""s, - { "fake test name"_catch_sr, "[fakeTestTag]"_catch_sr }, + { "fake test name", "[fakeTestTag]" }, { "fake-file.cpp", 123456789 } }; std::vector tests({ {&fakeInfo, nullptr} }); reporter->listTests(tests); diff --git a/tests/SelfTest/IntrospectiveTests/String.tests.cpp b/tests/SelfTest/IntrospectiveTests/String.tests.cpp deleted file mode 100644 index 43c58b49..00000000 --- a/tests/SelfTest/IntrospectiveTests/String.tests.cpp +++ /dev/null @@ -1,212 +0,0 @@ - -// Copyright Catch2 Authors -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE.txt or copy at -// https://www.boost.org/LICENSE_1_0.txt) - -// SPDX-License-Identifier: BSL-1.0 - -#include -#include - -#include - -TEST_CASE( "StringRef", "[Strings][StringRef]" ) { - using Catch::StringRef; - - SECTION( "Empty string" ) { - StringRef empty; - REQUIRE( empty.empty() ); - REQUIRE( empty.size() == 0 ); - REQUIRE( std::strcmp( empty.data(), "" ) == 0 ); - } - - SECTION( "From string literal" ) { - StringRef s = "hello"; - REQUIRE( s.empty() == false ); - REQUIRE( s.size() == 5 ); - - auto rawChars = s.data(); - REQUIRE( std::strcmp( rawChars, "hello" ) == 0 ); - - REQUIRE(s.data() == rawChars); - } - SECTION( "From sub-string" ) { - StringRef original = StringRef( "original string" ).substr(0, 8); - REQUIRE( original == "original" ); - - REQUIRE_NOTHROW(original.data()); - } - SECTION( "Copy construction is shallow" ) { - StringRef original = StringRef( "original string" ); - StringRef copy = original; - REQUIRE(original.begin() == copy.begin()); - } - SECTION( "Copy assignment is shallow" ) { - StringRef original = StringRef( "original string" ); - StringRef copy; - copy = original; - REQUIRE(original.begin() == copy.begin()); - } - - SECTION( "Substrings" ) { - StringRef s = "hello world!"; - StringRef ss = s.substr(0, 5); - - SECTION( "zero-based substring" ) { - REQUIRE( ss.empty() == false ); - REQUIRE( ss.size() == 5 ); - REQUIRE( std::strncmp( ss.data(), "hello", 5 ) == 0 ); - REQUIRE( ss == "hello" ); - } - - SECTION( "non-zero-based substring") { - ss = s.substr( 6, 6 ); - REQUIRE( ss.size() == 6 ); - REQUIRE( std::strcmp( ss.data(), "world!" ) == 0 ); - } - - SECTION( "Pointer values of full refs should match" ) { - StringRef s2 = s; - REQUIRE( s.data() == s2.data() ); - } - - SECTION( "Pointer values of substring refs should also match" ) { - REQUIRE( s.data() == ss.data() ); - } - - SECTION("Past the end substring") { - REQUIRE(s.substr(s.size() + 1, 123).empty()); - } - - SECTION("Substring off the end are trimmed") { - ss = s.substr(6, 123); - REQUIRE(std::strcmp(ss.data(), "world!") == 0); - } - SECTION("substring start after the end is empty") { - REQUIRE(s.substr(1'000'000, 1).empty()); - } - } - - SECTION( "Comparisons are deep" ) { - char buffer1[] = "Hello"; - char buffer2[] = "Hello"; - CHECK(reinterpret_cast(buffer1) != reinterpret_cast(buffer2)); - - StringRef left(buffer1), right(buffer2); - REQUIRE( left == right ); - REQUIRE(left != left.substr(0, 3)); - } - - SECTION( "from std::string" ) { - std::string stdStr = "a standard string"; - - SECTION( "implicitly constructed" ) { - StringRef sr = stdStr; - REQUIRE( sr == "a standard string" ); - REQUIRE( sr.size() == stdStr.size() ); - } - SECTION( "explicitly constructed" ) { - StringRef sr( stdStr ); - REQUIRE( sr == "a standard string" ); - REQUIRE( sr.size() == stdStr.size() ); - } - SECTION( "assigned" ) { - StringRef sr; - sr = stdStr; - REQUIRE( sr == "a standard string" ); - REQUIRE( sr.size() == stdStr.size() ); - } - } - - SECTION( "to std::string" ) { - StringRef sr = "a stringref"; - - SECTION( "explicitly constructed" ) { - std::string stdStr( sr ); - REQUIRE( stdStr == "a stringref" ); - REQUIRE( stdStr.size() == sr.size() ); - } - SECTION( "assigned" ) { - std::string stdStr; - stdStr = static_cast(sr); - REQUIRE( stdStr == "a stringref" ); - REQUIRE( stdStr.size() == sr.size() ); - } - } - - SECTION("std::string += StringRef") { - StringRef sr = "the stringref contents"; - std::string lhs("some string += "); - lhs += sr; - REQUIRE(lhs == "some string += the stringref contents"); - } - SECTION("StringRef + StringRef") { - StringRef sr1 = "abraka", sr2 = "dabra"; - std::string together = sr1 + sr2; - REQUIRE(together == "abrakadabra"); - } -} - -TEST_CASE("StringRef at compilation time", "[Strings][StringRef][constexpr]") { - using Catch::StringRef; - SECTION("Simple constructors") { - constexpr StringRef empty{}; - STATIC_REQUIRE(empty.size() == 0); - STATIC_REQUIRE(empty.begin() == empty.end()); - - constexpr char const* const abc = "abc"; - - constexpr StringRef stringref(abc, 3); - STATIC_REQUIRE(stringref.size() == 3); - STATIC_REQUIRE(stringref.data() == abc); - STATIC_REQUIRE(stringref.begin() == abc); - STATIC_REQUIRE(stringref.begin() != stringref.end()); - STATIC_REQUIRE(stringref.substr(10, 0).empty()); - STATIC_REQUIRE(stringref.substr(2, 1).data() == abc + 2); - STATIC_REQUIRE(stringref[1] == 'b'); - - - constexpr StringRef shortened(abc, 2); - STATIC_REQUIRE(shortened.size() == 2); - STATIC_REQUIRE(shortened.data() == abc); - STATIC_REQUIRE(shortened.begin() != shortened.end()); - } - SECTION("UDL construction") { - constexpr auto sr1 = "abc"_catch_sr; - STATIC_REQUIRE_FALSE(sr1.empty()); - STATIC_REQUIRE(sr1.size() == 3); - - using Catch::operator""_sr; - constexpr auto sr2 = ""_sr; - STATIC_REQUIRE(sr2.empty()); - STATIC_REQUIRE(sr2.size() == 0); - } -} - -TEST_CASE("StringRef::compare", "[Strings][StringRef][approvals]") { - using Catch::StringRef; - - SECTION("Same length on both sides") { - StringRef sr1("abcdc"); - StringRef sr2("abcdd"); - StringRef sr3("abcdc"); - - REQUIRE(sr1.compare(sr2) < 0); - REQUIRE(sr2.compare(sr1) > 0); - REQUIRE(sr1.compare(sr3) == 0); - REQUIRE(sr3.compare(sr1) == 0); - } - SECTION("Different lengths") { - StringRef sr1("def"); - StringRef sr2("deff"); - StringRef sr3("ab"); - - REQUIRE(sr1.compare(sr2) < 0); - REQUIRE(sr2.compare(sr1) > 0); - REQUIRE(sr1.compare(sr3) > 0); - REQUIRE(sr2.compare(sr3) > 0); - REQUIRE(sr3.compare(sr1) < 0); - REQUIRE(sr3.compare(sr2) < 0); - } -} diff --git a/tests/SelfTest/IntrospectiveTests/StringManip.tests.cpp b/tests/SelfTest/IntrospectiveTests/StringManip.tests.cpp index b3b80db8..e96710e9 100644 --- a/tests/SelfTest/IntrospectiveTests/StringManip.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/StringManip.tests.cpp @@ -16,19 +16,19 @@ static const char * const trailing_whitespace = "There is no extra whitespace he static const char * const whitespace_at_both_ends = " \r\n \t There is no extra whitespace here \t\t\t \n"; TEST_CASE("Trim strings", "[string-manip]") { - using Catch::trim; using Catch::StringRef; + using Catch::trim; static_assert(std::is_same_v, "Trimming std::string should return std::string"); - static_assert(std::is_same_v, "Trimming StringRef should return StringRef"); + static_assert(std::is_same_v, "Trimming std::string_view should return std::string_view"); REQUIRE(trim(std::string(no_whitespace)) == no_whitespace); REQUIRE(trim(std::string(leading_whitespace)) == no_whitespace); REQUIRE(trim(std::string(trailing_whitespace)) == no_whitespace); REQUIRE(trim(std::string(whitespace_at_both_ends)) == no_whitespace); - REQUIRE(trim(StringRef(no_whitespace)) == StringRef(no_whitespace)); - REQUIRE(trim(StringRef(leading_whitespace)) == StringRef(no_whitespace)); - REQUIRE(trim(StringRef(trailing_whitespace)) == StringRef(no_whitespace)); - REQUIRE(trim(StringRef(whitespace_at_both_ends)) == StringRef(no_whitespace)); + REQUIRE(trim(std::string_view(no_whitespace)) == std::string_view(no_whitespace)); + REQUIRE(trim(std::string_view(leading_whitespace)) == std::string_view(no_whitespace)); + REQUIRE(trim(std::string_view(trailing_whitespace)) == std::string_view(no_whitespace)); + REQUIRE(trim(std::string_view(whitespace_at_both_ends)) == std::string_view(no_whitespace)); } TEST_CASE("replaceInPlace", "[string-manip]") { @@ -78,11 +78,10 @@ TEST_CASE("replaceInPlace", "[string-manip]") { TEST_CASE("splitString", "[string-manip]") { using namespace Catch::Matchers; using Catch::splitStringRef; - using Catch::StringRef; - CHECK_THAT(splitStringRef("", ','), Equals(std::vector())); - CHECK_THAT(splitStringRef("abc", ','), Equals(std::vector{"abc"})); - CHECK_THAT(splitStringRef("abc,def", ','), Equals(std::vector{"abc", "def"})); + CHECK_THAT(splitStringRef("", ','), Equals(std::vector())); + CHECK_THAT(splitStringRef("abc", ','), Equals(std::vector{"abc"})); + CHECK_THAT(splitStringRef("abc,def", ','), Equals(std::vector{"abc", "def"})); } TEST_CASE("startsWith", "[string-manip]") { @@ -90,5 +89,5 @@ TEST_CASE("startsWith", "[string-manip]") { CHECK_FALSE(startsWith("", 'c')); CHECK(startsWith(std::string("abc"), 'a')); - CHECK(startsWith("def"_catch_sr, 'd')); + CHECK(startsWith("def", 'd')); } diff --git a/tests/SelfTest/IntrospectiveTests/Tag.tests.cpp b/tests/SelfTest/IntrospectiveTests/Tag.tests.cpp index 43723758..d6bbcb4b 100644 --- a/tests/SelfTest/IntrospectiveTests/Tag.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/Tag.tests.cpp @@ -46,22 +46,20 @@ TEST_CASE( "Tag alias can be registered against tag patterns" ) { static constexpr Catch::SourceLineInfo dummySourceLineInfo = CATCH_INTERNAL_LINEINFO; TEST_CASE("shortened hide tags are split apart", "[tags]") { - using Catch::StringRef; using Catch::Tag; using Catch::Matchers::VectorContains; Catch::TestCaseInfo testcase("", {"fake test name", "[.magic-tag]"}, dummySourceLineInfo); REQUIRE_THAT( testcase.tags, VectorContains( Tag( "magic-tag" ) ) - && VectorContains( Tag( "."_catch_sr ) ) ); + && VectorContains( Tag( "." ) ) ); } TEST_CASE("tags with dots in later positions are not parsed as hidden", "[tags]") { - using Catch::StringRef; using Catch::Matchers::VectorContains; Catch::TestCaseInfo testcase("", { "fake test name", "[magic.tag]" }, dummySourceLineInfo); REQUIRE(testcase.tags.size() == 1); - REQUIRE(testcase.tags[0].original == "magic.tag"_catch_sr); + REQUIRE(testcase.tags[0].original == "magic.tag"); } TEST_CASE( "empty tags are not allowed", "[tags]" ) { @@ -83,7 +81,7 @@ TEST_CASE( "Tags with spaces and non-alphanumerical characters are accepted", REQUIRE( testCase.tags.size() == 2 ); REQUIRE_THAT( testCase.tags, VectorContains( Tag( "tag with spaces" ) ) && - VectorContains( Tag( "I said \"good day\" sir!"_catch_sr ) ) ); + VectorContains( Tag( "I said \"good day\" sir!" ) ) ); } TEST_CASE( "Test case with identical tags keeps just one", "[tags]" ) { diff --git a/tests/SelfTest/IntrospectiveTests/ToString.tests.cpp b/tests/SelfTest/IntrospectiveTests/ToString.tests.cpp index be639ce3..df0feb93 100644 --- a/tests/SelfTest/IntrospectiveTests/ToString.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/ToString.tests.cpp @@ -29,24 +29,24 @@ TEST_CASE( "parseEnums", "[Strings][enums]" ) { using Catch::Detail::parseEnums; SECTION( "No enums" ) - CHECK_THAT( parseEnums( "" ), Equals( std::vector{} ) ); + CHECK_THAT( parseEnums( "" ), Equals( std::vector{} ) ); SECTION( "One enum value" ) { CHECK_THAT( parseEnums( "ClassName::EnumName::Value1" ), - Equals(std::vector{"Value1"} ) ); + Equals(std::vector{"Value1"} ) ); CHECK_THAT( parseEnums( "Value1" ), - Equals( std::vector{"Value1"} ) ); + Equals( std::vector{"Value1"} ) ); CHECK_THAT( parseEnums( "EnumName::Value1" ), - Equals(std::vector{"Value1"} ) ); + Equals(std::vector{"Value1"} ) ); } SECTION( "Multiple enum values" ) { CHECK_THAT( parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2" ), - Equals( std::vector{"Value1", "Value2"} ) ); + Equals( std::vector{"Value1", "Value2"} ) ); CHECK_THAT( parseEnums( "ClassName::EnumName::Value1, ClassName::EnumName::Value2, ClassName::EnumName::Value3" ), - Equals( std::vector{"Value1", "Value2", "Value3"} ) ); + Equals( std::vector{"Value1", "Value2", "Value3"} ) ); CHECK_THAT( parseEnums( "ClassName::EnumName::Value1,ClassName::EnumName::Value2 , ClassName::EnumName::Value3" ), - Equals( std::vector{"Value1", "Value2", "Value3"} ) ); + Equals( std::vector{"Value1", "Value2", "Value3"} ) ); } } @@ -70,19 +70,19 @@ TEST_CASE("convertIntoString stringification helper", "[toString][approvals]") { using namespace Catch; SECTION("No escaping") { - CHECK(convertIntoString(""_sr, false) == R"("")"s); - CHECK(convertIntoString("abcd"_sr, false) == R"("abcd")"s); - CHECK(convertIntoString("ab\ncd"_sr, false) == "\"ab\ncd\""s); - CHECK(convertIntoString("ab\r\ncd"_sr, false) == "\"ab\r\ncd\""s); - CHECK(convertIntoString("ab\"cd"_sr, false) == R"("ab"cd")"s); + CHECK(convertIntoString("", false) == R"("")"s); + CHECK(convertIntoString("abcd", false) == R"("abcd")"s); + CHECK(convertIntoString("ab\ncd", false) == "\"ab\ncd\""s); + CHECK(convertIntoString("ab\r\ncd", false) == "\"ab\r\ncd\""s); + CHECK(convertIntoString("ab\"cd", false) == R"("ab"cd")"s); } SECTION("Escaping invisibles") { - CHECK(convertIntoString(""_sr, true) == R"("")"s); - CHECK(convertIntoString("ab\ncd"_sr, true) == R"("ab\ncd")"s); - CHECK(convertIntoString("ab\r\ncd"_sr, true) == R"("ab\r\ncd")"s); - CHECK(convertIntoString("ab\tcd"_sr, true) == R"("ab\tcd")"s); - CHECK(convertIntoString("ab\fcd"_sr, true) == R"("ab\fcd")"s); - CHECK(convertIntoString("ab\"cd"_sr, true) == R"("ab"cd")"s); + CHECK(convertIntoString("", true) == R"("")"s); + CHECK(convertIntoString("ab\ncd", true) == R"("ab\ncd")"s); + CHECK(convertIntoString("ab\r\ncd", true) == R"("ab\r\ncd")"s); + CHECK(convertIntoString("ab\tcd", true) == R"("ab\tcd")"s); + CHECK(convertIntoString("ab\fcd", true) == R"("ab\fcd")"s); + CHECK(convertIntoString("ab\"cd", true) == R"("ab"cd")"s); } } diff --git a/tests/meson.build b/tests/meson.build index 58302b7a..e33dd066 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -25,7 +25,6 @@ self_test_sources = files( 'SelfTest/IntrospectiveTests/Reporters.tests.cpp', 'SelfTest/IntrospectiveTests/Sharding.tests.cpp', 'SelfTest/IntrospectiveTests/Stream.tests.cpp', - 'SelfTest/IntrospectiveTests/String.tests.cpp', 'SelfTest/IntrospectiveTests/StringManip.tests.cpp', 'SelfTest/IntrospectiveTests/Tag.tests.cpp', 'SelfTest/IntrospectiveTests/TestCaseInfoHasher.tests.cpp',