mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-25 23:06:10 +01:00
Added << ostream overload to StringRef
This commit is contained in:
parent
bb8c1fb17f
commit
fa3535e95e
@ -173,7 +173,7 @@ namespace Catch {
|
||||
return StringRef( lhs ) + rhs;
|
||||
}
|
||||
|
||||
std::ostream& operator << ( std::ostream& os, StringRef const& str ) {
|
||||
auto operator << ( std::ostream& os, StringRef const& str ) -> std::ostream& {
|
||||
return os << str.c_str();
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <iosfwd>
|
||||
|
||||
namespace Catch {
|
||||
|
||||
@ -76,7 +77,9 @@ namespace Catch {
|
||||
auto operator + ( StringRef const& lhs, StringRef const& rhs ) -> String;
|
||||
auto operator + ( StringRef const& lhs, char const* rhs ) -> String;
|
||||
auto operator + ( char const* lhs, StringRef const& rhs ) -> String;
|
||||
|
||||
|
||||
auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&;
|
||||
|
||||
} // namespace Catch
|
||||
|
||||
#endif // CATCH_STRINGREF_H_INCLUDED
|
||||
|
@ -4378,7 +4378,7 @@ StringBuilder.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( s == "hello" )
|
||||
with expansion:
|
||||
{?} == "hello"
|
||||
hello == "hello"
|
||||
|
||||
StringBuilder.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
@ -4397,7 +4397,7 @@ StringBuilder.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( s == "hello world" )
|
||||
with expansion:
|
||||
{?} == "hello world"
|
||||
hello world == "hello world"
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
StringBuilder
|
||||
@ -4410,7 +4410,7 @@ StringBuilder.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( s == "hello world" )
|
||||
with expansion:
|
||||
{?} == "hello world"
|
||||
hello world == "hello world"
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
StringBuilder
|
||||
@ -4435,7 +4435,7 @@ StringBuilder.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( s == "hello world" )
|
||||
with expansion:
|
||||
{?} == "hello world"
|
||||
hello world == "hello world"
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
StringBuilder
|
||||
@ -4449,7 +4449,7 @@ StringBuilder.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( s2 == s )
|
||||
with expansion:
|
||||
{?} == {?}
|
||||
hello == hello
|
||||
|
||||
StringBuilder.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
@ -4469,7 +4469,7 @@ StringBuilder.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( s2 == "hello" )
|
||||
with expansion:
|
||||
{?} == "hello"
|
||||
hello == "hello"
|
||||
|
||||
StringBuilder.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
@ -4489,7 +4489,7 @@ StringBuilder.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( s2 == "hello" )
|
||||
with expansion:
|
||||
{?} == "hello"
|
||||
hello == "hello"
|
||||
|
||||
StringBuilder.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
@ -4589,32 +4589,11 @@ StringRef.tests.cpp:<line number>
|
||||
StringRef.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( original == "original" )
|
||||
with expansion:
|
||||
{?} == "original"
|
||||
|
||||
StringRef.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
StringRef.tests.cpp:<line number>: FAILED:
|
||||
REQUIRE( isSubstring( original ) )
|
||||
with expansion:
|
||||
true
|
||||
|
||||
StringRef.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( isOwned( original ) == false )
|
||||
with expansion:
|
||||
false == false
|
||||
|
||||
StringRef.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( isSubstring( original ) == false )
|
||||
with expansion:
|
||||
false == false
|
||||
|
||||
StringRef.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( isOwned( original ) )
|
||||
with expansion:
|
||||
true
|
||||
false
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
StringRef
|
||||
@ -4646,7 +4625,7 @@ StringRef.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( ss == "hello" )
|
||||
with expansion:
|
||||
{?} == "hello"
|
||||
hello == "hello"
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
StringRef
|
||||
@ -4757,13 +4736,13 @@ StringRef.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( StringRef("hello") == StringRef("hello") )
|
||||
with expansion:
|
||||
{?} == {?}
|
||||
hello == hello
|
||||
|
||||
StringRef.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( StringRef("hello") != StringRef("cello") )
|
||||
with expansion:
|
||||
{?} != {?}
|
||||
hello != cello
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
StringRef
|
||||
@ -4777,13 +4756,13 @@ StringRef.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( copied == "hot potato" )
|
||||
with expansion:
|
||||
{?} == "hot potato"
|
||||
hot potato == "hot potato"
|
||||
|
||||
StringRef.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( str == "hot potato" )
|
||||
with expansion:
|
||||
{?} == "hot potato"
|
||||
hot potato == "hot potato"
|
||||
|
||||
StringRef.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
@ -4809,7 +4788,7 @@ StringRef.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( copied == "hot potato" )
|
||||
with expansion:
|
||||
{?} == "hot potato"
|
||||
hot potato == "hot potato"
|
||||
|
||||
StringRef.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
@ -4841,7 +4820,7 @@ StringRef.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( sr == "a standard string" )
|
||||
with expansion:
|
||||
{?} == "a standard string"
|
||||
a standard string == "a standard string"
|
||||
|
||||
StringRef.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
@ -4861,7 +4840,7 @@ StringRef.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( sr == "a standard string" )
|
||||
with expansion:
|
||||
{?} == "a standard string"
|
||||
a standard string == "a standard string"
|
||||
|
||||
StringRef.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
@ -4881,7 +4860,7 @@ StringRef.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( sr == "a standard string" )
|
||||
with expansion:
|
||||
{?} == "a standard string"
|
||||
a standard string == "a standard string"
|
||||
|
||||
StringRef.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
@ -7758,6 +7737,6 @@ MiscTests.cpp:<line number>:
|
||||
PASSED:
|
||||
|
||||
===============================================================================
|
||||
test cases: 183 | 130 passed | 49 failed | 4 failed as expected
|
||||
assertions: 913 | 791 passed | 101 failed | 21 failed as expected
|
||||
test cases: 183 | 129 passed | 50 failed | 4 failed as expected
|
||||
assertions: 910 | 787 passed | 102 failed | 21 failed as expected
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<testsuitesloose text artifact
|
||||
>
|
||||
<testsuite name="<exe-name>" errors="15" failures="87" tests="914" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<testsuite name="<exe-name>" errors="15" failures="88" tests="911" 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="#748 - captures with unexpected exceptions/outside assertions" time="{duration}">
|
||||
<error type="TEST_CASE">
|
||||
@ -518,7 +518,11 @@ MatchersTests.cpp:<line number>
|
||||
<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/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">
|
||||
StringRef.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/c_str() causes copy" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="StringRef/Substrings/non-zero-based substring" time="{duration}"/>
|
||||
|
@ -4999,7 +4999,7 @@ Message from section two
|
||||
s == "hello"
|
||||
</Original>
|
||||
<Expanded>
|
||||
{?} == "hello"
|
||||
hello == "hello"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
||||
@ -5018,7 +5018,7 @@ Message from section two
|
||||
s == "hello world"
|
||||
</Original>
|
||||
<Expanded>
|
||||
{?} == "hello world"
|
||||
hello world == "hello world"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||
@ -5029,7 +5029,7 @@ Message from section two
|
||||
s == "hello world"
|
||||
</Original>
|
||||
<Expanded>
|
||||
{?} == "hello world"
|
||||
hello world == "hello world"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||
@ -5056,7 +5056,7 @@ Message from section two
|
||||
s == "hello world"
|
||||
</Original>
|
||||
<Expanded>
|
||||
{?} == "hello world"
|
||||
hello world == "hello world"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="3" failures="0" expectedFailures="0"/>
|
||||
@ -5068,7 +5068,7 @@ Message from section two
|
||||
s2 == s
|
||||
</Original>
|
||||
<Expanded>
|
||||
{?} == {?}
|
||||
hello == hello
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
||||
@ -5090,7 +5090,7 @@ Message from section two
|
||||
s2 == "hello"
|
||||
</Original>
|
||||
<Expanded>
|
||||
{?} == "hello"
|
||||
hello == "hello"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
||||
@ -5112,7 +5112,7 @@ Message from section two
|
||||
s2 == "hello"
|
||||
</Original>
|
||||
<Expanded>
|
||||
{?} == "hello"
|
||||
hello == "hello"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringBuilder.tests.cpp" >
|
||||
@ -5225,42 +5225,18 @@ Message from section two
|
||||
original == "original"
|
||||
</Original>
|
||||
<Expanded>
|
||||
{?} == "original"
|
||||
original == "original"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
||||
<Expression success="false" type="REQUIRE" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
||||
<Original>
|
||||
isSubstring( original )
|
||||
</Original>
|
||||
<Expanded>
|
||||
true
|
||||
false
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
||||
<Original>
|
||||
isOwned( original ) == false
|
||||
</Original>
|
||||
<Expanded>
|
||||
false == false
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
||||
<Original>
|
||||
isSubstring( original ) == false
|
||||
</Original>
|
||||
<Expanded>
|
||||
false == false
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
||||
<Original>
|
||||
isOwned( original )
|
||||
</Original>
|
||||
<Expanded>
|
||||
true
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="5" failures="0" expectedFailures="0"/>
|
||||
<OverallResults successes="1" failures="1" expectedFailures="0"/>
|
||||
</Section>
|
||||
<Section name="Substrings" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
||||
<Section name="zero-based substring" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
||||
@ -5293,7 +5269,7 @@ Message from section two
|
||||
ss == "hello"
|
||||
</Original>
|
||||
<Expanded>
|
||||
{?} == "hello"
|
||||
hello == "hello"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="4" failures="0" expectedFailures="0"/>
|
||||
@ -5418,7 +5394,7 @@ Message from section two
|
||||
StringRef("hello") == StringRef("hello")
|
||||
</Original>
|
||||
<Expanded>
|
||||
{?} == {?}
|
||||
hello == hello
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
||||
@ -5426,7 +5402,7 @@ Message from section two
|
||||
StringRef("hello") != StringRef("cello")
|
||||
</Original>
|
||||
<Expanded>
|
||||
{?} != {?}
|
||||
hello != cello
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResults successes="2" failures="0" expectedFailures="0"/>
|
||||
@ -5438,7 +5414,7 @@ Message from section two
|
||||
copied == "hot potato"
|
||||
</Original>
|
||||
<Expanded>
|
||||
{?} == "hot potato"
|
||||
hot potato == "hot potato"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
||||
@ -5446,7 +5422,7 @@ Message from section two
|
||||
str == "hot potato"
|
||||
</Original>
|
||||
<Expanded>
|
||||
{?} == "hot potato"
|
||||
hot potato == "hot potato"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
||||
@ -5476,7 +5452,7 @@ Message from section two
|
||||
copied == "hot potato"
|
||||
</Original>
|
||||
<Expanded>
|
||||
{?} == "hot potato"
|
||||
hot potato == "hot potato"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
||||
@ -5514,7 +5490,7 @@ Message from section two
|
||||
sr == "a standard string"
|
||||
</Original>
|
||||
<Expanded>
|
||||
{?} == "a standard string"
|
||||
a standard string == "a standard string"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
||||
@ -5536,7 +5512,7 @@ Message from section two
|
||||
sr == "a standard string"
|
||||
</Original>
|
||||
<Expanded>
|
||||
{?} == "a standard string"
|
||||
a standard string == "a standard string"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
||||
@ -5558,7 +5534,7 @@ Message from section two
|
||||
sr == "a standard string"
|
||||
</Original>
|
||||
<Expanded>
|
||||
{?} == "a standard string"
|
||||
a standard string == "a standard string"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/StringRef.tests.cpp" >
|
||||
@ -5639,7 +5615,7 @@ Message from section two
|
||||
</Section>
|
||||
<OverallResults successes="2" failures="0" expectedFailures="0"/>
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
<OverallResult success="false"/>
|
||||
</TestCase>
|
||||
<TestCase name="Tabs and newlines show in output" tags="[.][failing][hide][whitespace]" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Expression success="false" type="CHECK" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
@ -8592,7 +8568,7 @@ loose text artifact
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<OverallResults successes="791" failures="102" expectedFailures="21"/>
|
||||
<OverallResults successes="787" failures="103" expectedFailures="21"/>
|
||||
</Group>
|
||||
<OverallResults successes="791" failures="101" expectedFailures="21"/>
|
||||
<OverallResults successes="787" failures="102" expectedFailures="21"/>
|
||||
</Catch>
|
||||
|
Loading…
Reference in New Issue
Block a user