mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-29 08:43:30 +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}/ToStringWhich.cpp
|
||||||
${SELF_TEST_DIR}/TrickyTests.cpp
|
${SELF_TEST_DIR}/TrickyTests.cpp
|
||||||
${SELF_TEST_DIR}/VariadicMacrosTests.cpp
|
${SELF_TEST_DIR}/VariadicMacrosTests.cpp
|
||||||
|
${SELF_TEST_DIR}/MatchersTests.cpp
|
||||||
)
|
)
|
||||||
CheckFileList(TEST_SOURCES ${SELF_TEST_DIR})
|
CheckFileList(TEST_SOURCES ${SELF_TEST_DIR})
|
||||||
|
|
||||||
|
@ -105,10 +105,10 @@ due to unexpected exception with message:
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Contains string matcher
|
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" ) )
|
CHECK_THAT( testStringForMatching(), Contains( "not there" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" contains: "not there"
|
"this string contains 'abc' as a substring" contains: "not there"
|
||||||
@ -148,10 +148,10 @@ due to unexpected exception with message:
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
EndsWith string matcher
|
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" ) )
|
CHECK_THAT( testStringForMatching(), EndsWith( "this" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" ends with: "this"
|
"this string contains 'abc' as a substring" ends with: "this"
|
||||||
@ -230,10 +230,10 @@ with expansion:
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Equals string matcher
|
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" ) )
|
CHECK_THAT( testStringForMatching(), Equals( "something else" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" equals: "something else"
|
"this string contains 'abc' as a substring" equals: "something else"
|
||||||
@ -355,10 +355,10 @@ with expansion:
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Matchers can be composed with both && and || - failing
|
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" ) )
|
CHECK_THAT( testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "random" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" ( ( contains: "string" or
|
"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
|
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" ) )
|
CHECK_THAT( testStringForMatching(), !Contains( "substring" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" not contains: "substring"
|
"this string contains 'abc' as a substring" not contains: "substring"
|
||||||
@ -564,10 +564,10 @@ Message from section two
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
StartsWith string matcher
|
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" ) )
|
CHECK_THAT( testStringForMatching(), StartsWith( "string" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" starts with: "string"
|
"this string contains 'abc' as a substring" starts with: "string"
|
||||||
|
@ -307,10 +307,10 @@ with expansion:
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
AllOf matcher
|
AllOf matcher
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
MiscTests.cpp:<line number>
|
MatchersTests.cpp:<line number>
|
||||||
...............................................................................
|
...............................................................................
|
||||||
|
|
||||||
MiscTests.cpp:<line number>:
|
MatchersTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
CHECK_THAT( testStringForMatching(), AllOf( Catch::Contains( "string" ), Catch::Contains( "abc" ) ) )
|
CHECK_THAT( testStringForMatching(), AllOf( Catch::Contains( "string" ), Catch::Contains( "abc" ) ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
@ -364,17 +364,17 @@ with message:
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
AnyOf matcher
|
AnyOf matcher
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
MiscTests.cpp:<line number>
|
MatchersTests.cpp:<line number>
|
||||||
...............................................................................
|
...............................................................................
|
||||||
|
|
||||||
MiscTests.cpp:<line number>:
|
MatchersTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
CHECK_THAT( testStringForMatching(), AnyOf( Catch::Contains( "string" ), Catch::Contains( "not there" ) ) )
|
CHECK_THAT( testStringForMatching(), AnyOf( Catch::Contains( "string" ), Catch::Contains( "not there" ) ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" ( contains: "string" or contains:
|
"this string contains 'abc' as a substring" ( contains: "string" or contains:
|
||||||
"not there" )
|
"not there" )
|
||||||
|
|
||||||
MiscTests.cpp:<line number>:
|
MatchersTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
CHECK_THAT( testStringForMatching(), AnyOf( Catch::Contains( "not there" ), Catch::Contains( "string" ) ) )
|
CHECK_THAT( testStringForMatching(), AnyOf( Catch::Contains( "not there" ), Catch::Contains( "string" ) ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
@ -848,10 +848,10 @@ with expansion:
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Contains string matcher
|
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" ) )
|
CHECK_THAT( testStringForMatching(), Contains( "not there" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" contains: "not there"
|
"this string contains 'abc' as a substring" contains: "not there"
|
||||||
@ -903,10 +903,10 @@ with expansion:
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
EndsWith string matcher
|
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" ) )
|
CHECK_THAT( testStringForMatching(), EndsWith( "this" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" ends with: "this"
|
"this string contains 'abc' as a substring" ends with: "this"
|
||||||
@ -1033,10 +1033,10 @@ with expansion:
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Equals
|
Equals
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
MiscTests.cpp:<line number>
|
MatchersTests.cpp:<line number>
|
||||||
...............................................................................
|
...............................................................................
|
||||||
|
|
||||||
MiscTests.cpp:<line number>:
|
MatchersTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
CHECK_THAT( testStringForMatching(), Equals( "this string contains 'abc' as a substring" ) )
|
CHECK_THAT( testStringForMatching(), Equals( "this string contains 'abc' as a substring" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
@ -1046,10 +1046,10 @@ with expansion:
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Equals string matcher
|
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" ) )
|
CHECK_THAT( testStringForMatching(), Equals( "something else" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" equals: "something else"
|
"this string contains 'abc' as a substring" equals: "something else"
|
||||||
@ -4281,10 +4281,10 @@ with message:
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Matchers can be (AllOf) composed with the && operator
|
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:
|
PASSED:
|
||||||
CHECK_THAT( testStringForMatching(), Contains( "string" ) && Contains( "abc" ) && Contains( "substring" ) && Contains( "contains" ) )
|
CHECK_THAT( testStringForMatching(), Contains( "string" ) && Contains( "abc" ) && Contains( "substring" ) && Contains( "contains" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
@ -4294,17 +4294,17 @@ with expansion:
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Matchers can be (AnyOf) composed with the || operator
|
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:
|
PASSED:
|
||||||
CHECK_THAT( testStringForMatching(), Contains( "string" ) || Contains( "different" ) || Contains( "random" ) )
|
CHECK_THAT( testStringForMatching(), Contains( "string" ) || Contains( "different" ) || Contains( "random" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" ( contains: "string" or contains:
|
"this string contains 'abc' as a substring" ( contains: "string" or contains:
|
||||||
"different" or contains: "random" )
|
"different" or contains: "random" )
|
||||||
|
|
||||||
MiscTests.cpp:<line number>:
|
MatchersTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
CHECK_THAT( testStringForMatching2(), Contains( "string" ) || Contains( "different" ) || Contains( "random" ) )
|
CHECK_THAT( testStringForMatching2(), Contains( "string" ) || Contains( "different" ) || Contains( "random" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
@ -4314,10 +4314,10 @@ with expansion:
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Matchers can be composed with both && and ||
|
Matchers can be composed with both && and ||
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
MiscTests.cpp:<line number>
|
MatchersTests.cpp:<line number>
|
||||||
...............................................................................
|
...............................................................................
|
||||||
|
|
||||||
MiscTests.cpp:<line number>:
|
MatchersTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
CHECK_THAT( testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "substring" ) )
|
CHECK_THAT( testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "substring" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
@ -4327,10 +4327,10 @@ with expansion:
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Matchers can be composed with both && and || - failing
|
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" ) )
|
CHECK_THAT( testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "random" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" ( ( contains: "string" or
|
"this string contains 'abc' as a substring" ( ( contains: "string" or
|
||||||
@ -4339,10 +4339,10 @@ with expansion:
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Matchers can be negated (Not) with the ! operator
|
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:
|
PASSED:
|
||||||
CHECK_THAT( testStringForMatching(), !Contains( "different" ) )
|
CHECK_THAT( testStringForMatching(), !Contains( "different" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
@ -4351,10 +4351,10 @@ with expansion:
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Matchers can be negated (Not) with the ! operator - failing
|
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" ) )
|
CHECK_THAT( testStringForMatching(), !Contains( "substring" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" not contains: "substring"
|
"this string contains 'abc' as a substring" not contains: "substring"
|
||||||
@ -6620,10 +6620,10 @@ No assertions in section 'two'
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
StartsWith string matcher
|
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" ) )
|
CHECK_THAT( testStringForMatching(), StartsWith( "string" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" starts with: "string"
|
"this string contains 'abc' as a substring" starts with: "string"
|
||||||
@ -6631,28 +6631,28 @@ with expansion:
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
String matchers
|
String matchers
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
MiscTests.cpp:<line number>
|
MatchersTests.cpp:<line number>
|
||||||
...............................................................................
|
...............................................................................
|
||||||
|
|
||||||
MiscTests.cpp:<line number>:
|
MatchersTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE_THAT( testStringForMatching(), Contains( "string" ) )
|
REQUIRE_THAT( testStringForMatching(), Contains( "string" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" contains: "string"
|
"this string contains 'abc' as a substring" contains: "string"
|
||||||
|
|
||||||
MiscTests.cpp:<line number>:
|
MatchersTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
CHECK_THAT( testStringForMatching(), Contains( "abc" ) )
|
CHECK_THAT( testStringForMatching(), Contains( "abc" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" contains: "abc"
|
"this string contains 'abc' as a substring" contains: "abc"
|
||||||
|
|
||||||
MiscTests.cpp:<line number>:
|
MatchersTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
CHECK_THAT( testStringForMatching(), StartsWith( "this" ) )
|
CHECK_THAT( testStringForMatching(), StartsWith( "this" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" starts with: "this"
|
"this string contains 'abc' as a substring" starts with: "this"
|
||||||
|
|
||||||
MiscTests.cpp:<line number>:
|
MatchersTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
CHECK_THAT( testStringForMatching(), EndsWith( "substring" ) )
|
CHECK_THAT( testStringForMatching(), EndsWith( "substring" ) )
|
||||||
with expansion:
|
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="Comparisons with int literals don't warn when mixing signed/ unsigned" time="{duration}"/>
|
||||||
<testcase classname="global" name="Contains string matcher" 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">
|
<failure message=""this string contains 'abc' as a substring" contains: "not there"" type="CHECK_THAT">
|
||||||
MiscTests.cpp:<line number>
|
MatchersTests.cpp:<line number>
|
||||||
</failure>
|
</failure>
|
||||||
</testcase>
|
</testcase>
|
||||||
<testcase classname="global" name="Custom exceptions can be translated when testing for nothrow" time="{duration}">
|
<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="Demonstrate that a non-const == is not used" time="{duration}"/>
|
||||||
<testcase classname="global" name="EndsWith string matcher" 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">
|
<failure message=""this string contains 'abc' as a substring" ends with: "this"" type="CHECK_THAT">
|
||||||
MiscTests.cpp:<line number>
|
MatchersTests.cpp:<line number>
|
||||||
</failure>
|
</failure>
|
||||||
</testcase>
|
</testcase>
|
||||||
<testcase classname="global" name="Equality checks that should fail" time="{duration}">
|
<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" time="{duration}"/>
|
||||||
<testcase classname="global" name="Equals string matcher" 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">
|
<failure message=""this string contains 'abc' as a substring" equals: "something else"" type="CHECK_THAT">
|
||||||
MiscTests.cpp:<line number>
|
MatchersTests.cpp:<line number>
|
||||||
</failure>
|
</failure>
|
||||||
</testcase>
|
</testcase>
|
||||||
<testcase classname="Exception messages can be tested for" name="exact match" time="{duration}"/>
|
<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 ||" time="{duration}"/>
|
||||||
<testcase classname="global" name="Matchers can be composed with both && and || - failing" 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">
|
<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>
|
</failure>
|
||||||
</testcase>
|
</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" time="{duration}"/>
|
||||||
<testcase classname="global" name="Matchers can be negated (Not) with the ! operator - failing" 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">
|
<failure message=""this string contains 'abc' as a substring" not contains: "substring"" type="CHECK_THAT">
|
||||||
MiscTests.cpp:<line number>
|
MatchersTests.cpp:<line number>
|
||||||
</failure>
|
</failure>
|
||||||
</testcase>
|
</testcase>
|
||||||
<testcase classname="global" name="Mismatching exception messages failing the test" time="{duration}">
|
<testcase classname="global" name="Mismatching exception messages failing the test" time="{duration}">
|
||||||
@ -445,7 +445,7 @@ Message from section two
|
|||||||
</testcase>
|
</testcase>
|
||||||
<testcase classname="global" name="StartsWith string matcher" time="{duration}">
|
<testcase classname="global" name="StartsWith string matcher" time="{duration}">
|
||||||
<failure message=""this string contains 'abc' as a substring" starts with: "string"" type="CHECK_THAT">
|
<failure message=""this string contains 'abc' as a substring" starts with: "string"" type="CHECK_THAT">
|
||||||
MiscTests.cpp:<line number>
|
MatchersTests.cpp:<line number>
|
||||||
</failure>
|
</failure>
|
||||||
</testcase>
|
</testcase>
|
||||||
<testcase classname="global" name="String matchers" time="{duration}"/>
|
<testcase classname="global" name="String matchers" time="{duration}"/>
|
||||||
|
@ -341,8 +341,8 @@
|
|||||||
</Expression>
|
</Expression>
|
||||||
<OverallResult success="false"/>
|
<OverallResult success="false"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<TestCase name="AllOf matcher" tags="[matchers]" 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>/MiscTests.cpp" >
|
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
testStringForMatching(), AllOf( Catch::Contains( "string" ), Catch::Contains( "abc" ) )
|
testStringForMatching(), AllOf( Catch::Contains( "string" ), Catch::Contains( "abc" ) )
|
||||||
</Original>
|
</Original>
|
||||||
@ -399,8 +399,8 @@
|
|||||||
<TestCase name="Anonymous test case 1" filename="projects/<exe-name>/VariadicMacrosTests.cpp" >
|
<TestCase name="Anonymous test case 1" filename="projects/<exe-name>/VariadicMacrosTests.cpp" >
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<TestCase name="AnyOf matcher" tags="[matchers]" 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>/MiscTests.cpp" >
|
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
testStringForMatching(), AnyOf( Catch::Contains( "string" ), Catch::Contains( "not there" ) )
|
testStringForMatching(), AnyOf( Catch::Contains( "string" ), Catch::Contains( "not there" ) )
|
||||||
</Original>
|
</Original>
|
||||||
@ -408,7 +408,7 @@
|
|||||||
"this string contains 'abc' as a substring" ( contains: "string" or contains: "not there" )
|
"this string contains 'abc' as a substring" ( contains: "string" or contains: "not there" )
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</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>
|
<Original>
|
||||||
testStringForMatching(), AnyOf( Catch::Contains( "not there" ), Catch::Contains( "string" ) )
|
testStringForMatching(), AnyOf( Catch::Contains( "not there" ), Catch::Contains( "string" ) )
|
||||||
</Original>
|
</Original>
|
||||||
@ -927,8 +927,8 @@
|
|||||||
</Expression>
|
</Expression>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<TestCase name="Contains string matcher" tags="[.][failing][hide][matchers]" 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>/MiscTests.cpp" >
|
<Expression success="false" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
testStringForMatching(), Contains( "not there" )
|
testStringForMatching(), Contains( "not there" )
|
||||||
</Original>
|
</Original>
|
||||||
@ -983,8 +983,8 @@
|
|||||||
</Expression>
|
</Expression>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<TestCase name="EndsWith string matcher" tags="[.][failing][hide][matchers]" 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>/MiscTests.cpp" >
|
<Expression success="false" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
testStringForMatching(), EndsWith( "this" )
|
testStringForMatching(), EndsWith( "this" )
|
||||||
</Original>
|
</Original>
|
||||||
@ -1160,8 +1160,8 @@
|
|||||||
</Expression>
|
</Expression>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<TestCase name="Equals" tags="[matchers]" 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>/MiscTests.cpp" >
|
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
testStringForMatching(), Equals( "this string contains 'abc' as a substring" )
|
testStringForMatching(), Equals( "this string contains 'abc' as a substring" )
|
||||||
</Original>
|
</Original>
|
||||||
@ -1171,8 +1171,8 @@
|
|||||||
</Expression>
|
</Expression>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<TestCase name="Equals string matcher" tags="[.][failing][hide][matchers]" 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>/MiscTests.cpp" >
|
<Expression success="false" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
testStringForMatching(), Equals( "something else" )
|
testStringForMatching(), Equals( "something else" )
|
||||||
</Original>
|
</Original>
|
||||||
@ -4380,8 +4380,8 @@ re>"
|
|||||||
<TestCase name="ManuallyRegistered" filename="projects/<exe-name>/TestMain.cpp" >
|
<TestCase name="ManuallyRegistered" filename="projects/<exe-name>/TestMain.cpp" >
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<TestCase name="Matchers can be (AllOf) composed with the && operator" tags="[matchers][operator&&][operators]" 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>/MiscTests.cpp" >
|
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
testStringForMatching(), Contains( "string" ) && Contains( "abc" ) && Contains( "substring" ) && Contains( "contains" )
|
testStringForMatching(), Contains( "string" ) && Contains( "abc" ) && Contains( "substring" ) && Contains( "contains" )
|
||||||
</Original>
|
</Original>
|
||||||
@ -4391,8 +4391,8 @@ re>"
|
|||||||
</Expression>
|
</Expression>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<TestCase name="Matchers can be (AnyOf) composed with the || operator" tags="[matchers][operators][operator||]" 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>/MiscTests.cpp" >
|
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
testStringForMatching(), Contains( "string" ) || Contains( "different" ) || Contains( "random" )
|
testStringForMatching(), Contains( "string" ) || Contains( "different" ) || Contains( "random" )
|
||||||
</Original>
|
</Original>
|
||||||
@ -4400,7 +4400,7 @@ re>"
|
|||||||
"this string contains 'abc' as a substring" ( contains: "string" or contains: "different" or contains: "random" )
|
"this string contains 'abc' as a substring" ( contains: "string" or contains: "different" or contains: "random" )
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</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>
|
<Original>
|
||||||
testStringForMatching2(), Contains( "string" ) || Contains( "different" ) || Contains( "random" )
|
testStringForMatching2(), Contains( "string" ) || Contains( "different" ) || Contains( "random" )
|
||||||
</Original>
|
</Original>
|
||||||
@ -4410,8 +4410,8 @@ re>"
|
|||||||
</Expression>
|
</Expression>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<TestCase name="Matchers can be composed with both && and ||" tags="[matchers][operator&&][operators][operator||]" 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>/MiscTests.cpp" >
|
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "substring" )
|
testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "substring" )
|
||||||
</Original>
|
</Original>
|
||||||
@ -4421,8 +4421,8 @@ re>"
|
|||||||
</Expression>
|
</Expression>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<TestCase name="Matchers can be composed with both && and || - failing" tags="[.][.failing][hide][matchers][operator&&][operators][operator||]" 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>/MiscTests.cpp" >
|
<Expression success="false" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "random" )
|
testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "random" )
|
||||||
</Original>
|
</Original>
|
||||||
@ -4432,8 +4432,8 @@ re>"
|
|||||||
</Expression>
|
</Expression>
|
||||||
<OverallResult success="false"/>
|
<OverallResult success="false"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<TestCase name="Matchers can be negated (Not) with the ! operator" tags="[matchers][not][operators]" 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>/MiscTests.cpp" >
|
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
testStringForMatching(), !Contains( "different" )
|
testStringForMatching(), !Contains( "different" )
|
||||||
</Original>
|
</Original>
|
||||||
@ -4443,8 +4443,8 @@ re>"
|
|||||||
</Expression>
|
</Expression>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<TestCase name="Matchers can be negated (Not) with the ! operator - failing" tags="[.][.failing][hide][matchers][not][operators]" 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>/MiscTests.cpp" >
|
<Expression success="false" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
testStringForMatching(), !Contains( "substring" )
|
testStringForMatching(), !Contains( "substring" )
|
||||||
</Original>
|
</Original>
|
||||||
@ -7032,8 +7032,8 @@ Message from section two
|
|||||||
</StdOut>
|
</StdOut>
|
||||||
</OverallResult>
|
</OverallResult>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<TestCase name="StartsWith string matcher" tags="[.][failing][hide][matchers]" 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>/MiscTests.cpp" >
|
<Expression success="false" type="CHECK_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
testStringForMatching(), StartsWith( "string" )
|
testStringForMatching(), StartsWith( "string" )
|
||||||
</Original>
|
</Original>
|
||||||
@ -7043,8 +7043,8 @@ Message from section two
|
|||||||
</Expression>
|
</Expression>
|
||||||
<OverallResult success="false"/>
|
<OverallResult success="false"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<TestCase name="String matchers" tags="[matchers]" 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>/MiscTests.cpp" >
|
<Expression success="true" type="REQUIRE_THAT" filename="projects/<exe-name>/MatchersTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
testStringForMatching(), Contains( "string" )
|
testStringForMatching(), Contains( "string" )
|
||||||
</Original>
|
</Original>
|
||||||
@ -7052,7 +7052,7 @@ Message from section two
|
|||||||
"this string contains 'abc' as a substring" contains: "string"
|
"this string contains 'abc' as a substring" contains: "string"
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</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>
|
<Original>
|
||||||
testStringForMatching(), Contains( "abc" )
|
testStringForMatching(), Contains( "abc" )
|
||||||
</Original>
|
</Original>
|
||||||
@ -7060,7 +7060,7 @@ Message from section two
|
|||||||
"this string contains 'abc' as a substring" contains: "abc"
|
"this string contains 'abc' as a substring" contains: "abc"
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</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>
|
<Original>
|
||||||
testStringForMatching(), StartsWith( "this" )
|
testStringForMatching(), StartsWith( "this" )
|
||||||
</Original>
|
</Original>
|
||||||
@ -7068,7 +7068,7 @@ Message from section two
|
|||||||
"this string contains 'abc' as a substring" starts with: "this"
|
"this string contains 'abc' as a substring" starts with: "this"
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</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>
|
<Original>
|
||||||
testStringForMatching(), EndsWith( "substring" )
|
testStringForMatching(), EndsWith( "substring" )
|
||||||
</Original>
|
</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);
|
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 )
|
inline unsigned int Factorial( unsigned int number )
|
||||||
{
|
{
|
||||||
// return number <= 1 ? number : Factorial(number-1)*number;
|
// return number <= 1 ? number : Factorial(number-1)*number;
|
||||||
|
Loading…
Reference in New Issue
Block a user