mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-25 14:56:10 +01:00
Moved matchers tests into their own file
This commit is contained in:
parent
1ca8cefa9a
commit
4e6938d78e
@ -70,6 +70,7 @@ set(TEST_SOURCES
|
||||
${SELF_TEST_DIR}/ToStringWhich.cpp
|
||||
${SELF_TEST_DIR}/TrickyTests.cpp
|
||||
${SELF_TEST_DIR}/VariadicMacrosTests.cpp
|
||||
${SELF_TEST_DIR}/MatchersTests.cpp
|
||||
)
|
||||
CheckFileList(TEST_SOURCES ${SELF_TEST_DIR})
|
||||
|
||||
|
@ -105,10 +105,10 @@ due to unexpected exception with message:
|
||||
-------------------------------------------------------------------------------
|
||||
Contains string matcher
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>: FAILED:
|
||||
MatchersTests.cpp:<line number>: FAILED:
|
||||
CHECK_THAT( testStringForMatching(), Contains( "not there" ) )
|
||||
with expansion:
|
||||
"this string contains 'abc' as a substring" contains: "not there"
|
||||
@ -148,10 +148,10 @@ due to unexpected exception with message:
|
||||
-------------------------------------------------------------------------------
|
||||
EndsWith string matcher
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>: FAILED:
|
||||
MatchersTests.cpp:<line number>: FAILED:
|
||||
CHECK_THAT( testStringForMatching(), EndsWith( "this" ) )
|
||||
with expansion:
|
||||
"this string contains 'abc' as a substring" ends with: "this"
|
||||
@ -230,10 +230,10 @@ with expansion:
|
||||
-------------------------------------------------------------------------------
|
||||
Equals string matcher
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>: FAILED:
|
||||
MatchersTests.cpp:<line number>: FAILED:
|
||||
CHECK_THAT( testStringForMatching(), Equals( "something else" ) )
|
||||
with expansion:
|
||||
"this string contains 'abc' as a substring" equals: "something else"
|
||||
@ -355,10 +355,10 @@ with expansion:
|
||||
-------------------------------------------------------------------------------
|
||||
Matchers can be composed with both && and || - failing
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>: FAILED:
|
||||
MatchersTests.cpp:<line number>: FAILED:
|
||||
CHECK_THAT( testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "random" ) )
|
||||
with expansion:
|
||||
"this string contains 'abc' as a substring" ( ( contains: "string" or
|
||||
@ -367,10 +367,10 @@ with expansion:
|
||||
-------------------------------------------------------------------------------
|
||||
Matchers can be negated (Not) with the ! operator - failing
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>: FAILED:
|
||||
MatchersTests.cpp:<line number>: FAILED:
|
||||
CHECK_THAT( testStringForMatching(), !Contains( "substring" ) )
|
||||
with expansion:
|
||||
"this string contains 'abc' as a substring" not contains: "substring"
|
||||
@ -564,10 +564,10 @@ Message from section two
|
||||
-------------------------------------------------------------------------------
|
||||
StartsWith string matcher
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>: FAILED:
|
||||
MatchersTests.cpp:<line number>: FAILED:
|
||||
CHECK_THAT( testStringForMatching(), StartsWith( "string" ) )
|
||||
with expansion:
|
||||
"this string contains 'abc' as a substring" starts with: "string"
|
||||
|
@ -307,10 +307,10 @@ with expansion:
|
||||
-------------------------------------------------------------------------------
|
||||
AllOf matcher
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
MatchersTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THAT( testStringForMatching(), AllOf( Catch::Contains( "string" ), Catch::Contains( "abc" ) ) )
|
||||
with expansion:
|
||||
@ -364,17 +364,17 @@ with message:
|
||||
-------------------------------------------------------------------------------
|
||||
AnyOf matcher
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
MatchersTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THAT( testStringForMatching(), AnyOf( Catch::Contains( "string" ), Catch::Contains( "not there" ) ) )
|
||||
with expansion:
|
||||
"this string contains 'abc' as a substring" ( contains: "string" or contains:
|
||||
"not there" )
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
MatchersTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THAT( testStringForMatching(), AnyOf( Catch::Contains( "not there" ), Catch::Contains( "string" ) ) )
|
||||
with expansion:
|
||||
@ -848,10 +848,10 @@ with expansion:
|
||||
-------------------------------------------------------------------------------
|
||||
Contains string matcher
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>: FAILED:
|
||||
MatchersTests.cpp:<line number>: FAILED:
|
||||
CHECK_THAT( testStringForMatching(), Contains( "not there" ) )
|
||||
with expansion:
|
||||
"this string contains 'abc' as a substring" contains: "not there"
|
||||
@ -903,10 +903,10 @@ with expansion:
|
||||
-------------------------------------------------------------------------------
|
||||
EndsWith string matcher
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>: FAILED:
|
||||
MatchersTests.cpp:<line number>: FAILED:
|
||||
CHECK_THAT( testStringForMatching(), EndsWith( "this" ) )
|
||||
with expansion:
|
||||
"this string contains 'abc' as a substring" ends with: "this"
|
||||
@ -1033,10 +1033,10 @@ with expansion:
|
||||
-------------------------------------------------------------------------------
|
||||
Equals
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
MatchersTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THAT( testStringForMatching(), Equals( "this string contains 'abc' as a substring" ) )
|
||||
with expansion:
|
||||
@ -1046,10 +1046,10 @@ with expansion:
|
||||
-------------------------------------------------------------------------------
|
||||
Equals string matcher
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>: FAILED:
|
||||
MatchersTests.cpp:<line number>: FAILED:
|
||||
CHECK_THAT( testStringForMatching(), Equals( "something else" ) )
|
||||
with expansion:
|
||||
"this string contains 'abc' as a substring" equals: "something else"
|
||||
@ -4281,10 +4281,10 @@ with message:
|
||||
-------------------------------------------------------------------------------
|
||||
Matchers can be (AllOf) composed with the && operator
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
MatchersTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THAT( testStringForMatching(), Contains( "string" ) && Contains( "abc" ) && Contains( "substring" ) && Contains( "contains" ) )
|
||||
with expansion:
|
||||
@ -4294,17 +4294,17 @@ with expansion:
|
||||
-------------------------------------------------------------------------------
|
||||
Matchers can be (AnyOf) composed with the || operator
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
MatchersTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THAT( testStringForMatching(), Contains( "string" ) || Contains( "different" ) || Contains( "random" ) )
|
||||
with expansion:
|
||||
"this string contains 'abc' as a substring" ( contains: "string" or contains:
|
||||
"different" or contains: "random" )
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
MatchersTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THAT( testStringForMatching2(), Contains( "string" ) || Contains( "different" ) || Contains( "random" ) )
|
||||
with expansion:
|
||||
@ -4314,10 +4314,10 @@ with expansion:
|
||||
-------------------------------------------------------------------------------
|
||||
Matchers can be composed with both && and ||
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
MatchersTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THAT( testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "substring" ) )
|
||||
with expansion:
|
||||
@ -4327,10 +4327,10 @@ with expansion:
|
||||
-------------------------------------------------------------------------------
|
||||
Matchers can be composed with both && and || - failing
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>: FAILED:
|
||||
MatchersTests.cpp:<line number>: FAILED:
|
||||
CHECK_THAT( testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "random" ) )
|
||||
with expansion:
|
||||
"this string contains 'abc' as a substring" ( ( contains: "string" or
|
||||
@ -4339,10 +4339,10 @@ with expansion:
|
||||
-------------------------------------------------------------------------------
|
||||
Matchers can be negated (Not) with the ! operator
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
MatchersTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THAT( testStringForMatching(), !Contains( "different" ) )
|
||||
with expansion:
|
||||
@ -4351,10 +4351,10 @@ with expansion:
|
||||
-------------------------------------------------------------------------------
|
||||
Matchers can be negated (Not) with the ! operator - failing
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>: FAILED:
|
||||
MatchersTests.cpp:<line number>: FAILED:
|
||||
CHECK_THAT( testStringForMatching(), !Contains( "substring" ) )
|
||||
with expansion:
|
||||
"this string contains 'abc' as a substring" not contains: "substring"
|
||||
@ -6620,10 +6620,10 @@ No assertions in section 'two'
|
||||
-------------------------------------------------------------------------------
|
||||
StartsWith string matcher
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>: FAILED:
|
||||
MatchersTests.cpp:<line number>: FAILED:
|
||||
CHECK_THAT( testStringForMatching(), StartsWith( "string" ) )
|
||||
with expansion:
|
||||
"this string contains 'abc' as a substring" starts with: "string"
|
||||
@ -6631,28 +6631,28 @@ with expansion:
|
||||
-------------------------------------------------------------------------------
|
||||
String matchers
|
||||
-------------------------------------------------------------------------------
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
MatchersTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE_THAT( testStringForMatching(), Contains( "string" ) )
|
||||
with expansion:
|
||||
"this string contains 'abc' as a substring" contains: "string"
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
MatchersTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THAT( testStringForMatching(), Contains( "abc" ) )
|
||||
with expansion:
|
||||
"this string contains 'abc' as a substring" contains: "abc"
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
MatchersTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THAT( testStringForMatching(), StartsWith( "this" ) )
|
||||
with expansion:
|
||||
"this string contains 'abc' as a substring" starts with: "this"
|
||||
|
||||
MiscTests.cpp:<line number>:
|
||||
MatchersTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THAT( testStringForMatching(), EndsWith( "substring" ) )
|
||||
with expansion:
|
||||
|
@ -92,7 +92,7 @@ ExceptionTests.cpp:<line number>
|
||||
<testcase classname="global" name="Comparisons with int literals don't warn when mixing signed/ unsigned" time="{duration}"/>
|
||||
<testcase classname="global" name="Contains string matcher" time="{duration}">
|
||||
<failure message=""this string contains 'abc' as a substring" contains: "not there"" type="CHECK_THAT">
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
</failure>
|
||||
</testcase>
|
||||
<testcase classname="global" name="Custom exceptions can be translated when testing for nothrow" time="{duration}">
|
||||
@ -116,7 +116,7 @@ ExceptionTests.cpp:<line number>
|
||||
<testcase classname="global" name="Demonstrate that a non-const == is not used" time="{duration}"/>
|
||||
<testcase classname="global" name="EndsWith string matcher" time="{duration}">
|
||||
<failure message=""this string contains 'abc' as a substring" ends with: "this"" type="CHECK_THAT">
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
</failure>
|
||||
</testcase>
|
||||
<testcase classname="global" name="Equality checks that should fail" time="{duration}">
|
||||
@ -164,7 +164,7 @@ ConditionTests.cpp:<line number>
|
||||
<testcase classname="global" name="Equals" time="{duration}"/>
|
||||
<testcase classname="global" name="Equals string matcher" time="{duration}">
|
||||
<failure message=""this string contains 'abc' as a substring" equals: "something else"" type="CHECK_THAT">
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
</failure>
|
||||
</testcase>
|
||||
<testcase classname="Exception messages can be tested for" name="exact match" time="{duration}"/>
|
||||
@ -256,13 +256,13 @@ ConditionTests.cpp:<line number>
|
||||
<testcase classname="global" name="Matchers can be composed with both && and ||" time="{duration}"/>
|
||||
<testcase classname="global" name="Matchers can be composed with both && and || - failing" time="{duration}">
|
||||
<failure message=""this string contains 'abc' as a substring" ( ( contains: "string" or contains: "different" ) and contains: "random" )" type="CHECK_THAT">
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
</failure>
|
||||
</testcase>
|
||||
<testcase classname="global" name="Matchers can be negated (Not) with the ! operator" time="{duration}"/>
|
||||
<testcase classname="global" name="Matchers can be negated (Not) with the ! operator - failing" time="{duration}">
|
||||
<failure message=""this string contains 'abc' as a substring" not contains: "substring"" type="CHECK_THAT">
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
</failure>
|
||||
</testcase>
|
||||
<testcase classname="global" name="Mismatching exception messages failing the test" time="{duration}">
|
||||
@ -445,7 +445,7 @@ Message from section two
|
||||
</testcase>
|
||||
<testcase classname="global" name="StartsWith string matcher" time="{duration}">
|
||||
<failure message=""this string contains 'abc' as a substring" starts with: "string"" type="CHECK_THAT">
|
||||
MiscTests.cpp:<line number>
|
||||
MatchersTests.cpp:<line number>
|
||||
</failure>
|
||||
</testcase>
|
||||
<testcase classname="global" name="String matchers" time="{duration}"/>
|
||||
|
@ -341,8 +341,8 @@
|
||||
</Expression>
|
||||
<OverallResult success="false"/>
|
||||
</TestCase>
|
||||
<TestCase name="AllOf matcher" tags="[matchers]" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<TestCase name="AllOf matcher" tags="[matchers]" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Original>
|
||||
testStringForMatching(), AllOf( Catch::Contains( "string" ), Catch::Contains( "abc" ) )
|
||||
</Original>
|
||||
@ -399,8 +399,8 @@
|
||||
<TestCase name="Anonymous test case 1" filename="projects/<exe-name>/VariadicMacrosTests.cpp" >
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="AnyOf matcher" tags="[matchers]" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<TestCase name="AnyOf matcher" tags="[matchers]" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Original>
|
||||
testStringForMatching(), AnyOf( Catch::Contains( "string" ), Catch::Contains( "not there" ) )
|
||||
</Original>
|
||||
@ -408,7 +408,7 @@
|
||||
"this string contains 'abc' as a substring" ( contains: "string" or contains: "not there" )
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Original>
|
||||
testStringForMatching(), AnyOf( Catch::Contains( "not there" ), Catch::Contains( "string" ) )
|
||||
</Original>
|
||||
@ -927,8 +927,8 @@
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Contains string matcher" tags="[.][failing][hide][matchers]" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Expression success="false" type="CHECK_THAT" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<TestCase name="Contains string matcher" tags="[.][failing][hide][matchers]" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Expression success="false" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Original>
|
||||
testStringForMatching(), Contains( "not there" )
|
||||
</Original>
|
||||
@ -983,8 +983,8 @@
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="EndsWith string matcher" tags="[.][failing][hide][matchers]" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Expression success="false" type="CHECK_THAT" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<TestCase name="EndsWith string matcher" tags="[.][failing][hide][matchers]" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Expression success="false" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Original>
|
||||
testStringForMatching(), EndsWith( "this" )
|
||||
</Original>
|
||||
@ -1160,8 +1160,8 @@
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Equals" tags="[matchers]" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<TestCase name="Equals" tags="[matchers]" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Original>
|
||||
testStringForMatching(), Equals( "this string contains 'abc' as a substring" )
|
||||
</Original>
|
||||
@ -1171,8 +1171,8 @@
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Equals string matcher" tags="[.][failing][hide][matchers]" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Expression success="false" type="CHECK_THAT" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<TestCase name="Equals string matcher" tags="[.][failing][hide][matchers]" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Expression success="false" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Original>
|
||||
testStringForMatching(), Equals( "something else" )
|
||||
</Original>
|
||||
@ -4380,8 +4380,8 @@ re>"
|
||||
<TestCase name="ManuallyRegistered" filename="projects/<exe-name>/TestMain.cpp" >
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Matchers can be (AllOf) composed with the && operator" tags="[matchers][operator&&][operators]" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<TestCase name="Matchers can be (AllOf) composed with the && operator" tags="[matchers][operator&&][operators]" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Original>
|
||||
testStringForMatching(), Contains( "string" ) && Contains( "abc" ) && Contains( "substring" ) && Contains( "contains" )
|
||||
</Original>
|
||||
@ -4391,8 +4391,8 @@ re>"
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Matchers can be (AnyOf) composed with the || operator" tags="[matchers][operators][operator||]" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<TestCase name="Matchers can be (AnyOf) composed with the || operator" tags="[matchers][operators][operator||]" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Original>
|
||||
testStringForMatching(), Contains( "string" ) || Contains( "different" ) || Contains( "random" )
|
||||
</Original>
|
||||
@ -4400,7 +4400,7 @@ re>"
|
||||
"this string contains 'abc' as a substring" ( contains: "string" or contains: "different" or contains: "random" )
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Original>
|
||||
testStringForMatching2(), Contains( "string" ) || Contains( "different" ) || Contains( "random" )
|
||||
</Original>
|
||||
@ -4410,8 +4410,8 @@ re>"
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Matchers can be composed with both && and ||" tags="[matchers][operator&&][operators][operator||]" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<TestCase name="Matchers can be composed with both && and ||" tags="[matchers][operator&&][operators][operator||]" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Original>
|
||||
testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "substring" )
|
||||
</Original>
|
||||
@ -4421,8 +4421,8 @@ re>"
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Matchers can be composed with both && and || - failing" tags="[.][.failing][hide][matchers][operator&&][operators][operator||]" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Expression success="false" type="CHECK_THAT" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<TestCase name="Matchers can be composed with both && and || - failing" tags="[.][.failing][hide][matchers][operator&&][operators][operator||]" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Expression success="false" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Original>
|
||||
testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "random" )
|
||||
</Original>
|
||||
@ -4432,8 +4432,8 @@ re>"
|
||||
</Expression>
|
||||
<OverallResult success="false"/>
|
||||
</TestCase>
|
||||
<TestCase name="Matchers can be negated (Not) with the ! operator" tags="[matchers][not][operators]" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<TestCase name="Matchers can be negated (Not) with the ! operator" tags="[matchers][not][operators]" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Original>
|
||||
testStringForMatching(), !Contains( "different" )
|
||||
</Original>
|
||||
@ -4443,8 +4443,8 @@ re>"
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Matchers can be negated (Not) with the ! operator - failing" tags="[.][.failing][hide][matchers][not][operators]" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Expression success="false" type="CHECK_THAT" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<TestCase name="Matchers can be negated (Not) with the ! operator - failing" tags="[.][.failing][hide][matchers][not][operators]" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Expression success="false" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Original>
|
||||
testStringForMatching(), !Contains( "substring" )
|
||||
</Original>
|
||||
@ -7032,8 +7032,8 @@ Message from section two
|
||||
</StdOut>
|
||||
</OverallResult>
|
||||
</TestCase>
|
||||
<TestCase name="StartsWith string matcher" tags="[.][failing][hide][matchers]" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Expression success="false" type="CHECK_THAT" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<TestCase name="StartsWith string matcher" tags="[.][failing][hide][matchers]" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Expression success="false" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Original>
|
||||
testStringForMatching(), StartsWith( "string" )
|
||||
</Original>
|
||||
@ -7043,8 +7043,8 @@ Message from section two
|
||||
</Expression>
|
||||
<OverallResult success="false"/>
|
||||
</TestCase>
|
||||
<TestCase name="String matchers" tags="[matchers]" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<TestCase name="String matchers" tags="[matchers]" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Original>
|
||||
testStringForMatching(), Contains( "string" )
|
||||
</Original>
|
||||
@ -7052,7 +7052,7 @@ Message from section two
|
||||
"this string contains 'abc' as a substring" contains: "string"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Original>
|
||||
testStringForMatching(), Contains( "abc" )
|
||||
</Original>
|
||||
@ -7060,7 +7060,7 @@ Message from section two
|
||||
"this string contains 'abc' as a substring" contains: "abc"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Original>
|
||||
testStringForMatching(), StartsWith( "this" )
|
||||
</Original>
|
||||
@ -7068,7 +7068,7 @@ Message from section two
|
||||
"this string contains 'abc' as a substring" starts with: "this"
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||
<Original>
|
||||
testStringForMatching(), EndsWith( "substring" )
|
||||
</Original>
|
||||
|
99
projects/SelfTest/MatchersTests.cpp
Normal file
99
projects/SelfTest/MatchersTests.cpp
Normal file
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Created by Phil on 21/02/2017.
|
||||
* Copyright 2017 Two Blue Cubes Ltd. All rights reserved.
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
|
||||
#include "catch.hpp"
|
||||
|
||||
inline const char* testStringForMatching()
|
||||
{
|
||||
return "this string contains 'abc' as a substring";
|
||||
}
|
||||
inline const char* testStringForMatching2()
|
||||
{
|
||||
return "some completely different text that contains one common word";
|
||||
}
|
||||
|
||||
using namespace Catch::Matchers;
|
||||
|
||||
TEST_CASE("String matchers", "[matchers]" )
|
||||
{
|
||||
REQUIRE_THAT( testStringForMatching(), Contains( "string" ) );
|
||||
CHECK_THAT( testStringForMatching(), Contains( "abc" ) );
|
||||
|
||||
CHECK_THAT( testStringForMatching(), StartsWith( "this" ) );
|
||||
CHECK_THAT( testStringForMatching(), EndsWith( "substring" ) );
|
||||
}
|
||||
|
||||
TEST_CASE("Contains string matcher", "[.][failing][matchers]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(), Contains( "not there" ) );
|
||||
}
|
||||
|
||||
TEST_CASE("StartsWith string matcher", "[.][failing][matchers]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(), StartsWith( "string" ) );
|
||||
}
|
||||
|
||||
TEST_CASE("EndsWith string matcher", "[.][failing][matchers]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(), EndsWith( "this" ) );
|
||||
}
|
||||
|
||||
TEST_CASE("Equals string matcher", "[.][failing][matchers]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(), Equals( "something else" ) );
|
||||
}
|
||||
|
||||
TEST_CASE("AllOf matcher", "[matchers]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(), AllOf( Catch::Contains( "string" ), Catch::Contains( "abc" ) ) );
|
||||
}
|
||||
TEST_CASE("AnyOf matcher", "[matchers]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(), AnyOf( Catch::Contains( "string" ), Catch::Contains( "not there" ) ) );
|
||||
CHECK_THAT( testStringForMatching(), AnyOf( Catch::Contains( "not there" ), Catch::Contains( "string" ) ) );
|
||||
}
|
||||
|
||||
TEST_CASE("Equals", "[matchers]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(), Equals( "this string contains 'abc' as a substring" ) );
|
||||
}
|
||||
|
||||
TEST_CASE("Matchers can be (AllOf) composed with the && operator", "[matchers][operators][operator&&]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(),
|
||||
Contains( "string" ) &&
|
||||
Contains( "abc" ) &&
|
||||
Contains( "substring" ) &&
|
||||
Contains( "contains" ) );
|
||||
}
|
||||
|
||||
TEST_CASE("Matchers can be (AnyOf) composed with the || operator", "[matchers][operators][operator||]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(), Contains( "string" ) || Contains( "different" ) || Contains( "random" ) );
|
||||
CHECK_THAT( testStringForMatching2(), Contains( "string" ) || Contains( "different" ) || Contains( "random" ) );
|
||||
}
|
||||
|
||||
TEST_CASE("Matchers can be composed with both && and ||", "[matchers][operators][operator||][operator&&]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "substring" ) );
|
||||
}
|
||||
|
||||
TEST_CASE("Matchers can be composed with both && and || - failing", "[matchers][operators][operator||][operator&&][.failing]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "random" ) );
|
||||
}
|
||||
|
||||
TEST_CASE("Matchers can be negated (Not) with the ! operator", "[matchers][operators][not]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(), !Contains( "different" ) );
|
||||
}
|
||||
|
||||
TEST_CASE("Matchers can be negated (Not) with the ! operator - failing", "[matchers][operators][not][.failing]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(), !Contains( "substring" ) );
|
||||
}
|
@ -204,97 +204,6 @@ TEST_CASE( "atomic if", "[failing][0]")
|
||||
REQUIRE(x == 0);
|
||||
}
|
||||
|
||||
inline const char* testStringForMatching()
|
||||
{
|
||||
return "this string contains 'abc' as a substring";
|
||||
}
|
||||
inline const char* testStringForMatching2()
|
||||
{
|
||||
return "some completely different text that contains one common word";
|
||||
}
|
||||
|
||||
using namespace Catch::Matchers;
|
||||
|
||||
TEST_CASE("String matchers", "[matchers]" )
|
||||
{
|
||||
REQUIRE_THAT( testStringForMatching(), Contains( "string" ) );
|
||||
CHECK_THAT( testStringForMatching(), Contains( "abc" ) );
|
||||
|
||||
CHECK_THAT( testStringForMatching(), StartsWith( "this" ) );
|
||||
CHECK_THAT( testStringForMatching(), EndsWith( "substring" ) );
|
||||
}
|
||||
|
||||
TEST_CASE("Contains string matcher", "[.][failing][matchers]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(), Contains( "not there" ) );
|
||||
}
|
||||
|
||||
TEST_CASE("StartsWith string matcher", "[.][failing][matchers]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(), StartsWith( "string" ) );
|
||||
}
|
||||
|
||||
TEST_CASE("EndsWith string matcher", "[.][failing][matchers]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(), EndsWith( "this" ) );
|
||||
}
|
||||
|
||||
TEST_CASE("Equals string matcher", "[.][failing][matchers]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(), Equals( "something else" ) );
|
||||
}
|
||||
|
||||
TEST_CASE("AllOf matcher", "[matchers]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(), AllOf( Catch::Contains( "string" ), Catch::Contains( "abc" ) ) );
|
||||
}
|
||||
TEST_CASE("AnyOf matcher", "[matchers]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(), AnyOf( Catch::Contains( "string" ), Catch::Contains( "not there" ) ) );
|
||||
CHECK_THAT( testStringForMatching(), AnyOf( Catch::Contains( "not there" ), Catch::Contains( "string" ) ) );
|
||||
}
|
||||
|
||||
TEST_CASE("Equals", "[matchers]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(), Equals( "this string contains 'abc' as a substring" ) );
|
||||
}
|
||||
|
||||
TEST_CASE("Matchers can be (AllOf) composed with the && operator", "[matchers][operators][operator&&]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(),
|
||||
Contains( "string" ) &&
|
||||
Contains( "abc" ) &&
|
||||
Contains( "substring" ) &&
|
||||
Contains( "contains" ) );
|
||||
}
|
||||
|
||||
TEST_CASE("Matchers can be (AnyOf) composed with the || operator", "[matchers][operators][operator||]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(), Contains( "string" ) || Contains( "different" ) || Contains( "random" ) );
|
||||
CHECK_THAT( testStringForMatching2(), Contains( "string" ) || Contains( "different" ) || Contains( "random" ) );
|
||||
}
|
||||
|
||||
TEST_CASE("Matchers can be composed with both && and ||", "[matchers][operators][operator||][operator&&]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "substring" ) );
|
||||
}
|
||||
|
||||
TEST_CASE("Matchers can be composed with both && and || - failing", "[matchers][operators][operator||][operator&&][.failing]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "random" ) );
|
||||
}
|
||||
|
||||
TEST_CASE("Matchers can be negated (Not) with the ! operator", "[matchers][operators][not]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(), !Contains( "different" ) );
|
||||
}
|
||||
|
||||
TEST_CASE("Matchers can be negated (Not) with the ! operator - failing", "[matchers][operators][not][.failing]")
|
||||
{
|
||||
CHECK_THAT( testStringForMatching(), !Contains( "substring" ) );
|
||||
}
|
||||
|
||||
|
||||
inline unsigned int Factorial( unsigned int number )
|
||||
{
|
||||
// return number <= 1 ? number : Factorial(number-1)*number;
|
||||
|
Loading…
Reference in New Issue
Block a user