diff --git a/include/internal/catch_assertionresult.cpp b/include/internal/catch_assertionresult.cpp index 8f505d04..5da1cfdf 100644 --- a/include/internal/catch_assertionresult.cpp +++ b/include/internal/catch_assertionresult.cpp @@ -56,13 +56,13 @@ namespace Catch { if( isFalseTest( m_info.resultDisposition ) ) return "!(" + m_info.capturedExpression + ")"; else - return m_info.capturedExpression; + return static_cast(m_info.capturedExpression); } std::string AssertionResult::getExpressionInMacro() const { std::string expr; if( m_info.macroName[0] == 0 ) - expr = m_info.capturedExpression; + expr = static_cast(m_info.capturedExpression); else { expr.reserve( m_info.macroName.size() + m_info.capturedExpression.size() + 4 ); expr += m_info.macroName; diff --git a/include/internal/catch_message.cpp b/include/internal/catch_message.cpp index faceb50c..8f391bcb 100644 --- a/include/internal/catch_message.cpp +++ b/include/internal/catch_message.cpp @@ -113,7 +113,7 @@ namespace Catch { case ',': if (start != pos && openings.size() == 0) { m_messages.emplace_back(macroName, lineInfo, resultType); - m_messages.back().message = trimmed(start, pos); + m_messages.back().message = static_cast(trimmed(start, pos)); m_messages.back().message += " := "; start = pos; } @@ -121,7 +121,7 @@ namespace Catch { } assert(openings.size() == 0 && "Mismatched openings"); m_messages.emplace_back(macroName, lineInfo, resultType); - m_messages.back().message = trimmed(start, names.size() - 1); + m_messages.back().message = static_cast(trimmed(start, names.size() - 1)); m_messages.back().message += " := "; } Capturer::~Capturer() { diff --git a/include/internal/catch_run_context.cpp b/include/internal/catch_run_context.cpp index d2acc652..79f906d6 100644 --- a/include/internal/catch_run_context.cpp +++ b/include/internal/catch_run_context.cpp @@ -230,7 +230,7 @@ namespace Catch { m_unfinishedSections.push_back(endInfo); } - + #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) void RunContext::benchmarkPreparing(std::string const& name) { m_reporter->benchmarkPreparing(name); @@ -279,7 +279,7 @@ namespace Catch { // Don't rebuild the result -- the stringification itself can cause more fatal errors // Instead, fake a result data. AssertionResultData tempResult( ResultWas::FatalErrorCondition, { false } ); - tempResult.message = message; + tempResult.message = static_cast(message); AssertionResult result(m_lastAssertionInfo, tempResult); assertionEnded(result); @@ -442,7 +442,7 @@ namespace Catch { m_lastAssertionInfo = info; AssertionResultData data( resultType, LazyExpression( false ) ); - data.message = message; + data.message = static_cast(message); AssertionResult assertionResult{ m_lastAssertionInfo, data }; assertionEnded( assertionResult ); if( !assertionResult.isOk() ) diff --git a/include/internal/catch_stringref.h b/include/internal/catch_stringref.h index f7e4a360..b83e61bb 100644 --- a/include/internal/catch_stringref.h +++ b/include/internal/catch_stringref.h @@ -23,6 +23,7 @@ namespace Catch { class StringRef { public: using size_type = std::size_t; + using const_iterator = const char*; private: friend struct StringRefTestAccess; @@ -78,7 +79,7 @@ namespace Catch { return *this; } - operator std::string() const; + explicit operator std::string() const; void swap( StringRef& other ) noexcept; @@ -105,6 +106,10 @@ namespace Catch { // Note that the pointer can change when if the StringRef is a substring auto currentData() const noexcept -> char const*; + public: // iterators + const_iterator begin() const { return m_start; } + const_iterator end() const { return m_start + m_size; } + private: // ownership queries - may not be consistent between calls auto isOwned() const noexcept -> bool; auto isSubstring() const noexcept -> bool; diff --git a/include/internal/catch_test_case_info.cpp b/include/internal/catch_test_case_info.cpp index 4baa9d4b..685ee30f 100644 --- a/include/internal/catch_test_case_info.cpp +++ b/include/internal/catch_test_case_info.cpp @@ -59,8 +59,7 @@ namespace Catch { std::vector tags; std::string desc, tag; bool inTag = false; - std::string _descOrTags = nameAndTags.tags; - for (char c : _descOrTags) { + for (char c : nameAndTags.tags) { if( !inTag ) { if( c == '[' ) inTag = true; @@ -93,7 +92,7 @@ namespace Catch { tags.push_back( "." ); } - TestCaseInfo info( nameAndTags.name, _className, desc, tags, _lineInfo ); + TestCaseInfo info( static_cast(nameAndTags.name), _className, desc, tags, _lineInfo ); return TestCase( _testCase, std::move(info) ); } diff --git a/include/internal/catch_test_case_registry_impl.cpp b/include/internal/catch_test_case_registry_impl.cpp index bb596804..84bfdae1 100644 --- a/include/internal/catch_test_case_registry_impl.cpp +++ b/include/internal/catch_test_case_registry_impl.cpp @@ -105,7 +105,7 @@ namespace Catch { } std::string extractClassName( StringRef const& classOrQualifiedMethodName ) { - std::string className = classOrQualifiedMethodName; + std::string className(classOrQualifiedMethodName); if( startsWith( className, '&' ) ) { std::size_t lastColons = className.rfind( "::" ); diff --git a/include/internal/catch_tostring.h b/include/internal/catch_tostring.h index 8668b1eb..640fc8cb 100644 --- a/include/internal/catch_tostring.h +++ b/include/internal/catch_tostring.h @@ -654,7 +654,7 @@ namespace Catch { \ template<> struct StringMaker { \ static std::string convert( enumName value ) { \ static const auto& enumInfo = ::Catch::getMutableRegistryHub().getMutableEnumValuesRegistry().registerEnum( #enumName, #__VA_ARGS__, { __VA_ARGS__ } ); \ - return enumInfo.lookup( static_cast( value ) ); \ + return static_cast(enumInfo.lookup( static_cast( value ) )); \ } \ }; \ } diff --git a/projects/SelfTest/Baselines/compact.sw.approved.txt b/projects/SelfTest/Baselines/compact.sw.approved.txt index c6a401fc..3e2984f6 100644 --- a/projects/SelfTest/Baselines/compact.sw.approved.txt +++ b/projects/SelfTest/Baselines/compact.sw.approved.txt @@ -1043,8 +1043,6 @@ String.tests.cpp:: passed: stdStr == "a stringref" for: "a stringre 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: stdStr == "a stringref" for: "a stringref" == "a stringref" -String.tests.cpp:: passed: stdStr.size() == sr.size() for: 11 == 11 ToStringChrono.tests.cpp:: passed: minute == seconds for: 1 m == 60 s ToStringChrono.tests.cpp:: passed: hour != seconds for: 1 h != 60 s ToStringChrono.tests.cpp:: passed: micro != milli for: 1 us != 1 ms diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index 59ea0426..1f30e8f4 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -1381,5 +1381,5 @@ due to unexpected exception with message: =============================================================================== test cases: 300 | 226 passed | 70 failed | 4 failed as expected -assertions: 1559 | 1407 passed | 131 failed | 21 failed as expected +assertions: 1557 | 1405 passed | 131 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index 6ab478be..3bd3a759 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -7783,24 +7783,6 @@ String.tests.cpp:: PASSED: with expansion: 17 == 17 -------------------------------------------------------------------------------- -StringRef - to std::string - implicitly 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 @@ -12462,5 +12444,5 @@ Misc.tests.cpp:: PASSED: =============================================================================== test cases: 300 | 210 passed | 86 failed | 4 failed as expected -assertions: 1576 | 1407 passed | 148 failed | 21 failed as expected +assertions: 1574 | 1405 passed | 148 failed | 21 failed as expected diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index 11930e67..c3cf2d6f 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -1,7 +1,7 @@ - + @@ -726,7 +726,6 @@ Matchers.tests.cpp: - diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index 939bd6bf..de3b7657 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -9601,28 +9601,6 @@ Message from section two -
-
- - - stdStr == "a stringref" - - - "a stringref" == "a stringref" - - - - - stdStr.size() == sr.size() - - - 11 == 11 - - - -
- -
@@ -14834,7 +14812,7 @@ loose text artifact
- + - + diff --git a/projects/SelfTest/IntrospectiveTests/String.tests.cpp b/projects/SelfTest/IntrospectiveTests/String.tests.cpp index 6a888f90..77c16dcb 100644 --- a/projects/SelfTest/IntrospectiveTests/String.tests.cpp +++ b/projects/SelfTest/IntrospectiveTests/String.tests.cpp @@ -142,11 +142,6 @@ TEST_CASE( "StringRef", "[Strings][StringRef]" ) { SECTION( "to std::string" ) { StringRef sr = "a stringref"; - SECTION( "implicitly constructed" ) { - std::string stdStr = sr; - REQUIRE( stdStr == "a stringref" ); - REQUIRE( stdStr.size() == sr.size() ); - } SECTION( "explicitly constructed" ) { std::string stdStr( sr ); REQUIRE( stdStr == "a stringref" ); @@ -154,7 +149,7 @@ TEST_CASE( "StringRef", "[Strings][StringRef]" ) { } SECTION( "assigned" ) { std::string stdStr; - stdStr = sr; + stdStr = static_cast(sr); REQUIRE( stdStr == "a stringref" ); REQUIRE( stdStr.size() == sr.size() ); }