mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
StringRef will not take ownership when writing itself to stream
This also fixes some tests that were previously failing unnoticed - WTF?
This commit is contained in:
parent
5a8f9c84dd
commit
4e57661919
@ -112,7 +112,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto operator << ( std::ostream& os, StringRef const& str ) -> std::ostream& {
|
auto operator << ( std::ostream& os, StringRef const& str ) -> std::ostream& {
|
||||||
return os << str.c_str();
|
return os.write(str.m_start, str.m_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Catch
|
} // namespace Catch
|
||||||
|
@ -84,6 +84,8 @@ namespace Catch {
|
|||||||
|
|
||||||
void swap( StringRef& other ) noexcept;
|
void swap( StringRef& other ) noexcept;
|
||||||
|
|
||||||
|
friend auto operator << (std::ostream& os, StringRef const& sr)->std::ostream&;
|
||||||
|
|
||||||
public: // operators
|
public: // operators
|
||||||
auto operator == ( StringRef const& other ) const noexcept -> bool;
|
auto operator == ( StringRef const& other ) const noexcept -> bool;
|
||||||
auto operator != ( StringRef const& other ) const noexcept -> bool;
|
auto operator != ( StringRef const& other ) const noexcept -> bool;
|
||||||
@ -114,7 +116,6 @@ namespace Catch {
|
|||||||
auto operator + ( StringRef const& lhs, char const* rhs ) -> std::string;
|
auto operator + ( StringRef const& lhs, char const* rhs ) -> std::string;
|
||||||
auto operator + ( char const* lhs, StringRef const& rhs ) -> std::string;
|
auto operator + ( char const* lhs, StringRef const& rhs ) -> std::string;
|
||||||
|
|
||||||
auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&;
|
|
||||||
|
|
||||||
inline auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef {
|
inline auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef {
|
||||||
return StringRef( rawChars, size );
|
return StringRef( rawChars, size );
|
||||||
|
@ -627,7 +627,10 @@ String.tests.cpp:<line number>: passed: isOwned( s ) == false for: false == fals
|
|||||||
String.tests.cpp:<line number>: passed: s.c_str() == rawChars for: "hello" == "hello"
|
String.tests.cpp:<line number>: passed: s.c_str() == rawChars for: "hello" == "hello"
|
||||||
String.tests.cpp:<line number>: passed: isOwned( s ) == false for: false == false
|
String.tests.cpp:<line number>: passed: isOwned( s ) == false for: false == false
|
||||||
String.tests.cpp:<line number>: passed: original == "original"
|
String.tests.cpp:<line number>: passed: original == "original"
|
||||||
String.tests.cpp:<line number>: failed: isSubstring( original ) for: false
|
String.tests.cpp:<line number>: passed: isSubstring( original ) for: true
|
||||||
|
String.tests.cpp:<line number>: passed: isOwned( original ) == false for: false == false
|
||||||
|
String.tests.cpp:<line number>: passed: isSubstring( original ) == false for: false == false
|
||||||
|
String.tests.cpp:<line number>: passed: isOwned( original ) for: true
|
||||||
String.tests.cpp:<line number>: passed: ss.empty() == false for: false == false
|
String.tests.cpp:<line number>: passed: ss.empty() == false for: false == false
|
||||||
String.tests.cpp:<line number>: passed: ss.size() == 5 for: 5 == 5
|
String.tests.cpp:<line number>: passed: ss.size() == 5 for: 5 == 5
|
||||||
String.tests.cpp:<line number>: passed: std::strcmp( ss.c_str(), "hello" ) == 0 for: 0 == 0
|
String.tests.cpp:<line number>: passed: std::strcmp( ss.c_str(), "hello" ) == 0 for: 0 == 0
|
||||||
@ -1077,5 +1080,5 @@ Misc.tests.cpp:<line number>: passed: v.size() == 5 for: 5 == 5
|
|||||||
Misc.tests.cpp:<line number>: passed: v.capacity() >= 5 for: 5 >= 5
|
Misc.tests.cpp:<line number>: passed: v.capacity() >= 5 for: 5 >= 5
|
||||||
Misc.tests.cpp:<line number>: passed:
|
Misc.tests.cpp:<line number>: passed:
|
||||||
Misc.tests.cpp:<line number>: passed:
|
Misc.tests.cpp:<line number>: passed:
|
||||||
Failed 63 test cases, failed 122 assertions.
|
Failed 62 test cases, failed 121 assertions.
|
||||||
|
|
||||||
|
@ -4998,10 +4998,29 @@ String.tests.cpp:<line number>:
|
|||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE( original == "original" )
|
REQUIRE( original == "original" )
|
||||||
|
|
||||||
String.tests.cpp:<line number>: FAILED:
|
String.tests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
REQUIRE( isSubstring( original ) )
|
REQUIRE( isSubstring( original ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
false
|
true
|
||||||
|
|
||||||
|
String.tests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( isOwned( original ) == false )
|
||||||
|
with expansion:
|
||||||
|
false == false
|
||||||
|
|
||||||
|
String.tests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( isSubstring( original ) == false )
|
||||||
|
with expansion:
|
||||||
|
false == false
|
||||||
|
|
||||||
|
String.tests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( isOwned( original ) )
|
||||||
|
with expansion:
|
||||||
|
true
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
StringRef
|
StringRef
|
||||||
@ -8531,6 +8550,6 @@ Misc.tests.cpp:<line number>:
|
|||||||
PASSED:
|
PASSED:
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
test cases: 202 | 135 passed | 63 failed | 4 failed as expected
|
test cases: 202 | 136 passed | 62 failed | 4 failed as expected
|
||||||
assertions: 1018 | 875 passed | 122 failed | 21 failed as expected
|
assertions: 1021 | 879 passed | 121 failed | 21 failed as expected
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<testsuitesloose text artifact
|
<testsuitesloose text artifact
|
||||||
>
|
>
|
||||||
<testsuite name="<exe-name>" errors="17" failures="106" tests="1019" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
<testsuite name="<exe-name>" errors="17" failures="105" tests="1022" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||||
<testcase classname="<exe-name>.global" name="# A test name that starts with a #" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="# A test name that starts with a #" time="{duration}"/>
|
||||||
<testcase classname="<exe-name>.global" name="#1005: Comparing pointer to int and long (NULL can be either on various systems)" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="#1005: Comparing pointer to int and long (NULL can be either on various systems)" time="{duration}"/>
|
||||||
<testcase classname="<exe-name>.global" name="#1027" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="#1027" time="{duration}"/>
|
||||||
@ -546,11 +546,7 @@ Matchers.tests.cpp:<line number>
|
|||||||
<testcase classname="<exe-name>.global" name="StringRef/Empty string" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="StringRef/Empty string" time="{duration}"/>
|
||||||
<testcase classname="<exe-name>.global" name="StringRef/From string literal" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="StringRef/From string literal" time="{duration}"/>
|
||||||
<testcase classname="<exe-name>.global" name="StringRef/From string literal/c_str() does not cause copy" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="StringRef/From string literal/c_str() does not cause copy" time="{duration}"/>
|
||||||
<testcase classname="<exe-name>.global" name="StringRef/From sub-string" time="{duration}">
|
<testcase classname="<exe-name>.global" name="StringRef/From sub-string" time="{duration}"/>
|
||||||
<failure message="false" type="REQUIRE">
|
|
||||||
String.tests.cpp:<line number>
|
|
||||||
</failure>
|
|
||||||
</testcase>
|
|
||||||
<testcase classname="<exe-name>.global" name="StringRef/Substrings/zero-based substring" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="StringRef/Substrings/zero-based substring" time="{duration}"/>
|
||||||
<testcase classname="<exe-name>.global" name="StringRef/Substrings/c_str() causes copy" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="StringRef/Substrings/c_str() causes copy" time="{duration}"/>
|
||||||
<testcase classname="<exe-name>.global" name="StringRef/Substrings/non-zero-based substring" time="{duration}"/>
|
<testcase classname="<exe-name>.global" name="StringRef/Substrings/non-zero-based substring" time="{duration}"/>
|
||||||
|
@ -5716,15 +5716,39 @@ Message from section two
|
|||||||
original == "original"
|
original == "original"
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
<Expression success="false" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
isSubstring( original )
|
isSubstring( original )
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
false
|
true
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
<OverallResults successes="1" failures="1" expectedFailures="0"/>
|
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
|
||||||
|
<Original>
|
||||||
|
isOwned( original ) == false
|
||||||
|
</Original>
|
||||||
|
<Expanded>
|
||||||
|
false == false
|
||||||
|
</Expanded>
|
||||||
|
</Expression>
|
||||||
|
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
|
||||||
|
<Original>
|
||||||
|
isSubstring( original ) == false
|
||||||
|
</Original>
|
||||||
|
<Expanded>
|
||||||
|
false == false
|
||||||
|
</Expanded>
|
||||||
|
</Expression>
|
||||||
|
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
|
||||||
|
<Original>
|
||||||
|
isOwned( original )
|
||||||
|
</Original>
|
||||||
|
<Expanded>
|
||||||
|
true
|
||||||
|
</Expanded>
|
||||||
|
</Expression>
|
||||||
|
<OverallResults successes="5" failures="0" expectedFailures="0"/>
|
||||||
</Section>
|
</Section>
|
||||||
<Section name="Substrings" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
|
<Section name="Substrings" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
|
||||||
<Section name="zero-based substring" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
|
<Section name="zero-based substring" filename="projects/<exe-name>/IntrospectiveTests/String.tests.cpp" >
|
||||||
@ -6054,7 +6078,7 @@ Message from section two
|
|||||||
</Expression>
|
</Expression>
|
||||||
<OverallResults successes="3" failures="0" expectedFailures="0"/>
|
<OverallResults successes="3" failures="0" expectedFailures="0"/>
|
||||||
</Section>
|
</Section>
|
||||||
<OverallResult success="false"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<TestCase name="Stringifying std::chrono::duration helpers" tags="[chrono][toString]" filename="projects/<exe-name>/UsageTests/ToStringChrono.tests.cpp" >
|
<TestCase name="Stringifying std::chrono::duration helpers" tags="[chrono][toString]" filename="projects/<exe-name>/UsageTests/ToStringChrono.tests.cpp" >
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/ToStringChrono.tests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/ToStringChrono.tests.cpp" >
|
||||||
@ -9381,7 +9405,7 @@ loose text artifact
|
|||||||
</Section>
|
</Section>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<OverallResults successes="875" failures="123" expectedFailures="21"/>
|
<OverallResults successes="879" failures="122" expectedFailures="21"/>
|
||||||
</Group>
|
</Group>
|
||||||
<OverallResults successes="875" failures="122" expectedFailures="21"/>
|
<OverallResults successes="879" failures="121" expectedFailures="21"/>
|
||||||
</Catch>
|
</Catch>
|
||||||
|
Loading…
Reference in New Issue
Block a user