Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authormelak472020-02-16 11:19:10 +0100
committerGitHub2020-02-16 11:19:10 +0100
commit17c4b2d0932ba944743b3c1e578352080af8c137 (patch)
treed4af4ea94e8e25a624634c4750871d7d221d66d0 /tests
parentdb1a0465dc39e8aed36852984c14072192750b1d (diff)
downloadcatch3-17c4b2d0932ba944743b3c1e578352080af8c137.tar.gz
Feature: generic matchers (#1843)
This commit extends the Matchers feature with the ability to have type-independent (e.g. templated) matchers. This is done by adding a new base type that Matchers can extend, `MatcherGenericBase`, and overloads of operators `!`, `&&` and `||` that handle matchers extending `MatcherGenericBase` in a special manner. These new matchers can also take their arguments as values and non-const references. Closes #1307 Closes #1553 Closes #1554 Co-authored-by: Martin Hořeňovský <martin.horenovsky@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/SelfTest/Baselines/automake.sw.approved.txt8
-rw-r--r--tests/SelfTest/Baselines/compact.sw.approved.txt35
-rw-r--r--tests/SelfTest/Baselines/console.std.approved.txt4
-rw-r--r--tests/SelfTest/Baselines/console.sw.approved.txt233
-rw-r--r--tests/SelfTest/Baselines/junit.sw.approved.txt10
-rw-r--r--tests/SelfTest/Baselines/sonarqube.sw.approved.txt8
-rw-r--r--tests/SelfTest/Baselines/tap.sw.approved.txt72
-rw-r--r--tests/SelfTest/Baselines/teamcity.sw.approved.txt16
-rw-r--r--tests/SelfTest/Baselines/xml.sw.approved.txt212
-rw-r--r--tests/SelfTest/UsageTests/Matchers.tests.cpp300
10 files changed, 889 insertions, 9 deletions
diff --git a/tests/SelfTest/Baselines/automake.sw.approved.txt b/tests/SelfTest/Baselines/automake.sw.approved.txt
index 035a92f2..db7f4006 100644
--- a/tests/SelfTest/Baselines/automake.sw.approved.txt
+++ b/tests/SelfTest/Baselines/automake.sw.approved.txt
@@ -85,6 +85,13 @@ Nor would this
:test-result: PASS CAPTURE parses string and character constants
:test-result: PASS Capture and info messages
:test-result: PASS Character pretty printing
+:test-result: PASS Combining MatchAllOfGeneric does not nest
+:test-result: PASS Combining MatchAnyOfGeneric does not nest
+:test-result: PASS Combining MatchNotOfGeneric does not nest
+:test-result: PASS Combining concrete matchers does not use templated matchers
+:test-result: PASS Combining only templated matchers
+:test-result: PASS Combining templated and concrete matchers
+:test-result: PASS Combining templated matchers
:test-result: PASS Commas in various macros are allowed
:test-result: PASS Comparing function pointers
:test-result: PASS Comparison ops
@@ -147,6 +154,7 @@ Nor would this
:test-result: PASS Ordering comparison checks that should succeed
:test-result: PASS Our PCG implementation provides expected results for known seeds
:test-result: FAIL Output from all sections is reported
+:test-result: PASS Overloaded comma or address-of operators are not used
:test-result: PASS Parse test names and tags
:test-result: PASS Pointers can be compared to null
:test-result: PASS Precision of floating point stringification can be set
diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt
index 66f75768..0d6cd160 100644
--- a/tests/SelfTest/Baselines/compact.sw.approved.txt
+++ b/tests/SelfTest/Baselines/compact.sw.approved.txt
@@ -263,6 +263,37 @@ ToStringGeneral.tests.cpp:<line number>: passed: c == i for: 2 == 2
ToStringGeneral.tests.cpp:<line number>: passed: c == i for: 3 == 3
ToStringGeneral.tests.cpp:<line number>: passed: c == i for: 4 == 4
ToStringGeneral.tests.cpp:<line number>: passed: c == i for: 5 == 5
+Matchers.tests.cpp:<line number>: passed: with 1 message: 'std::is_same< decltype(MatcherA() && MatcherB() && MatcherC()), Catch::Matchers::Impl::MatchAllOfGeneric<MatcherA, MatcherB, MatcherC> >::value'
+Matchers.tests.cpp:<line number>: passed: 1, MatcherA() && MatcherB() && MatcherC() for: 1 ( equals: (int) 1 or (float) 1.0f and equals: (long long) 1 and equals: (T) 1 )
+Matchers.tests.cpp:<line number>: passed: with 1 message: 'std::is_same< decltype(MatcherA() && MatcherB() && MatcherC() && MatcherD()), Catch::Matchers::Impl::MatchAllOfGeneric<MatcherA, MatcherB, MatcherC, MatcherD> >::value'
+Matchers.tests.cpp:<line number>: passed: 1, MatcherA() && MatcherB() && MatcherC() && MatcherD() for: 1 ( equals: (int) 1 or (float) 1.0f and equals: (long long) 1 and equals: (T) 1 and equals: true )
+Matchers.tests.cpp:<line number>: passed: with 1 message: 'std::is_same< decltype(MatcherA() || MatcherB() || MatcherC()), Catch::Matchers::Impl::MatchAnyOfGeneric<MatcherA, MatcherB, MatcherC> >::value'
+Matchers.tests.cpp:<line number>: passed: 1, MatcherA() || MatcherB() || MatcherC() for: 1 ( equals: (int) 1 or (float) 1.0f or equals: (long long) 1 or equals: (T) 1 )
+Matchers.tests.cpp:<line number>: passed: with 1 message: 'std::is_same< decltype(MatcherA() || MatcherB() || MatcherC() || MatcherD()), Catch::Matchers::Impl::MatchAnyOfGeneric<MatcherA, MatcherB, MatcherC, MatcherD> >::value'
+Matchers.tests.cpp:<line number>: passed: 1, MatcherA() || MatcherB() || MatcherC() || MatcherD() for: 1 ( equals: (int) 1 or (float) 1.0f or equals: (long long) 1 or equals: (T) 1 or equals: true )
+Matchers.tests.cpp:<line number>: passed: with 1 message: 'std::is_same< decltype(!MatcherA()), Catch::Matchers::Impl::MatchNotOfGeneric<MatcherA> >::value'
+Matchers.tests.cpp:<line number>: passed: 0, !MatcherA() for: 0 not equals: (int) 1 or (float) 1.0f
+Matchers.tests.cpp:<line number>: passed: with 1 message: 'std::is_same< decltype(!!MatcherA()), MatcherA const& >::value'
+Matchers.tests.cpp:<line number>: passed: 1, !!MatcherA() for: 1 equals: (int) 1 or (float) 1.0f
+Matchers.tests.cpp:<line number>: passed: with 1 message: 'std::is_same< decltype(!!!MatcherA()), Catch::Matchers::Impl::MatchNotOfGeneric<MatcherA> >::value'
+Matchers.tests.cpp:<line number>: passed: 0, !!!MatcherA() for: 0 not equals: (int) 1 or (float) 1.0f
+Matchers.tests.cpp:<line number>: passed: with 1 message: 'std::is_same< decltype(!!!!MatcherA()), MatcherA const & >::value'
+Matchers.tests.cpp:<line number>: passed: 1, !!!!MatcherA() for: 1 equals: (int) 1 or (float) 1.0f
+Matchers.tests.cpp:<line number>: passed: with 1 message: 'std::is_same< decltype(StartsWith("foo") || (StartsWith("bar") && EndsWith("bar") && !EndsWith("foo"))), Catch::Matchers::Impl::MatchAnyOf<std::string> >::value'
+Matchers.tests.cpp:<line number>: passed: with 1 message: 'std::is_same< decltype(MatcherA() || MatcherB()), Catch::Matchers::Impl::MatchAnyOfGeneric<MatcherA, MatcherB> >::value'
+Matchers.tests.cpp:<line number>: passed: 1, MatcherA() || MatcherB() for: 1 ( equals: (int) 1 or (float) 1.0f or equals: (long long) 1 )
+Matchers.tests.cpp:<line number>: passed: with 1 message: 'std::is_same< decltype(MatcherA() && MatcherB()), Catch::Matchers::Impl::MatchAllOfGeneric<MatcherA, MatcherB> >::value'
+Matchers.tests.cpp:<line number>: passed: 1, MatcherA() && MatcherB() for: 1 ( equals: (int) 1 or (float) 1.0f and equals: (long long) 1 )
+Matchers.tests.cpp:<line number>: passed: with 1 message: 'std::is_same< decltype(MatcherA() || !MatcherB()), Catch::Matchers::Impl::MatchAnyOfGeneric<MatcherA, Catch::Matchers::Impl::MatchNotOfGeneric<MatcherB>> >::value'
+Matchers.tests.cpp:<line number>: passed: 1, MatcherA() || !MatcherB() for: 1 ( equals: (int) 1 or (float) 1.0f or not equals: (long long) 1 )
+Matchers.tests.cpp:<line number>: passed: vec, Predicate<std::vector<int>>([](auto const& vec) { return std::all_of(vec.begin(), vec.end(), [](int elem) { return elem % 2 == 1; }); }, "All elements are odd") && !EqualsRange(a) for: { 1, 3, 5 } ( matches predicate: "All elements are odd" and not Equals: { 5, 3, 1 } )
+Matchers.tests.cpp:<line number>: passed: str, StartsWith("foo") && EqualsRange(arr) && EndsWith("bar") for: "foobar" ( starts with: "foo" and Equals: { 'f', 'o', 'o', 'b', 'a', 'r' } and ends with: "bar" )
+Matchers.tests.cpp:<line number>: passed: str, StartsWith("foo") && !EqualsRange(bad_arr) && EndsWith("bar") for: "foobar" ( starts with: "foo" and not Equals: { 'o', 'o', 'f', 'b', 'a', 'r' } and ends with: "bar" )
+Matchers.tests.cpp:<line number>: passed: str, EqualsRange(arr) && StartsWith("foo") && EndsWith("bar") for: "foobar" ( Equals: { 'f', 'o', 'o', 'b', 'a', 'r' } and starts with: "foo" and ends with: "bar" )
+Matchers.tests.cpp:<line number>: passed: str, !EqualsRange(bad_arr) && StartsWith("foo") && EndsWith("bar") for: "foobar" ( not Equals: { 'o', 'o', 'f', 'b', 'a', 'r' } and starts with: "foo" and ends with: "bar" )
+Matchers.tests.cpp:<line number>: passed: str, EqualsRange(bad_arr) || (StartsWith("foo") && EndsWith("bar")) for: "foobar" ( Equals: { 'o', 'o', 'f', 'b', 'a', 'r' } or ( starts with: "foo" and ends with: "bar" ) )
+Matchers.tests.cpp:<line number>: passed: str, (StartsWith("foo") && EndsWith("bar")) || EqualsRange(bad_arr) for: "foobar" ( ( starts with: "foo" and ends with: "bar" ) or Equals: { 'o', 'o', 'f', 'b', 'a', 'r' } )
+Matchers.tests.cpp:<line number>: passed: container, EqualsRange(a) || EqualsRange(b) || EqualsRange(c) for: { 1, 2, 3 } ( Equals: { 1, 2, 3 } or Equals: { 0, 1, 2 } or Equals: { 4, 5, 6 } )
Tricky.tests.cpp:<line number>: passed: std::vector<constructor_throws>{constructor_throws{}, constructor_throws{}}
Tricky.tests.cpp:<line number>: passed: std::vector<constructor_throws>{constructor_throws{}, constructor_throws{}}
Tricky.tests.cpp:<line number>: passed: std::vector<int>{1, 2, 3} == std::vector<int>{1, 2, 3}
@@ -883,6 +914,10 @@ RandomNumberGeneration.tests.cpp:<line number>: passed: rng() == 0x<hex digits>
4261393167 (0x<hex digits>)
Message.tests.cpp:<line number>: failed: explicitly with 1 message: 'Message from section one'
Message.tests.cpp:<line number>: failed: explicitly with 1 message: 'Message from section two'
+Matchers.tests.cpp:<line number>: passed: (EvilMatcher(), EvilMatcher()), EvilCommaOperatorUsed
+Matchers.tests.cpp:<line number>: passed: &EvilMatcher(), EvilAddressOfOperatorUsed
+Matchers.tests.cpp:<line number>: passed: EvilMatcher() || EvilMatcher() && !EvilMatcher()
+Matchers.tests.cpp:<line number>: passed: (EvilMatcher() && EvilMatcher()) || !EvilMatcher()
CmdLine.tests.cpp:<line number>: passed: spec.hasFilters() == false for: false == false
CmdLine.tests.cpp:<line number>: passed: spec.matches( *tcA ) == false for: false == false
CmdLine.tests.cpp:<line number>: passed: spec.matches( *tcB ) == false for: false == false
diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt
index d714a7f4..7056db0b 100644
--- a/tests/SelfTest/Baselines/console.std.approved.txt
+++ b/tests/SelfTest/Baselines/console.std.approved.txt
@@ -1380,6 +1380,6 @@ due to unexpected exception with message:
Why would you throw a std::string?
===============================================================================
-test cases: 320 | 246 passed | 70 failed | 4 failed as expected
-assertions: 1792 | 1640 passed | 131 failed | 21 failed as expected
+test cases: 328 | 254 passed | 70 failed | 4 failed as expected
+assertions: 1827 | 1675 passed | 131 failed | 21 failed as expected
diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt
index e6d9c48d..595acde6 100644
--- a/tests/SelfTest/Baselines/console.sw.approved.txt
+++ b/tests/SelfTest/Baselines/console.sw.approved.txt
@@ -2117,6 +2117,217 @@ with expansion:
5 == 5
-------------------------------------------------------------------------------
+Combining MatchAllOfGeneric does not nest
+-------------------------------------------------------------------------------
+Matchers.tests.cpp:<line number>
+...............................................................................
+
+Matchers.tests.cpp:<line number>: PASSED:
+with message:
+ std::is_same< decltype(MatcherA() && MatcherB() && MatcherC()), Catch::
+ Matchers::Impl::MatchAllOfGeneric<MatcherA, MatcherB, MatcherC> >::value
+
+Matchers.tests.cpp:<line number>: PASSED:
+ REQUIRE_THAT( 1, MatcherA() && MatcherB() && MatcherC() )
+with expansion:
+ 1 ( equals: (int) 1 or (float) 1.0f and equals: (long long) 1 and equals: (T)
+ 1 )
+
+Matchers.tests.cpp:<line number>: PASSED:
+with message:
+ std::is_same< decltype(MatcherA() && MatcherB() && MatcherC() && MatcherD()),
+ Catch::Matchers::Impl::MatchAllOfGeneric<MatcherA, MatcherB, MatcherC,
+ MatcherD> >::value
+
+Matchers.tests.cpp:<line number>: PASSED:
+ REQUIRE_THAT( 1, MatcherA() && MatcherB() && MatcherC() && MatcherD() )
+with expansion:
+ 1 ( equals: (int) 1 or (float) 1.0f and equals: (long long) 1 and equals: (T)
+ 1 and equals: true )
+
+-------------------------------------------------------------------------------
+Combining MatchAnyOfGeneric does not nest
+-------------------------------------------------------------------------------
+Matchers.tests.cpp:<line number>
+...............................................................................
+
+Matchers.tests.cpp:<line number>: PASSED:
+with message:
+ std::is_same< decltype(MatcherA() || MatcherB() || MatcherC()), Catch::
+ Matchers::Impl::MatchAnyOfGeneric<MatcherA, MatcherB, MatcherC> >::value
+
+Matchers.tests.cpp:<line number>: PASSED:
+ REQUIRE_THAT( 1, MatcherA() || MatcherB() || MatcherC() )
+with expansion:
+ 1 ( equals: (int) 1 or (float) 1.0f or equals: (long long) 1 or equals: (T) 1
+ )
+
+Matchers.tests.cpp:<line number>: PASSED:
+with message:
+ std::is_same< decltype(MatcherA() || MatcherB() || MatcherC() || MatcherD()),
+ Catch::Matchers::Impl::MatchAnyOfGeneric<MatcherA, MatcherB, MatcherC,
+ MatcherD> >::value
+
+Matchers.tests.cpp:<line number>: PASSED:
+ REQUIRE_THAT( 1, MatcherA() || MatcherB() || MatcherC() || MatcherD() )
+with expansion:
+ 1 ( equals: (int) 1 or (float) 1.0f or equals: (long long) 1 or equals: (T) 1
+ or equals: true )
+
+-------------------------------------------------------------------------------
+Combining MatchNotOfGeneric does not nest
+-------------------------------------------------------------------------------
+Matchers.tests.cpp:<line number>
+...............................................................................
+
+Matchers.tests.cpp:<line number>: PASSED:
+with message:
+ std::is_same< decltype(!MatcherA()), Catch::Matchers::Impl::MatchNotOfGeneric
+ <MatcherA> >::value
+
+Matchers.tests.cpp:<line number>: PASSED:
+ REQUIRE_THAT( 0, !MatcherA() )
+with expansion:
+ 0 not equals: (int) 1 or (float) 1.0f
+
+Matchers.tests.cpp:<line number>: PASSED:
+with message:
+ std::is_same< decltype(!!MatcherA()), MatcherA const& >::value
+
+Matchers.tests.cpp:<line number>: PASSED:
+ REQUIRE_THAT( 1, !!MatcherA() )
+with expansion:
+ 1 equals: (int) 1 or (float) 1.0f
+
+Matchers.tests.cpp:<line number>: PASSED:
+with message:
+ std::is_same< decltype(!!!MatcherA()), Catch::Matchers::Impl::
+ MatchNotOfGeneric<MatcherA> >::value
+
+Matchers.tests.cpp:<line number>: PASSED:
+ REQUIRE_THAT( 0, !!!MatcherA() )
+with expansion:
+ 0 not equals: (int) 1 or (float) 1.0f
+
+Matchers.tests.cpp:<line number>: PASSED:
+with message:
+ std::is_same< decltype(!!!!MatcherA()), MatcherA const & >::value
+
+Matchers.tests.cpp:<line number>: PASSED:
+ REQUIRE_THAT( 1, !!!!MatcherA() )
+with expansion:
+ 1 equals: (int) 1 or (float) 1.0f
+
+-------------------------------------------------------------------------------
+Combining concrete matchers does not use templated matchers
+-------------------------------------------------------------------------------
+Matchers.tests.cpp:<line number>
+...............................................................................
+
+Matchers.tests.cpp:<line number>: PASSED:
+with message:
+ std::is_same< decltype(StartsWith("foo") || (StartsWith("bar") && EndsWith
+ ("bar") && !EndsWith("foo"))), Catch::Matchers::Impl::MatchAnyOf<std::string>
+ >::value
+
+-------------------------------------------------------------------------------
+Combining only templated matchers
+-------------------------------------------------------------------------------
+Matchers.tests.cpp:<line number>
+...............................................................................
+
+Matchers.tests.cpp:<line number>: PASSED:
+with message:
+ std::is_same< decltype(MatcherA() || MatcherB()), Catch::Matchers::Impl::
+ MatchAnyOfGeneric<MatcherA, MatcherB> >::value
+
+Matchers.tests.cpp:<line number>: PASSED:
+ REQUIRE_THAT( 1, MatcherA() || MatcherB() )
+with expansion:
+ 1 ( equals: (int) 1 or (float) 1.0f or equals: (long long) 1 )
+
+Matchers.tests.cpp:<line number>: PASSED:
+with message:
+ std::is_same< decltype(MatcherA() && MatcherB()), Catch::Matchers::Impl::
+ MatchAllOfGeneric<MatcherA, MatcherB> >::value
+
+Matchers.tests.cpp:<line number>: PASSED:
+ REQUIRE_THAT( 1, MatcherA() && MatcherB() )
+with expansion:
+ 1 ( equals: (int) 1 or (float) 1.0f and equals: (long long) 1 )
+
+Matchers.tests.cpp:<line number>: PASSED:
+with message:
+ std::is_same< decltype(MatcherA() || !MatcherB()), Catch::Matchers::Impl::
+ MatchAnyOfGeneric<MatcherA, Catch::Matchers::Impl::MatchNotOfGeneric
+ <MatcherB>> >::value
+
+Matchers.tests.cpp:<line number>: PASSED:
+ REQUIRE_THAT( 1, MatcherA() || !MatcherB() )
+with expansion:
+ 1 ( equals: (int) 1 or (float) 1.0f or not equals: (long long) 1 )
+
+-------------------------------------------------------------------------------
+Combining templated and concrete matchers
+-------------------------------------------------------------------------------
+Matchers.tests.cpp:<line number>
+...............................................................................
+
+Matchers.tests.cpp:<line number>: PASSED:
+ REQUIRE_THAT( vec, Predicate<std::vector<int>>([](auto const& vec) { return std::all_of(vec.begin(), vec.end(), [](int elem) { return elem % 2 == 1; }); }, "All elements are odd") && !EqualsRange(a) )
+with expansion:
+ { 1, 3, 5 } ( matches predicate: "All elements are odd" and not Equals: { 5,
+ 3, 1 } )
+
+Matchers.tests.cpp:<line number>: PASSED:
+ REQUIRE_THAT( str, StartsWith("foo") && EqualsRange(arr) && EndsWith("bar") )
+with expansion:
+ "foobar" ( starts with: "foo" and Equals: { 'f', 'o', 'o', 'b', 'a', 'r' }
+ and ends with: "bar" )
+
+Matchers.tests.cpp:<line number>: PASSED:
+ REQUIRE_THAT( str, StartsWith("foo") && !EqualsRange(bad_arr) && EndsWith("bar") )
+with expansion:
+ "foobar" ( starts with: "foo" and not Equals: { 'o', 'o', 'f', 'b', 'a', 'r'
+ } and ends with: "bar" )
+
+Matchers.tests.cpp:<line number>: PASSED:
+ REQUIRE_THAT( str, EqualsRange(arr) && StartsWith("foo") && EndsWith("bar") )
+with expansion:
+ "foobar" ( Equals: { 'f', 'o', 'o', 'b', 'a', 'r' } and starts with: "foo"
+ and ends with: "bar" )
+
+Matchers.tests.cpp:<line number>: PASSED:
+ REQUIRE_THAT( str, !EqualsRange(bad_arr) && StartsWith("foo") && EndsWith("bar") )
+with expansion:
+ "foobar" ( not Equals: { 'o', 'o', 'f', 'b', 'a', 'r' } and starts with:
+ "foo" and ends with: "bar" )
+
+Matchers.tests.cpp:<line number>: PASSED:
+ REQUIRE_THAT( str, EqualsRange(bad_arr) || (StartsWith("foo") && EndsWith("bar")) )
+with expansion:
+ "foobar" ( Equals: { 'o', 'o', 'f', 'b', 'a', 'r' } or ( starts with: "foo"
+ and ends with: "bar" ) )
+
+Matchers.tests.cpp:<line number>: PASSED:
+ REQUIRE_THAT( str, (StartsWith("foo") && EndsWith("bar")) || EqualsRange(bad_arr) )
+with expansion:
+ "foobar" ( ( starts with: "foo" and ends with: "bar" ) or Equals: { 'o', 'o',
+ 'f', 'b', 'a', 'r' } )
+
+-------------------------------------------------------------------------------
+Combining templated matchers
+-------------------------------------------------------------------------------
+Matchers.tests.cpp:<line number>
+...............................................................................
+
+Matchers.tests.cpp:<line number>: PASSED:
+ REQUIRE_THAT( container, EqualsRange(a) || EqualsRange(b) || EqualsRange(c) )
+with expansion:
+ { 1, 2, 3 } ( Equals: { 1, 2, 3 } or Equals: { 0, 1, 2 } or Equals: { 4, 5, 6
+ } )
+
+-------------------------------------------------------------------------------
Commas in various macros are allowed
-------------------------------------------------------------------------------
Tricky.tests.cpp:<line number>
@@ -6415,6 +6626,24 @@ explicitly with message:
Message from section two
-------------------------------------------------------------------------------
+Overloaded comma or address-of operators are not used
+-------------------------------------------------------------------------------
+Matchers.tests.cpp:<line number>
+...............................................................................
+
+Matchers.tests.cpp:<line number>: PASSED:
+ REQUIRE_THROWS_AS( (EvilMatcher(), EvilMatcher()), EvilCommaOperatorUsed )
+
+Matchers.tests.cpp:<line number>: PASSED:
+ REQUIRE_THROWS_AS( &EvilMatcher(), EvilAddressOfOperatorUsed )
+
+Matchers.tests.cpp:<line number>: PASSED:
+ REQUIRE_NOTHROW( EvilMatcher() || EvilMatcher() && !EvilMatcher() )
+
+Matchers.tests.cpp:<line number>: PASSED:
+ REQUIRE_NOTHROW( (EvilMatcher() && EvilMatcher()) || !EvilMatcher() )
+
+-------------------------------------------------------------------------------
Parse test names and tags
Empty test spec should have no filters
-------------------------------------------------------------------------------
@@ -14053,6 +14282,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED:
===============================================================================
-test cases: 320 | 230 passed | 86 failed | 4 failed as expected
-assertions: 1809 | 1640 passed | 148 failed | 21 failed as expected
+test cases: 328 | 238 passed | 86 failed | 4 failed as expected
+assertions: 1844 | 1675 passed | 148 failed | 21 failed as expected
diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt
index 0a3175dc..f7214ed7 100644
--- a/tests/SelfTest/Baselines/junit.sw.approved.txt
+++ b/tests/SelfTest/Baselines/junit.sw.approved.txt
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuitesloose text artifact
>
- <testsuite name="<exe-name>" errors="17" failures="132" tests="1810" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
+ <testsuite name="<exe-name>" errors="17" failures="132" tests="1845" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties>
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/>
<property name="random-seed" value="1"/>
@@ -350,6 +350,13 @@ Exception.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="Character pretty printing/Specifically escaped" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Character pretty printing/General chars" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Character pretty printing/Low ASCII" time="{duration}"/>
+ <testcase classname="<exe-name>.global" name="Combining MatchAllOfGeneric does not nest" time="{duration}"/>
+ <testcase classname="<exe-name>.global" name="Combining MatchAnyOfGeneric does not nest" time="{duration}"/>
+ <testcase classname="<exe-name>.global" name="Combining MatchNotOfGeneric does not nest" time="{duration}"/>
+ <testcase classname="<exe-name>.global" name="Combining concrete matchers does not use templated matchers" time="{duration}"/>
+ <testcase classname="<exe-name>.global" name="Combining only templated matchers" time="{duration}"/>
+ <testcase classname="<exe-name>.global" name="Combining templated and concrete matchers" time="{duration}"/>
+ <testcase classname="<exe-name>.global" name="Combining templated matchers" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Commas in various macros are allowed" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Comparing function pointers" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Comparison ops" time="{duration}"/>
@@ -950,6 +957,7 @@ Message from section two
Message.tests.cpp:<line number>
</failure>
</testcase>
+ <testcase classname="<exe-name>.global" name="Overloaded comma or address-of operators are not used" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/Empty test spec should have no filters" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/Test spec from empty string should have no filters" time="{duration}"/>
<testcase classname="<exe-name>.global" name="Parse test names and tags/Test spec from just a comma should have no filters" time="{duration}"/>
diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
index d359b155..517c5f0b 100644
--- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
+++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
@@ -915,6 +915,13 @@ Exception.tests.cpp:<line number>
<file path="tests/<exe-name>/UsageTests/Matchers.tests.cpp">
<testCase name="Arbitrary predicate matcher/Function pointer" duration="{duration}"/>
<testCase name="Arbitrary predicate matcher/Lambdas + different type" duration="{duration}"/>
+ <testCase name="Combining MatchAllOfGeneric does not nest" duration="{duration}"/>
+ <testCase name="Combining MatchAnyOfGeneric does not nest" duration="{duration}"/>
+ <testCase name="Combining MatchNotOfGeneric does not nest" duration="{duration}"/>
+ <testCase name="Combining concrete matchers does not use templated matchers" duration="{duration}"/>
+ <testCase name="Combining only templated matchers" duration="{duration}"/>
+ <testCase name="Combining templated and concrete matchers" duration="{duration}"/>
+ <testCase name="Combining templated matchers" duration="{duration}"/>
<testCase name="Contains string matcher" duration="{duration}">
<failure message="CHECK_THAT(testStringForMatching(), Contains(&quot;not there&quot;, Catch::CaseSensitive::No))">
FAILED:
@@ -1042,6 +1049,7 @@ with expansion:
Matchers.tests.cpp:<line number>
</failure>
</testCase>
+ <testCase name="Overloaded comma or address-of operators are not used" duration="{duration}"/>
<testCase name="Predicate matcher can accept const char*" duration="{duration}"/>
<testCase name="Regex string matcher" duration="{duration}">
<failure message="CHECK_THAT(testStringForMatching(), Matches(&quot;this STRING contains 'abc' as a substring&quot;))">
diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt
index bc0f3c25..f6c53961 100644
--- a/tests/SelfTest/Baselines/tap.sw.approved.txt
+++ b/tests/SelfTest/Baselines/tap.sw.approved.txt
@@ -524,6 +524,68 @@ ok {test-number} - c == i for: 3 == 3
ok {test-number} - c == i for: 4 == 4
# Character pretty printing
ok {test-number} - c == i for: 5 == 5
+# Combining MatchAllOfGeneric does not nest
+ok {test-number} - with 1 message: 'std::is_same< decltype(MatcherA() && MatcherB() && MatcherC()), Catch::Matchers::Impl::MatchAllOfGeneric<MatcherA, MatcherB, MatcherC> >::value'
+# Combining MatchAllOfGeneric does not nest
+ok {test-number} - 1, MatcherA() && MatcherB() && MatcherC() for: 1 ( equals: (int) 1 or (float) 1.0f and equals: (long long) 1 and equals: (T) 1 )
+# Combining MatchAllOfGeneric does not nest
+ok {test-number} - with 1 message: 'std::is_same< decltype(MatcherA() && MatcherB() && MatcherC() && MatcherD()), Catch::Matchers::Impl::MatchAllOfGeneric<MatcherA, MatcherB, MatcherC, MatcherD> >::value'
+# Combining MatchAllOfGeneric does not nest
+ok {test-number} - 1, MatcherA() && MatcherB() && MatcherC() && MatcherD() for: 1 ( equals: (int) 1 or (float) 1.0f and equals: (long long) 1 and equals: (T) 1 and equals: true )
+# Combining MatchAnyOfGeneric does not nest
+ok {test-number} - with 1 message: 'std::is_same< decltype(MatcherA() || MatcherB() || MatcherC()), Catch::Matchers::Impl::MatchAnyOfGeneric<MatcherA, MatcherB, MatcherC> >::value'
+# Combining MatchAnyOfGeneric does not nest
+ok {test-number} - 1, MatcherA() || MatcherB() || MatcherC() for: 1 ( equals: (int) 1 or (float) 1.0f or equals: (long long) 1 or equals: (T) 1 )
+# Combining MatchAnyOfGeneric does not nest
+ok {test-number} - with 1 message: 'std::is_same< decltype(MatcherA() || MatcherB() || MatcherC() || MatcherD()), Catch::Matchers::Impl::MatchAnyOfGeneric<MatcherA, MatcherB, MatcherC, MatcherD> >::value'
+# Combining MatchAnyOfGeneric does not nest
+ok {test-number} - 1, MatcherA() || MatcherB() || MatcherC() || MatcherD() for: 1 ( equals: (int) 1 or (float) 1.0f or equals: (long long) 1 or equals: (T) 1 or equals: true )
+# Combining MatchNotOfGeneric does not nest
+ok {test-number} - with 1 message: 'std::is_same< decltype(!MatcherA()), Catch::Matchers::Impl::MatchNotOfGeneric<MatcherA> >::value'
+# Combining MatchNotOfGeneric does not nest
+ok {test-number} - 0, !MatcherA() for: 0 not equals: (int) 1 or (float) 1.0f
+# Combining MatchNotOfGeneric does not nest
+ok {test-number} - with 1 message: 'std::is_same< decltype(!!MatcherA()), MatcherA const& >::value'
+# Combining MatchNotOfGeneric does not nest
+ok {test-number} - 1, !!MatcherA() for: 1 equals: (int) 1 or (float) 1.0f
+# Combining MatchNotOfGeneric does not nest
+ok {test-number} - with 1 message: 'std::is_same< decltype(!!!MatcherA()), Catch::Matchers::Impl::MatchNotOfGeneric<MatcherA> >::value'
+# Combining MatchNotOfGeneric does not nest
+ok {test-number} - 0, !!!MatcherA() for: 0 not equals: (int) 1 or (float) 1.0f
+# Combining MatchNotOfGeneric does not nest
+ok {test-number} - with 1 message: 'std::is_same< decltype(!!!!MatcherA()), MatcherA const & >::value'
+# Combining MatchNotOfGeneric does not nest
+ok {test-number} - 1, !!!!MatcherA() for: 1 equals: (int) 1 or (float) 1.0f
+# Combining concrete matchers does not use templated matchers
+ok {test-number} - with 1 message: 'std::is_same< decltype(StartsWith("foo") || (StartsWith("bar") && EndsWith("bar") && !EndsWith("foo"))), Catch::Matchers::Impl::MatchAnyOf<std::string> >::value'
+# Combining only templated matchers
+ok {test-number} - with 1 message: 'std::is_same< decltype(MatcherA() || MatcherB()), Catch::Matchers::Impl::MatchAnyOfGeneric<MatcherA, MatcherB> >::value'
+# Combining only templated matchers
+ok {test-number} - 1, MatcherA() || MatcherB() for: 1 ( equals: (int) 1 or (float) 1.0f or equals: (long long) 1 )
+# Combining only templated matchers
+ok {test-number} - with 1 message: 'std::is_same< decltype(MatcherA() && MatcherB()), Catch::Matchers::Impl::MatchAllOfGeneric<MatcherA, MatcherB> >::value'
+# Combining only templated matchers
+ok {test-number} - 1, MatcherA() && MatcherB() for: 1 ( equals: (int) 1 or (float) 1.0f and equals: (long long) 1 )
+# Combining only templated matchers
+ok {test-number} - with 1 message: 'std::is_same< decltype(MatcherA() || !MatcherB()), Catch::Matchers::Impl::MatchAnyOfGeneric<MatcherA, Catch::Matchers::Impl::MatchNotOfGeneric<MatcherB>> >::value'
+# Combining only templated matchers
+ok {test-number} - 1, MatcherA() || !MatcherB() for: 1 ( equals: (int) 1 or (float) 1.0f or not equals: (long long) 1 )
+# Combining templated and concrete matchers
+ok {test-number} - vec, Predicate<std::vector<int>>([](auto const& vec) { return std::all_of(vec.begin(), vec.end(), [](int elem) { return elem % 2 == 1; }); }, "All elements are odd") && !EqualsRange(a) for: { 1, 3, 5 } ( matches predicate: "All elements are odd" and not Equals: { 5, 3, 1 } )
+# Combining templated and concrete matchers
+ok {test-number} - str, StartsWith("foo") && EqualsRange(arr) && EndsWith("bar") for: "foobar" ( starts with: "foo" and Equals: { 'f', 'o', 'o', 'b', 'a', 'r' } and ends with: "bar" )
+# Combining templated and concrete matchers
+ok {test-number} - str, StartsWith("foo") && !EqualsRange(bad_arr) && EndsWith("bar") for: "foobar" ( starts with: "foo" and not Equals: { 'o', 'o', 'f', 'b', 'a', 'r' } and ends with: "bar" )
+# Combining templated and concrete matchers
+ok {test-number} - str, EqualsRange(arr) && StartsWith("foo") && EndsWith("bar") for: "foobar" ( Equals: { 'f', 'o', 'o', 'b', 'a', 'r' } and starts with: "foo" and ends with: "bar" )
+# Combining templated and concrete matchers
+ok {test-number} - str, !EqualsRange(bad_arr) && StartsWith("foo") && EndsWith("bar") for: "foobar" ( not Equals: { 'o', 'o', 'f', 'b', 'a', 'r' } and starts with: "foo" and ends with: "bar" )
+# Combining templated and concrete matchers
+ok {test-number} - str, EqualsRange(bad_arr) || (StartsWith("foo") && EndsWith("bar")) for: "foobar" ( Equals: { 'o', 'o', 'f', 'b', 'a', 'r' } or ( starts with: "foo" and ends with: "bar" ) )
+# Combining templated and concrete matchers
+ok {test-number} - str, (StartsWith("foo") && EndsWith("bar")) || EqualsRange(bad_arr) for: "foobar" ( ( starts with: "foo" and ends with: "bar" ) or Equals: { 'o', 'o', 'f', 'b', 'a', 'r' } )
+# Combining templated matchers
+ok {test-number} - container, EqualsRange(a) || EqualsRange(b) || EqualsRange(c) for: { 1, 2, 3 } ( Equals: { 1, 2, 3 } or Equals: { 0, 1, 2 } or Equals: { 4, 5, 6 } )
# Commas in various macros are allowed
ok {test-number} - std::vector<constructor_throws>{constructor_throws{}, constructor_throws{}}
# Commas in various macros are allowed
@@ -1688,6 +1750,14 @@ ok {test-number} - rng() == 0x<hex digits> for: 4261393167 (0x<hex digits>) == 4
not ok {test-number} - explicitly with 1 message: 'Message from section one'
# Output from all sections is reported
not ok {test-number} - explicitly with 1 message: 'Message from section two'
+# Overloaded comma or address-of operators are not used
+ok {test-number} - (EvilMatcher(), EvilMatcher()), EvilCommaOperatorUsed
+# Overloaded comma or address-of operators are not used
+ok {test-number} - &EvilMatcher(), EvilAddressOfOperatorUsed
+# Overloaded comma or address-of operators are not used
+ok {test-number} - EvilMatcher() || EvilMatcher() && !EvilMatcher()
+# Overloaded comma or address-of operators are not used
+ok {test-number} - (EvilMatcher() && EvilMatcher()) || !EvilMatcher()
# Parse test names and tags
ok {test-number} - spec.hasFilters() == false for: false == false
# Parse test names and tags
@@ -3610,5 +3680,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
ok {test-number} -
# xmlentitycheck
ok {test-number} -
-1..1801
+1..1836
diff --git a/tests/SelfTest/Baselines/teamcity.sw.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.approved.txt
index 76d62183..dbfb9835 100644
--- a/tests/SelfTest/Baselines/teamcity.sw.approved.txt
+++ b/tests/SelfTest/Baselines/teamcity.sw.approved.txt
@@ -203,6 +203,20 @@ Exception.tests.cpp:<line number>|nunexpected exception with message:|n "unexpe
##teamcity[testFinished name='Capture and info messages' duration="{duration}"]
##teamcity[testStarted name='Character pretty printing']
##teamcity[testFinished name='Character pretty printing' duration="{duration}"]
+##teamcity[testStarted name='Combining MatchAllOfGeneric does not nest']
+##teamcity[testFinished name='Combining MatchAllOfGeneric does not nest' duration="{duration}"]
+##teamcity[testStarted name='Combining MatchAnyOfGeneric does not nest']
+##teamcity[testFinished name='Combining MatchAnyOfGeneric does not nest' duration="{duration}"]
+##teamcity[testStarted name='Combining MatchNotOfGeneric does not nest']
+##teamcity[testFinished name='Combining MatchNotOfGeneric does not nest' duration="{duration}"]
+##teamcity[testStarted name='Combining concrete matchers does not use templated matchers']
+##teamcity[testFinished name='Combining concrete matchers does not use templated matchers' duration="{duration}"]
+##teamcity[testStarted name='Combining only tem