Added &&, || and ! operator overloads for matchers

(syntactic sugar for AllOf, AnyOf and Not compositional matchers, respectively)
This commit is contained in:
Phil Nash
2015-11-05 18:46:00 +00:00
parent f3e7722cc6
commit 054e3c5b43
6 changed files with 286 additions and 8 deletions

View File

@@ -707,6 +707,29 @@ MiscTests.cpp:<line number>: FAILED:
with expansion:
"this string contains 'abc' as a substring" equals: "something else"
-------------------------------------------------------------------------------
Matchers can be composed with both + and | - failing
-------------------------------------------------------------------------------
MiscTests.cpp:<line number>
...............................................................................
MiscTests.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
contains: "different" ) and contains: "random" )
-------------------------------------------------------------------------------
Matchers can be negated (Not) with the ! operator - failing
-------------------------------------------------------------------------------
MiscTests.cpp:<line number>
...............................................................................
MiscTests.cpp:<line number>: FAILED:
CHECK_THAT( testStringForMatching() !Contains( "substring" ) )
with expansion:
"this string contains 'abc' as a substring" not contains: "substring"
-------------------------------------------------------------------------------
Nice descriptive name
-------------------------------------------------------------------------------
@@ -797,6 +820,6 @@ with expansion:
"first" == "second"
===============================================================================
test cases: 159 | 119 passed | 39 failed | 1 failed as expected
assertions: 905 | 812 passed | 80 failed | 13 failed as expected
test cases: 165 | 123 passed | 41 failed | 1 failed as expected
assertions: 912 | 817 passed | 82 failed | 13 failed as expected