catch3
Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.
Clonegit clone https://git.progmasoft.com/catch3
Add more comprehensive tests for the quantifier matchers
- Commit
77643ce2e56233d7e9d3974b5efdb40b0e9149e1- Author
- Martin Hořeňovský ·
- Parents
552af8920df2
Changes
tests/SelfTest/Baselines/automake.sw.approved.txt | 4 +- tests/SelfTest/Baselines/compact.sw.approved.txt | 63 ++- tests/SelfTest/Baselines/console.std.approved.txt | 4 +- tests/SelfTest/Baselines/console.sw.approved.txt | 357 ++++++++++---- tests/SelfTest/Baselines/junit.sw.approved.txt | 17 +- tests/SelfTest/Baselines/sonarqube.sw.approved.txt | 15 +- tests/SelfTest/Baselines/tap.sw.approved.txt | 128 +++-- tests/SelfTest/Baselines/teamcity.sw.approved.txt | 8 +- tests/SelfTest/Baselines/xml.sw.approved.txt | 517 ++++++++++++++++----- tests/SelfTest/UsageTests/MatchersRanges.tests.cpp | 353 ++++++++++++-- 10 files changed, 1155 insertions(+), 311 deletions(-) diff --git a/tests/SelfTest/Baselines/automake.sw.approved.txt b/tests/SelfTest/Baselines/automake.sw.approved.txt index 4b51b804..87f2a189 100644 --- a/tests/SelfTest/Baselines/automake.sw.approved.txt +++ b/tests/SelfTest/Baselines/automake.sw.approved.txt @@ -237,8 +237,10 @@ Message from section two :test-result: PASS Trim strings :test-result: FAIL Unexpected exceptions can be translated :test-result: PASS Upcasting special member functions +:test-result: PASS Usage of AllMatch range matcher +:test-result: PASS Usage of AnyMatch range matcher +:test-result: PASS Usage of NoneMatch range matcher :test-result: PASS Usage of the SizeIs range matcher -:test-result: PASS Usage of the quantifiers matchers :test-result: PASS Use a custom approx :test-result: PASS Variadic macros :test-result: PASS Vector Approx matcher diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt index a50cc6e3..1b6fb40c 100644 --- a/tests/SelfTest/Baselines/compact.sw.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.approved.txt @@ -1659,6 +1659,51 @@ There is no extra whitespace here Exception.tests.cpp:<line number>: failed: unexpected exception with message: '3.14' UniquePtr.tests.cpp:<line number>: passed: bptr->i == 3 for: 3 == 3 UniquePtr.tests.cpp:<line number>: passed: bptr->i == 3 for: 3 == 3 +MatchersRanges.tests.cpp:<line number>: passed: data, AllMatch(SizeIs(5)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } all match has size == 5 +MatchersRanges.tests.cpp:<line number>: passed: data, !AllMatch(Contains(0) && Contains(1)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } not all match ( contains element 0 and contains element 1 ) +MatchersRanges.tests.cpp:<line number>: passed: needs_adl, AllMatch( Predicate<int>( []( int elem ) { return elem < 6; } ) ) for: { 1, 2, 3, 4, 5 } all match matches undescribed predicate +MatchersRanges.tests.cpp:<line number>: passed: mocked, allMatch for: { 1, 2, 3, 4, 5 } all match matches undescribed predicate +MatchersRanges.tests.cpp:<line number>: passed: mocked.derefed[0] for: true +MatchersRanges.tests.cpp:<line number>: passed: mocked.derefed[1] for: true +MatchersRanges.tests.cpp:<line number>: passed: mocked.derefed[2] for: true +MatchersRanges.tests.cpp:<line number>: passed: mocked.derefed[3] for: true +MatchersRanges.tests.cpp:<line number>: passed: mocked.derefed[4] for: true +MatchersRanges.tests.cpp:<line number>: passed: mocked, !allMatch for: { 1, 2, 3, 4, 5 } not all match matches undescribed predicate +MatchersRanges.tests.cpp:<line number>: passed: mocked.derefed[0] for: true +MatchersRanges.tests.cpp:<line number>: passed: mocked.derefed[1] for: true +MatchersRanges.tests.cpp:<line number>: passed: mocked.derefed[2] for: true +MatchersRanges.tests.cpp:<line number>: passed: !(mocked.derefed[3]) for: !false +MatchersRanges.tests.cpp:<line number>: passed: !(mocked.derefed[4]) for: !false +MatchersRanges.tests.cpp:<line number>: passed: data, AnyMatch(SizeIs(5)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } any match has size == 5 +MatchersRanges.tests.cpp:<line number>: passed: data, !AnyMatch(Contains(0) && Contains(10)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } not any match ( contains element 0 and contains element 10 ) +MatchersRanges.tests.cpp:<line number>: passed: needs_adl, AnyMatch( Predicate<int>( []( int elem ) { return elem < 3; } ) ) for: { 1, 2, 3, 4, 5 } any match matches undescribed predicate +MatchersRanges.tests.cpp:<line number>: passed: mocked, !anyMatch for: { 1, 2, 3, 4, 5 } not any match matches undescribed predicate +MatchersRanges.tests.cpp:<line number>: passed: mocked.derefed[0] for: true +MatchersRanges.tests.cpp:<line number>: passed: mocked.derefed[1] for: true +MatchersRanges.tests.cpp:<line number>: passed: mocked.derefed[2] for: true +MatchersRanges.tests.cpp:<line number>: passed: mocked.derefed[3] for: true +MatchersRanges.tests.cpp:<line number>: passed: mocked.derefed[4] for: true +MatchersRanges.tests.cpp:<line number>: passed: mocked, anyMatch for: { 1, 2, 3, 4, 5 } any match matches undescribed predicate +MatchersRanges.tests.cpp:<line number>: passed: mocked.derefed[0] for: true +MatchersRanges.tests.cpp:<line number>: passed: !(mocked.derefed[1]) for: !false +MatchersRanges.tests.cpp:<line number>: passed: !(mocked.derefed[2]) for: !false +MatchersRanges.tests.cpp:<line number>: passed: !(mocked.derefed[3]) for: !false +MatchersRanges.tests.cpp:<line number>: passed: !(mocked.derefed[4]) for: !false +MatchersRanges.tests.cpp:<line number>: passed: data, NoneMatch(SizeIs(6)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } none match has size == 6 +MatchersRanges.tests.cpp:<line number>: passed: data, !NoneMatch(Contains(0) && Contains(1)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } not none match ( contains element 0 and contains element 1 ) +MatchersRanges.tests.cpp:<line number>: passed: needs_adl, NoneMatch( Predicate<int>( []( int elem ) { return elem > 6; } ) ) for: { 1, 2, 3, 4, 5 } none match matches undescribed predicate +MatchersRanges.tests.cpp:<line number>: passed: mocked, noneMatch for: { 1, 2, 3, 4, 5 } none match matches undescribed predicate +MatchersRanges.tests.cpp:<line number>: passed: mocked.derefed[0] for: true +MatchersRanges.tests.cpp:<line number>: passed: mocked.derefed[1] for: true +MatchersRanges.tests.cpp:<line number>: passed: mocked.derefed[2] for: true +MatchersRanges.tests.cpp:<line number>: passed: mocked.derefed[3] for: true +MatchersRanges.tests.cpp:<line number>: passed: mocked.derefed[4] for: true +MatchersRanges.tests.cpp:<line number>: passed: mocked, !noneMatch for: { 1, 2, 3, 4, 5 } not none match matches undescribed predicate +MatchersRanges.tests.cpp:<line number>: passed: mocked.derefed[0] for: true +MatchersRanges.tests.cpp:<line number>: passed: !(mocked.derefed[1]) for: !false +MatchersRanges.tests.cpp:<line number>: passed: !(mocked.derefed[2]) for: !false +MatchersRanges.tests.cpp:<line number>: passed: !(mocked.derefed[3]) for: !false +MatchersRanges.tests.cpp:<line number>: passed: !(mocked.derefed[4]) for: !false MatchersRanges.tests.cpp:<line number>: passed: empty_vec, SizeIs(0) for: { } has size == 0 MatchersRanges.tests.cpp:<line number>: passed: empty_vec, !SizeIs(2) for: { } not has size == 2 MatchersRanges.tests.cpp:<line number>: passed: empty_vec, SizeIs(Lt(2)) for: { } size matches is less than 2 @@ -1668,24 +1713,6 @@ MatchersRanges.tests.cpp:<line number>: passed: arr, !SizeIs(!Lt(3)) for: { 0, 0 MatchersRanges.tests.cpp:<line number>: passed: map, SizeIs(3) for: { {?}, {?}, {?} } has size == 3 MatchersRanges.tests.cpp:<line number>: passed: unrelated::ADL_size{}, SizeIs(12) for: {?} has size == 12 MatchersRanges.tests.cpp:<line number>: passed: has_size{}, SizeIs(13) for: {?} has size == 13 -MatchersRanges.tests.cpp:<line number>: passed: int_arr_arr, AllMatch(Contains(0)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } all match contains element 0 -MatchersRanges.tests.cpp:<line number>: passed: int_arr_arr, AllMatch(SizeIs(5)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } all match has size == 5 -MatchersRanges.tests.cpp:<line number>: passed: string_vector, AllMatch(StartsWith("C")) for: { "Command+", "Catch2+", "CMake+", "C++", "Console+" } all match starts with: "C" -MatchersRanges.tests.cpp:<line number>: passed: string_vector, AllMatch(EndsWith("+")) for: { "Command+", "Catch2+", "CMake+", "C++", "Console+" } all match ends with: "+" -MatchersRanges.tests.cpp:<line number>: passed: int_vectors_list, AllMatch(!IsEmpty()) for: { { 1, 2 }, { 3, 4 }, { 5, 6 } } all match not is empty -MatchersRanges.tests.cpp:<line number>: passed: int_vectors_list, AllMatch(SizeIs(2)) for: { { 1, 2 }, { 3, 4 }, { 5, 6 } } all match has size == 2 -MatchersRanges.tests.cpp:<line number>: passed: int_arr_arr, AnyMatch(Contains(-2)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } any match contains element -2 -MatchersRanges.tests.cpp:<line number>: passed: int_arr_arr, AnyMatch(SizeIs(5)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } any match has size == 5 -MatchersRanges.tests.cpp:<line number>: passed: string_vector, AnyMatch(StartsWith("CMak")) for: { "Command+", "Catch2+", "CMake+", "C++", "Console+" } any match starts with: "CMak" -MatchersRanges.tests.cpp:<line number>: passed: string_vector, AnyMatch(EndsWith("++")) for: { "Command+", "Catch2+", "CMake+", "C++", "Console+" } any match ends with: "++" -MatchersRanges.tests.cpp:<line number>: passed: int_vectors_list, AnyMatch(Contains(4)) for: { { 1, 2 }, { 3, 4 }, { 5, 6 } } any match contains element 4 -MatchersRanges.tests.cpp:<line number>: passed: int_vectors_list, AnyMatch(SizeIs(2)) for: { { 1, 2 }, { 3, 4 }, { 5, 6 } } any match has size == 2 -MatchersRanges.tests.cpp:<line number>: passed: int_arr_arr, NoneMatch(Contains(-6)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } none match contains element -6 -MatchersRanges.tests.cpp:<line number>: passed: int_arr_arr, NoneMatch(SizeIs(42)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } none match has size == 42 -MatchersRanges.tests.cpp:<line number>: passed: string_vector, NoneMatch(StartsWith("abd")) for: { "Command+", "Catch2+", "CMake+", "C++", "Console+" } none match starts with: "abd" -MatchersRanges.tests.cpp:<line number>: passed: string_vector, NoneMatch(EndsWith("#!--")) for: { "Command+", "Catch2+", "CMake+", "C++", "Console+" } none match ends with: "#!--" -MatchersRanges.tests.cpp:<line number>: passed: int_vectors_list, NoneMatch(IsEmpty()) for: { { 1, 2 }, { 3, 4 }, { 5, 6 } } none match is empty -MatchersRanges.tests.cpp:<line number>: passed: int_vectors_list, NoneMatch(SizeIs(3)) for: { { 1, 2 }, { 3, 4 }, { 5, 6 } } none match has size == 3 Approx.tests.cpp:<line number>: passed: d == approx( 1.23 ) for: 1.23 == Approx( 1.23 ) Approx.tests.cpp:<line number>: passed: d == approx( 1.22 ) for: 1.23 == Approx( 1.22 ) Approx.tests.cpp:<line number>: passed: d == approx( 1.24 ) for: 1.23 == Approx( 1.24 ) diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt index acd627ee..149bed95 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: 352 | 278 passed | 70 failed | 4 failed as expected -assertions: 2010 | 1858 passed | 131 failed | 21 failed as expected +test cases: 354 | 280 passed | 70 failed | 4 failed as expected +assertions: 2037 | 1885 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 2dd42716..08b69583 100644 --- a/tests/SelfTest/Baselines/console.sw.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.approved.txt @@ -12221,193 +12221,394 @@ with expansion: 3 == 3 ------------------------------------------------------------------------------- -Usage of the SizeIs range matcher - Some with stdlib containers +Usage of AllMatch range matcher + Basic usage ------------------------------------------------------------------------------- MatchersRanges.tests.cpp:<line number> ............................................................................... MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( empty_vec, SizeIs(0) ) + REQUIRE_THAT( data, AllMatch(SizeIs(5)) ) with expansion: - { } has size == 0 + { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 + }, { 1, 0, 0, -1, 5 } } all match has size == 5 MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( empty_vec, !SizeIs(2) ) + REQUIRE_THAT( data, !AllMatch(Contains(0) && Contains(1)) ) with expansion: - { } not has size == 2 + { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 + }, { 1, 0, 0, -1, 5 } } not all match ( contains element 0 and contains + element 1 ) + +------------------------------------------------------------------------------- +Usage of AllMatch range matcher + Type requires ADL found begin and end +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp:<line number> +............................................................................... MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( empty_vec, SizeIs(Lt(2)) ) + REQUIRE_THAT( needs_adl, AllMatch( Predicate<int>( []( int elem ) { return elem < 6; } ) ) ) with expansion: - { } size matches is less than 2 + { 1, 2, 3, 4, 5 } all match matches undescribed predicate + +------------------------------------------------------------------------------- +Usage of AllMatch range matcher + Shortcircuiting + All are read +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp:<line number> +............................................................................... MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( arr, SizeIs(2) ) + REQUIRE_THAT( mocked, allMatch ) with expansion: - { 0, 0 } has size == 2 + { 1, 2, 3, 4, 5 } all match matches undescribed predicate MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( arr, SizeIs( Lt(3)) ) + REQUIRE( mocked.derefed[0] ) with expansion: - { 0, 0 } size matches is less than 3 + true MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( arr, !SizeIs(!Lt(3)) ) + REQUIRE( mocked.derefed[1] ) with expansion: - { 0, 0 } not size matches not is less than 3 + true MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( map, SizeIs(3) ) + REQUIRE( mocked.derefed[2] ) with expansion: - { {?}, {?}, {?} } has size == 3 + true + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE( mocked.derefed[3] ) +with expansion: + true + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE( mocked.derefed[4] ) +with expansion: + true ------------------------------------------------------------------------------- -Usage of the SizeIs range matcher - Type requires ADL found size free function +Usage of AllMatch range matcher + Shortcircuiting + Short-circuited ------------------------------------------------------------------------------- MatchersRanges.tests.cpp:<line number> ............................................................................... MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( unrelated::ADL_size{}, SizeIs(12) ) + REQUIRE_THAT( mocked, !allMatch ) with expansion: - {?} has size == 12 + { 1, 2, 3, 4, 5 } not all match matches undescribed predicate + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE( mocked.derefed[0] ) +with expansion: + true + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE( mocked.derefed[1] ) +with expansion: + true + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE( mocked.derefed[2] ) +with expansion: + true + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE_FALSE( mocked.derefed[3] ) +with expansion: + !false + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE_FALSE( mocked.derefed[4] ) +with expansion: + !false ------------------------------------------------------------------------------- -Usage of the SizeIs range matcher - Type has size member +Usage of AnyMatch range matcher + Basic usage ------------------------------------------------------------------------------- MatchersRanges.tests.cpp:<line number> ............................................................................... MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( has_size{}, SizeIs(13) ) + REQUIRE_THAT( data, AnyMatch(SizeIs(5)) ) with expansion: - {?} has size == 13 + { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 + }, { 1, 0, 0, -1, 5 } } any match has size == 5 + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE_THAT( data, !AnyMatch(Contains(0) && Contains(10)) ) +with expansion: + { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 + }, { 1, 0, 0, -1, 5 } } not any match ( contains element 0 and contains + element 10 ) ------------------------------------------------------------------------------- -Usage of the quantifiers matchers - Usage of the AllMatch range matcher +Usage of AnyMatch range matcher + Type requires ADL found begin and end ------------------------------------------------------------------------------- MatchersRanges.tests.cpp:<line number> ............................................................................... MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( int_arr_arr, AllMatch(Contains(0)) ) + REQUIRE_THAT( needs_adl, AnyMatch( Predicate<int>( []( int elem ) { return elem < 3; } ) ) ) with expansion: - { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 - }, { 1, 0, 0, -1, 5 } } all match contains element 0 + { 1, 2, 3, 4, 5 } any match matches undescribed predicate + +------------------------------------------------------------------------------- +Usage of AnyMatch range matcher + Shortcircuiting + All are read +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp:<line number> +............................................................................... MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( int_arr_arr, AllMatch(SizeIs(5)) ) + REQUIRE_THAT( mocked, !anyMatch ) with expansion: - { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 - }, { 1, 0, 0, -1, 5 } } all match has size == 5 + { 1, 2, 3, 4, 5 } not any match matches undescribed predicate MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( string_vector, AllMatch(StartsWith("C")) ) + REQUIRE( mocked.derefed[0] ) with expansion: - { "Command+", "Catch2+", "CMake+", "C++", "Console+" } all match starts with: - "C" + true MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( string_vector, AllMatch(EndsWith("+")) ) + REQUIRE( mocked.derefed[1] ) with expansion: - { "Command+", "Catch2+", "CMake+", "C++", "Console+" } all match ends with: - "+" + true + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE( mocked.derefed[2] ) +with expansion: + true MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( int_vectors_list, AllMatch(!IsEmpty()) ) + REQUIRE( mocked.derefed[3] ) with expansion: - { { 1, 2 }, { 3, 4 }, { 5, 6 } } all match not is empty + true MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( int_vectors_list, AllMatch(SizeIs(2)) ) + REQUIRE( mocked.derefed[4] ) with expansion: - { { 1, 2 }, { 3, 4 }, { 5, 6 } } all match has size == 2 + true ------------------------------------------------------------------------------- -Usage of the quantifiers matchers - Usage of the AnyMatch range matcher +Usage of AnyMatch range matcher + Shortcircuiting + Short-circuited ------------------------------------------------------------------------------- MatchersRanges.tests.cpp:<line number> ............................................................................... MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( int_arr_arr, AnyMatch(Contains(-2)) ) + REQUIRE_THAT( mocked, anyMatch ) with expansion: - { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 - }, { 1, 0, 0, -1, 5 } } any match contains element -2 + { 1, 2, 3, 4, 5 } any match matches undescribed predicate MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( int_arr_arr, AnyMatch(SizeIs(5)) ) + REQUIRE( mocked.derefed[0] ) with expansion: - { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 - }, { 1, 0, 0, -1, 5 } } any match has size == 5 + true MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( string_vector, AnyMatch(StartsWith("CMak")) ) + REQUIRE_FALSE( mocked.derefed[1] ) with expansion: - { "Command+", "Catch2+", "CMake+", "C++", "Console+" } any match starts with: - "CMak" + !false MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( string_vector, AnyMatch(EndsWith("++")) ) + REQUIRE_FALSE( mocked.derefed[2] ) with expansion: - { "Command+", "Catch2+", "CMake+", "C++", "Console+" } any match ends with: - "++" + !false MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( int_vectors_list, AnyMatch(Contains(4)) ) + REQUIRE_FALSE( mocked.derefed[3] ) with expansion: - { { 1, 2 }, { 3, 4 }, { 5, 6 } } any match contains element 4 + !false MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( int_vectors_list, AnyMatch(SizeIs(2)) ) + REQUIRE_FALSE( mocked.derefed[4] ) with expansion: - { { 1, 2 }, { 3, 4 }, { 5, 6 } } any match has size == 2 + !false ------------------------------------------------------------------------------- -Usage of the quantifiers matchers - Usage of the NoneMatch range matcher +Usage of NoneMatch range matcher + Basic usage ------------------------------------------------------------------------------- MatchersRanges.tests.cpp:<line number> ............................................................................... MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( int_arr_arr, NoneMatch(Contains(-6)) ) + REQUIRE_THAT( data, NoneMatch(SizeIs(6)) ) with expansion: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 - }, { 1, 0, 0, -1, 5 } } none match contains element -6 + }, { 1, 0, 0, -1, 5 } } none match has size == 6 MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( int_arr_arr, NoneMatch(SizeIs(42)) ) + REQUIRE_THAT( data, !NoneMatch(Contains(0) && Contains(1)) ) with expansion: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 - }, { 1, 0, 0, -1, 5 } } none match has size == 42 + }, { 1, 0, 0, -1, 5 } } not none match ( contains element 0 and contains + element 1 ) + +------------------------------------------------------------------------------- +Usage of NoneMatch range matcher + Type requires ADL found begin and end +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp:<line number> +............................................................................... MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( string_vector, NoneMatch(StartsWith("abd")) ) + REQUIRE_THAT( needs_adl, NoneMatch( Predicate<int>( []( int elem ) { return elem > 6; } ) ) ) with expansion: - { "Command+", "Catch2+", "CMake+", "C++", "Console+" } none match starts - with: "abd" + { 1, 2, 3, 4, 5 } none match matches undescribed predicate + +------------------------------------------------------------------------------- +Usage of NoneMatch range matcher + Shortcircuiting + All are read +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp:<line number> +............................................................................... + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE_THAT( mocked, noneMatch ) +with expansion: + { 1, 2, 3, 4, 5 } none match matches undescribed predicate + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE( mocked.derefed[0] ) +with expansion: + true + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE( mocked.derefed[1] ) +with expansion: + true + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE( mocked.derefed[2] ) +with expansion: + true MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( string_vector, NoneMatch(EndsWith("#!--")) ) + REQUIRE( mocked.derefed[3] ) with expansion: - { "Command+", "Catch2+", "CMake+", "C++", "Console+" } none match ends with: - "#!--" + true + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE( mocked.derefed[4] ) +with expansion: + true + +------------------------------------------------------------------------------- +Usage of NoneMatch range matcher + Shortcircuiting + Short-circuited +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp:<line number> +............................................................................... MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( int_vectors_list, NoneMatch(IsEmpty()) ) + REQUIRE_THAT( mocked, !noneMatch ) with expansion: - { { 1, 2 }, { 3, 4 }, { 5, 6 } } none match is empty + { 1, 2, 3, 4, 5 } not none match matches undescribed predicate MatchersRanges.tests.cpp:<line number>: PASSED: - REQUIRE_THAT( int_vectors_list, NoneMatch(SizeIs(3)) ) + REQUIRE( mocked.derefed[0] ) with expansion: - { { 1, 2 }, { 3, 4 }, { 5, 6 } } none match has size == 3 + true + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE_FALSE( mocked.derefed[1] ) +with expansion: + !false + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE_FALSE( mocked.derefed[2] ) +with expansion: + !false + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE_FALSE( mocked.derefed[3] ) +with expansion: + !false + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE_FALSE( mocked.derefed[4] ) +with expansion: + !false + +------------------------------------------------------------------------------- +Usage of the SizeIs range matcher + Some with stdlib containers +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp:<line number> +............................................................................... + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE_THAT( empty_vec, SizeIs(0) ) +with expansion: + { } has size == 0 + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE_THAT( empty_vec, !SizeIs(2) ) +with expansion: + { } not has size == 2 + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE_THAT( empty_vec, SizeIs(Lt(2)) ) +with expansion: + { } size matches is less than 2 + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE_THAT( arr, SizeIs(2) ) +with expansion: + { 0, 0 } has size == 2 + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE_THAT( arr, SizeIs( Lt(3)) ) +with expansion: + { 0, 0 } size matches is less than 3 + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE_THAT( arr, !SizeIs(!Lt(3)) ) +with expansion: + { 0, 0 } not size matches not is less than 3 + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE_THAT( map, SizeIs(3) ) +with expansion: + { {?}, {?}, {?} } has size == 3 + +------------------------------------------------------------------------------- +Usage of the SizeIs range matcher + Type requires ADL found size free function +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp:<line number> +............................................................................... + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE_THAT( unrelated::ADL_size{}, SizeIs(12) ) +with expansion: + {?} has size == 12 + +------------------------------------------------------------------------------- +Usage of the SizeIs range matcher + Type has size member +------------------------------------------------------------------------------- +MatchersRanges.tests.cpp:<line number> +............................................................................... + +MatchersRanges.tests.cpp:<line number>: PASSED: + REQUIRE_THAT( has_size{}, SizeIs(13) ) +with expansion: + {?} has size == 13 ------------------------------------------------------------------------------- Use a custom approx @@ -15804,6 +16005,6 @@ Misc.tests.cpp:<line number> Misc.tests.cpp:<line number>: PASSED: =============================================================================== -test cases: 352 | 262 passed | 86 failed | 4 failed as expected -assertions: 2027 | 1858 passed | 148 failed | 21 failed as expected +test cases: 354 | 264 passed | 86 failed | 4 failed as expected +assertions: 2054 | 1885 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 214e03e8..c7e3d02c 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="2028" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> + <testsuite name="<exe-name>" errors="17" failures="132" tests="2055" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> <properties> <property name="filters" value="~[!nonportable]~[!benchmark]~[approvals] *"/> <property name="random-seed" value="1"/> @@ -1280,12 +1280,21 @@ Exception.tests.cpp:<line number> </testcase> <testcase classname="<exe-name>.global" name="Upcasting special member functions/Move constructor" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Upcasting special member functions/move assignment" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="Usage of AllMatch range matcher/Basic usage" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="Usage of AllMatch range matcher/Type requires ADL found begin and end" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="Usage of AllMatch range matcher/Shortcircuiting/All are read" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="Usage of AllMatch range matcher/Shortcircuiting/Short-circuited" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="Usage of AnyMatch range matcher/Basic usage" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="Usage of AnyMatch range matcher/Type requires ADL found begin and end" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="Usage of AnyMatch range matcher/Shortcircuiting/All are read" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="Usage of AnyMatch range matcher/Shortcircuiting/Short-circuited" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="Usage of NoneMatch range matcher/Basic usage" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="Usage of NoneMatch range matcher/Type requires ADL found begin and end" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="Usage of NoneMatch range matcher/Shortcircuiting/All are read" time="{duration}" status="run"/> + <testcase classname="<exe-name>.global" name="Usage of NoneMatch range matcher/Shortcircuiting/Short-circuited" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Usage of the SizeIs range matcher/Some with stdlib containers" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Usage of the SizeIs range matcher/Type requires ADL found size free function" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Usage of the SizeIs range matcher/Type has size member" time="{duration}" status="run"/> - <testcase classname="<exe-name>.global" name="Usage of the quantifiers matchers/Usage of the AllMatch range matcher" time="{duration}" status="run"/> - <testcase classname="<exe-name>.global" name="Usage of the quantifiers matchers/Usage of the AnyMatch range matcher" time="{duration}" status="run"/> - <testcase classname="<exe-name>.global" name="Usage of the quantifiers matchers/Usage of the NoneMatch range matcher" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Use a custom approx" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Variadic macros/Section with one argument" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Vector Approx matcher/Empty vector is roughly equal to an empty vector" time="{duration}" status="run"/> diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt index ed78a3a9..736b1b4f 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt @@ -1265,12 +1265,21 @@ Matchers.tests.cpp:<line number> <testCase name="Basic use of the Empty range matcher/Simple, std-provided containers" duration="{duration}"/> <testCase name="Basic use of the Empty range matcher/Type with empty" duration="{duration}"/> <testCase name="Basic use of the Empty range matcher/Type requires ADL found empty free function" duration="{duration}"/> + <testCase name="Usage of AllMatch range matcher/Basic usage" duration="{duration}"/> + <testCase name="Usage of AllMatch range matcher/Type requires ADL found begin and end" duration="{duration}"/> + <testCase name="Usage of AllMatch range matcher/Shortcircuiting/All are read" duration="{duration}"/> + <testCase name="Usage of AllMatch range matcher/Shortcircuiting/Short-circuited" duration="{duration}"/> + <testCase name="Usage of AnyMatch range matcher/Basic usage" duration="{duration}"/> + <testCase name="Usage of AnyMatch range matcher/Type requires ADL found begin and end" duration="{duration}"/> + <testCase name="Usage of AnyMatch range matcher/Shortcircuiting/All are read" duration="{duration}"/> + <testCase name="Usage of AnyMatch range matcher/Shortcircuiting/Short-circuited" duration="{duration}"/> + <testCase name="Usage of NoneMatch range matcher/Basic usage" duration="{duration}"/> + <testCase name="Usage of NoneMatch range matcher/Type requires ADL found begin and end" duration="{duration}"/> + <testCase name="Usage of NoneMatch range matcher/Shortcircuiting/All are read" duration="{duration}"/> + <testCase name="Usage of NoneMatch range matcher/Shortcircuiting/Short-circuited" duration="{duration}"/> <testCase name="Usage of the SizeIs range matcher/Some with stdlib containers" duration="{duration}"/> <testCase name="Usage of the SizeIs range matcher/Type requires ADL found size free function" duration="{duration}"/> <testCase name="Usage of the SizeIs range matcher/Type has size member" duration="{duration}"/> - <testCase name="Usage of the quantifiers matchers/Usage of the AllMatch range matcher" duration="{duration}"/> - <testCase name="Usage of the quantifiers matchers/Usage of the AnyMatch range matcher" duration="{duration}"/> - <testCase name="Usage of the quantifiers matchers/Usage of the NoneMatch range matcher" duration="{duration}"/> </file> <file path="tests/<exe-name>/UsageTests/Message.tests.cpp"> <testCase name="#1455 - INFO and WARN can start with a linebreak" duration="{duration}"/> diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt index 3b32341b..40fa0125 100644 --- a/tests/SelfTest/Baselines/tap.sw.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.approved.txt @@ -3161,6 +3161,96 @@ not ok {test-number} - unexpected exception with message: '3.14' ok {test-number} - bptr->i == 3 for: 3 == 3 # Upcasting special member functions ok {test-number} - bptr->i == 3 for: 3 == 3 +# Usage of AllMatch range matcher +ok {test-number} - data, AllMatch(SizeIs(5)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } all match has size == 5 +# Usage of AllMatch range matcher +ok {test-number} - data, !AllMatch(Contains(0) && Contains(1)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } not all match ( contains element 0 and contains element 1 ) +# Usage of AllMatch range matcher +ok {test-number} - needs_adl, AllMatch( Predicate<int>( []( int elem ) { return elem < 6; } ) ) for: { 1, 2, 3, 4, 5 } all match matches undescribed predicate +# Usage of AllMatch range matcher +ok {test-number} - mocked, allMatch for: { 1, 2, 3, 4, 5 } all match matches undescribed predicate +# Usage of AllMatch range matcher +ok {test-number} - mocked.derefed[0] for: true +# Usage of AllMatch range matcher +ok {test-number} - mocked.derefed[1] for: true +# Usage of AllMatch range matcher +ok {test-number} - mocked.derefed[2] for: true +# Usage of AllMatch range matcher +ok {test-number} - mocked.derefed[3] for: true +# Usage of AllMatch range matcher +ok {test-number} - mocked.derefed[4] for: true +# Usage of AllMatch range matcher +ok {test-number} - mocked, !allMatch for: { 1, 2, 3, 4, 5 } not all match matches undescribed predicate +# Usage of AllMatch range matcher +ok {test-number} - mocked.derefed[0] for: true +# Usage of AllMatch range matcher +ok {test-number} - mocked.derefed[1] for: true +# Usage of AllMatch range matcher +ok {test-number} - mocked.derefed[2] for: true +# Usage of AllMatch range matcher +ok {test-number} - !(mocked.derefed[3]) for: !false +# Usage of AllMatch range matcher +ok {test-number} - !(mocked.derefed[4]) for: !false +# Usage of AnyMatch range matcher +ok {test-number} - data, AnyMatch(SizeIs(5)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } any match has size == 5 +# Usage of AnyMatch range matcher +ok {test-number} - data, !AnyMatch(Contains(0) && Contains(10)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } not any match ( contains element 0 and contains element 10 ) +# Usage of AnyMatch range matcher +ok {test-number} - needs_adl, AnyMatch( Predicate<int>( []( int elem ) { return elem < 3; } ) ) for: { 1, 2, 3, 4, 5 } any match matches undescribed predicate +# Usage of AnyMatch range matcher +ok {test-number} - mocked, !anyMatch for: { 1, 2, 3, 4, 5 } not any match matches undescribed predicate +# Usage of AnyMatch range matcher +ok {test-number} - mocked.derefed[0] for: true +# Usage of AnyMatch range matcher +ok {test-number} - mocked.derefed[1] for: true +# Usage of AnyMatch range matcher +ok {test-number} - mocked.derefed[2] for: true +# Usage of AnyMatch range matcher +ok {test-number} - mocked.derefed[3] for: true +# Usage of AnyMatch range matcher +ok {test-number} - mocked.derefed[4] for: true +# Usage of AnyMatch range matcher +ok {test-number} - mocked, anyMatch for: { 1, 2, 3, 4, 5 } any match matches undescribed predicate +# Usage of AnyMatch range matcher +ok {test-number} - mocked.derefed[0] for: true +# Usage of AnyMatch range matcher +ok {test-number} - !(mocked.derefed[1]) for: !false +# Usage of AnyMatch range matcher +ok {test-number} - !(mocked.derefed[2]) for: !false +# Usage of AnyMatch range matcher +ok {test-number} - !(mocked.derefed[3]) for: !false +# Usage of AnyMatch range matcher +ok {test-number} - !(mocked.derefed[4]) for: !false +# Usage of NoneMatch range matcher +ok {test-number} - data, NoneMatch(SizeIs(6)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } none match has size == 6 +# Usage of NoneMatch range matcher +ok {test-number} - data, !NoneMatch(Contains(0) && Contains(1)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } not none match ( contains element 0 and contains element 1 ) +# Usage of NoneMatch range matcher +ok {test-number} - needs_adl, NoneMatch( Predicate<int>( []( int elem ) { return elem > 6; } ) ) for: { 1, 2, 3, 4, 5 } none match matches undescribed predicate +# Usage of NoneMatch range matcher +ok {test-number} - mocked, noneMatch for: { 1, 2, 3, 4, 5 } none match matches undescribed predicate +# Usage of NoneMatch range matcher +ok {test-number} - mocked.derefed[0] for: true +# Usage of NoneMatch range matcher +ok {test-number} - mocked.derefed[1] for: true +# Usage of NoneMatch range matcher +ok {test-number} - mocked.derefed[2] for: true +# Usage of NoneMatch range matcher +ok {test-number} - mocked.derefed[3] for: true +# Usage of NoneMatch range matcher +ok {test-number} - mocked.derefed[4] for: true +# Usage of NoneMatch range matcher +ok {test-number} - mocked, !noneMatch for: { 1, 2, 3, 4, 5 } not none match matches undescribed predicate +# Usage of NoneMatch range matcher +ok {test-number} - mocked.derefed[0] for: true +# Usage of NoneMatch range matcher +ok {test-number} - !(mocked.derefed[1]) for: !false +# Usage of NoneMatch range matcher +ok {test-number} - !(mocked.derefed[2]) for: !false +# Usage of NoneMatch range matcher +ok {test-number} - !(mocked.derefed[3]) for: !false +# Usage of NoneMatch range matcher +ok {test-number} - !(mocked.derefed[4]) for: !false # Usage of the SizeIs range matcher ok {test-number} - empty_vec, SizeIs(0) for: { } has size == 0 # Usage of the SizeIs range matcher @@ -3179,42 +3269,6 @@ ok {test-number} - map, SizeIs(3) for: { {?}, {?}, {?} } has size == 3 ok {test-number} - unrelated::ADL_size{}, SizeIs(12) for: {?} has size == 12 # Usage of the SizeIs range matcher ok {test-number} - has_size{}, SizeIs(13) for: {?} has size == 13 -# Usage of the quantifiers matchers -ok {test-number} - int_arr_arr, AllMatch(Contains(0)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } all match contains element 0 -# Usage of the quantifiers matchers -ok {test-number} - int_arr_arr, AllMatch(SizeIs(5)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } all match has size == 5 -# Usage of the quantifiers matchers -ok {test-number} - string_vector, AllMatch(StartsWith("C")) for: { "Command+", "Catch2+", "CMake+", "C++", "Console+" } all match starts with: "C" -# Usage of the quantifiers matchers -ok {test-number} - string_vector, AllMatch(EndsWith("+")) for: { "Command+", "Catch2+", "CMake+", "C++", "Console+" } all match ends with: "+" -# Usage of the quantifiers matchers -ok {test-number} - int_vectors_list, AllMatch(!IsEmpty()) for: { { 1, 2 }, { 3, 4 }, { 5, 6 } } all match not is empty -# Usage of the quantifiers matchers -ok {test-number} - int_vectors_list, AllMatch(SizeIs(2)) for: { { 1, 2 }, { 3, 4 }, { 5, 6 } } all match has size == 2 -# Usage of the quantifiers matchers -ok {test-number} - int_arr_arr, AnyMatch(Contains(-2)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } any match contains element -2 -# Usage of the quantifiers matchers -ok {test-number} - int_arr_arr, AnyMatch(SizeIs(5)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } any match has size == 5 -# Usage of the quantifiers matchers -ok {test-number} - string_vector, AnyMatch(StartsWith("CMak")) for: { "Command+", "Catch2+", "CMake+", "C++", "Console+" } any match starts with: "CMak" -# Usage of the quantifiers matchers -ok {test-number} - string_vector, AnyMatch(EndsWith("++")) for: { "Command+", "Catch2+", "CMake+", "C++", "Console+" } any match ends with: "++" -# Usage of the quantifiers matchers -ok {test-number} - int_vectors_list, AnyMatch(Contains(4)) for: { { 1, 2 }, { 3, 4 }, { 5, 6 } } any match contains element 4 -# Usage of the quantifiers matchers -ok {test-number} - int_vectors_list, AnyMatch(SizeIs(2)) for: { { 1, 2 }, { 3, 4 }, { 5, 6 } } any match has size == 2 -# Usage of the quantifiers matchers -ok {test-number} - int_arr_arr, NoneMatch(Contains(-6)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } none match contains element -6 -# Usage of the quantifiers matchers -ok {test-number} - int_arr_arr, NoneMatch(SizeIs(42)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } none match has size == 42 -# Usage of the quantifiers matchers -ok {test-number} - string_vector, NoneMatch(StartsWith("abd")) for: { "Command+", "Catch2+", "CMake+", "C++", "Console+" } none match starts with: "abd" -# Usage of the quantifiers matchers -ok {test-number} - string_vector, NoneMatch(EndsWith("#!--")) for: { "Command+", "Catch2+", "CMake+", "C++", "Console+" } none match ends with: "#!--" -# Usage of the quantifiers matchers -ok {test-number} - int_vectors_list, NoneMatch(IsEmpty()) for: { { 1, 2 }, { 3, 4 }, { 5, 6 } } none match is empty -# Usage of the quantifiers matchers -ok {test-number} - int_vectors_list, NoneMatch(SizeIs(3)) for: { { 1, 2 }, { 3, 4 }, { 5, 6 } } none match has size == 3 # Use a custom approx ok {test-number} - d == approx( 1.23 ) for: 1.23 == Approx( 1.23 ) # Use a custom approx @@ -4046,5 +4100,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0 ok {test-number} - # xmlentitycheck ok {test-number} - -1..2027 +1..2054 diff --git a/tests/SelfTest/Baselines/teamcity.sw.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.approved.txt index 09b426b7..413e5153 100644 --- a/tests/SelfTest/Baselines/teamcity.sw.approved.txt +++ b/tests/SelfTest/Baselines/teamcity.sw.approved.txt @@ -577,10 +577,14 @@ Exception.tests.cpp:<line number>|nunexpected exception with message:|n "3.14"' ##teamcity[testFinished name='Unexpected exceptions can be translated' duration="{duration}"] ##teamcity[testStarted name='Upcasting special member functions'] ##teamcity[testFinished name='Upcasting special member functions' duration="{duration}"] +##teamcity[testStarted name='Usage of AllMatch range matcher'] +##teamcity[testFinished name='Usage of AllMatch range matcher' duration="{duration}"] +##teamcity[testStarted name='Usage of AnyMatch range matcher'] +##teamcity[testFinished name='Usage of AnyMatch range matcher' duration="{duration}"] +##teamcity[testStarted name='Usage of NoneMatch range matcher'] +##teamcity[testFinished name='Usage of NoneMatch range matcher' duration="{duration}"] ##teamcity[testStarted name='Usage of the SizeIs range matcher'] ##teamcity[testFinished name='Usage of the SizeIs range matcher' duration="{duration}"] -##teamcity[testStarted name='Usage of the quantifiers matchers'] -##teamcity[testFinished name='Usage of the quantifiers matchers' duration="{duration}"] ##teamcity[testStarted name='Use a custom approx'] ##teamcity[testFinished name='Use a custom approx' duration="{duration}"] ##teamcity[testStarted name='Variadic macros'] diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt index a9de7c7e..ecaa869b 100644 --- a/tests/SelfTest/Baselines/xml.sw.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.approved.txt @@ -14536,243 +14536,510 @@ There is no extra whitespace here </Section> <OverallResult success="true"/> </TestCase> - <TestCase name="Usage of the SizeIs range matcher" tags="[matchers][size][templated]" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > - <Section name="Some with stdlib containers" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > - <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > - <Original> - empty_vec, SizeIs(0) - </Original> - <Expanded> - { } has size == 0 - </Expanded> - </Expression> + <TestCase name="Usage of AllMatch range matcher" tags="[matchers][quantifiers][templated]" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Section name="Basic usage" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Original> - empty_vec, !SizeIs(2) + data, AllMatch(SizeIs(5)) </Original> <Expanded> - { } not has size == 2 - </Expanded> - </Expression> - <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > - <Original> - empty_vec, SizeIs(Lt(2)) - </Original> - <Expanded> - { } size matches is less than 2 - </Expanded> - </Expression> - <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > - <Original> - arr, SizeIs(2) - </Original> - <Expanded> - { 0, 0 } has size == 2 - </Expanded> - </Expression> - <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > - <Original> - arr, SizeIs( Lt(3)) - </Original> - <Expanded> - { 0, 0 } size matches is less than 3 + { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } all match has size == 5 </Expanded> </Expression> <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Original> - arr, !SizeIs(!Lt(3)) + data, !AllMatch(Contains(0) && Contains(1)) </Original> <Expanded> - { 0, 0 } not size matches not is less than 3 + { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } not all match ( contains element 0 and contains element 1 ) </Expanded> </Expression> - <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > - <Original> - map, SizeIs(3) - </Original> - <Expanded> - { {?}, {?}, {?} } has size == 3 - </Expanded> - </Expression> - <OverallResults successes="7" failures="0" expectedFailures="0"/> + <OverallResults successes="2" failures="0" expectedFailures="0"/> </Section> - <Section name="Type requires ADL found size free function" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Section name="Type requires ADL found begin and end" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Original> - unrelated::ADL_size{}, SizeIs(12) + needs_adl, AllMatch( Predicate<int>( []( int elem ) { return elem < 6; } ) ) </Original> <Expanded> - {?} has size == 12 + { 1, 2, 3, 4, 5 } all match matches undescribed predicate </Expanded> </Expression> <OverallResults successes="1" failures="0" expectedFailures="0"/> </Section> - <Section name="Type has size member" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > - <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > - <Original> - has_size{}, SizeIs(13) - </Original> - <Expanded> - {?} has size == 13 - </Expanded> - </Expression> - <OverallResults successes="1" failures="0" expectedFailures="0"/> + <Section name="Shortcircuiting" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Section name="All are read" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked, allMatch + </Original> + <Expanded> + { 1, 2, 3, 4, 5 } all match matches undescribed predicate + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked.derefed[0] + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked.derefed[1] + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked.derefed[2] + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked.derefed[3] + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked.derefed[4] + </Original> + <Expanded> + true + </Expanded> + </Expression> + <OverallResults successes="6" failures="0" expectedFailures="0"/> + </Section> + <OverallResults successes="6" failures="0" expectedFailures="0"/> + </Section> + <Section name="Shortcircuiting" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Section name="Short-circuited" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked, !allMatch + </Original> + <Expanded> + { 1, 2, 3, 4, 5 } not all match matches undescribed predicate + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked.derefed[0] + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked.derefed[1] + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked.derefed[2] + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE_FALSE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + !(mocked.derefed[3]) + </Original> + <Expanded> + !false + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE_FALSE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + !(mocked.derefed[4]) + </Original> + <Expanded> + !false + </Expanded> + </Expression> + <OverallResults successes="6" failures="0" expectedFailures="0"/> + </Section> + <OverallResults successes="6" failures="0" expectedFailures="0"/> </Section> <OverallResult success="true"/> </TestCase> - <TestCase name="Usage of the quantifiers matchers" tags="[matchers][quantifiers][templated]" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > - <Section name="Usage of the AllMatch range matcher" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > - <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > - <Original> - int_arr_arr, AllMatch(Contains(0)) - </Original> - <Expanded> - { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } all match contains element 0 - </Expanded> - </Expression> - <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > - <Original> - int_arr_arr, AllMatch(SizeIs(5)) - </Original> - <Expanded> - { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } all match has size == 5 - </Expanded> - </Expression> - <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > - <Original> - string_vector, AllMatch(StartsWith("C")) - </Original> - <Expanded> - { "Command+", "Catch2+", "CMake+", "C++", "Console+" } all match starts with: "C" - </Expanded> - </Expression> + <TestCase name="Usage of AnyMatch range matcher" tags="[matchers][quantifiers][templated]" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Section name="Basic usage" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Original> - string_vector, AllMatch(EndsWith("+")) + data, AnyMatch(SizeIs(5)) </Original> <Expanded> - { "Command+", "Catch2+", "CMake+", "C++", "Console+" } all match ends with: "+" + { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } any match has size == 5 </Expanded> </Expression> <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Original> - int_vectors_list, AllMatch(!IsEmpty()) + data, !AnyMatch(Contains(0) && Contains(10)) </Original> <Expanded> - { { 1, 2 }, { 3, 4 }, { 5, 6 } } all match not is empty + { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } not any match ( contains element 0 and contains element 10 ) </Expanded> </Expression> + <OverallResults successes="2" failures="0" expectedFailures="0"/> + </Section> + <Section name="Type requires ADL found begin and end" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Original> - int_vectors_list, AllMatch(SizeIs(2)) + needs_adl, AnyMatch( Predicate<int>( []( int elem ) { return elem < 3; } ) ) </Original> <Expanded> - { { 1, 2 }, { 3, 4 }, { 5, 6 } } all match has size == 2 + { 1, 2, 3, 4, 5 } any match matches undescribed predicate </Expanded> </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0"/> + </Section> + <Section name="Shortcircuiting" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Section name="All are read" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked, !anyMatch + </Original> + <Expanded> + { 1, 2, 3, 4, 5 } not any match matches undescribed predicate + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked.derefed[0] + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked.derefed[1] + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked.derefed[2] + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked.derefed[3] + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked.derefed[4] + </Original> + <Expanded> + true + </Expanded> + </Expression> + <OverallResults successes="6" failures="0" expectedFailures="0"/> + </Section> <OverallResults successes="6" failures="0" expectedFailures="0"/> </Section> - <Section name="Usage of the AnyMatch range matcher" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Section name="Shortcircuiting" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Section name="Short-circuited" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked, anyMatch + </Original> + <Expanded> + { 1, 2, 3, 4, 5 } any match matches undescribed predicate + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked.derefed[0] + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE_FALSE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + !(mocked.derefed[1]) + </Original> + <Expanded> + !false + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE_FALSE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + !(mocked.derefed[2]) + </Original> + <Expanded> + !false + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE_FALSE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + !(mocked.derefed[3]) + </Original> + <Expanded> + !false + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE_FALSE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + !(mocked.derefed[4]) + </Original> + <Expanded> + !false + </Expanded> + </Expression> + <OverallResults successes="6" failures="0" expectedFailures="0"/> + </Section> + <OverallResults successes="6" failures="0" expectedFailures="0"/> + </Section> + <OverallResult success="true"/> + </TestCase> + <TestCase name="Usage of NoneMatch range matcher" tags="[matchers][quantifiers][templated]" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Section name="Basic usage" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Original> - int_arr_arr, AnyMatch(Contains(-2)) + data, NoneMatch(SizeIs(6)) </Original> <Expanded> - { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } any match contains element -2 + { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } none match has size == 6 </Expanded> </Expression> <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Original> - int_arr_arr, AnyMatch(SizeIs(5)) + data, !NoneMatch(Contains(0) && Contains(1)) </Original> <Expanded> - { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } any match has size == 5 + { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } not none match ( contains element 0 and contains element 1 ) </Expanded> </Expression> + <OverallResults successes="2" failures="0" expectedFailures="0"/> + </Section> + <Section name="Type requires ADL found begin and end" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Original> - string_vector, AnyMatch(StartsWith("CMak")) + needs_adl, NoneMatch( Predicate<int>( []( int elem ) { return elem > 6; } ) ) </Original> <Expanded> - { "Command+", "Catch2+", "CMake+", "C++", "Console+" } any match starts with: "CMak" + { 1, 2, 3, 4, 5 } none match matches undescribed predicate </Expanded> </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0"/> + </Section> + <Section name="Shortcircuiting" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Section name="All are read" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked, noneMatch + </Original> + <Expanded> + { 1, 2, 3, 4, 5 } none match matches undescribed predicate + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked.derefed[0] + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked.derefed[1] + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked.derefed[2] + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked.derefed[3] + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked.derefed[4] + </Original> + <Expanded> + true + </Expanded> + </Expression> + <OverallResults successes="6" failures="0" expectedFailures="0"/> + </Section> + <OverallResults successes="6" failures="0" expectedFailures="0"/> + </Section> + <Section name="Shortcircuiting" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Section name="Short-circuited" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked, !noneMatch + </Original> + <Expanded> + { 1, 2, 3, 4, 5 } not none match matches undescribed predicate + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + mocked.derefed[0] + </Original> + <Expanded> + true + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE_FALSE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + !(mocked.derefed[1]) + </Original> + <Expanded> + !false + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE_FALSE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + !(mocked.derefed[2]) + </Original> + <Expanded> + !false + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE_FALSE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + !(mocked.derefed[3]) + </Original> + <Expanded> + !false + </Expanded> + </Expression> + <Expression success="true" type="REQUIRE_FALSE" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Original> + !(mocked.derefed[4]) + </Original> + <Expanded> + !false + </Expanded> + </Expression> + <OverallResults successes="6" failures="0" expectedFailures="0"/> + </Section> + <OverallResults successes="6" failures="0" expectedFailures="0"/> + </Section> + <OverallResult success="true"/> + </TestCase> + <TestCase name="Usage of the SizeIs range matcher" tags="[matchers][size][templated]" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > + <Section name="Some with stdlib containers" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Original> - string_vector, AnyMatch(EndsWith("++")) + empty_vec, SizeIs(0) </Original> <Expanded> - { "Command+", "Catch2+", "CMake+", "C++", "Console+" } any match ends with: "++" + { } has size == 0 </Expanded> </Expression> <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Original> - int_vectors_list, AnyMatch(Contains(4)) + empty_vec, !SizeIs(2) </Original> <Expanded> - { { 1, 2 }, { 3, 4 }, { 5, 6 } } any match contains element 4 + { } not has size == 2 </Expanded> </Expression> <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Original> - int_vectors_list, AnyMatch(SizeIs(2)) + empty_vec, SizeIs(Lt(2)) </Original> <Expanded> - { { 1, 2 }, { 3, 4 }, { 5, 6 } } any match has size == 2 + { } size matches is less than 2 </Expanded> </Expression> - <OverallResults successes="6" failures="0" expectedFailures="0"/> - </Section> - <Section name="Usage of the NoneMatch range matcher" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Original> - int_arr_arr, NoneMatch(Contains(-6)) + arr, SizeIs(2) </Original> <Expanded> - { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } none match contains element -6 + { 0, 0 } has size == 2 </Expanded> </Expression> <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Original> - int_arr_arr, NoneMatch(SizeIs(42)) + arr, SizeIs( Lt(3)) </Original> <Expanded> - { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } none match has size == 42 + { 0, 0 } size matches is less than 3 </Expanded> </Expression> <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Original> - string_vector, NoneMatch(StartsWith("abd")) + arr, !SizeIs(!Lt(3)) </Original> <Expanded> - { "Command+", "Catch2+", "CMake+", "C++", "Console+" } none match starts with: "abd" + { 0, 0 } not size matches not is less than 3 </Expanded> </Expression> <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Original> - string_vector, NoneMatch(EndsWith("#!--")) + map, SizeIs(3) </Original> <Expanded> - { "Command+", "Catch2+", "CMake+", "C++", "Console+" } none match ends with: "#!--" + { {?}, {?}, {?} } has size == 3 </Expanded> </Expression> + <OverallResults successes="7" failures="0" expectedFailures="0"/> + </Section> + <Section name="Type requires ADL found size free function" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Original> - int_vectors_list, NoneMatch(IsEmpty()) + unrelated::ADL_size{}, SizeIs(12) </Original> <Expanded> - { { 1, 2 }, { 3, 4 }, { 5, 6 } } none match is empty + {?} has size == 12 </Expanded> </Expression> + <OverallResults successes="1" failures="0" expectedFailures="0"/> + </Section> + <Section name="Type has size member" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" > <Original> - int_vectors_list, NoneMatch(SizeIs(3)) + has_size{}, SizeIs(13) </Original> <Expanded> - { { 1, 2 }, { 3, 4 }, { 5, 6 } } none match has size == 3 + {?} has size == 13 </Expanded> </Expression> - <OverallResults successes="6" failures="0" expectedFailures="0"/> + <OverallResults successes="1" failures="0" expectedFailures="0"/> </Section> <OverallResult success="true"/> </TestCase> @@ -18754,9 +19021,9 @@ loose text artifact </Section> <OverallResult success="true"/> </TestCase> - <OverallResults successes="1858" failures="149" expectedFailures="21"/> - <OverallResultsCases successes="262" failures="86" expectedFailures="4"/> + <OverallResults successes="1885" failures="149" expectedFailures="21"/> + <OverallResultsCases successes="264" failures="86" expectedFailures="4"/> </Group> - <OverallResults successes="1858" failures="148" expectedFailures="21"/> - <OverallResultsCases successes="262" failures="86" expectedFailures="4"/> + <OverallResults successes="1885" failures="148" expectedFailures="21"/> + <OverallResultsCases successes="264" failures="86" expectedFailures="4"/> </Catch> diff --git a/tests/SelfTest/UsageTests/MatchersRanges.tests.cpp b/tests/SelfTest/UsageTests/MatchersRanges.tests.cpp index 13b546e3..912b5cdb 100644 --- a/tests/SelfTest/UsageTests/MatchersRanges.tests.cpp +++ b/tests/SelfTest/UsageTests/MatchersRanges.tests.cpp @@ -6,6 +6,7 @@ #include <catch2/matchers/catch_matchers_contains.hpp> #include <catch2/matchers/catch_matchers_floating_point.hpp> #include <catch2/matchers/catch_matchers_quantifiers.hpp> +#include <catch2/matchers/catch_matchers_predicate.hpp> #include <catch2/matchers/catch_matchers_string.hpp> #include <array> @@ -33,8 +34,143 @@ namespace unrelated { } }; } // end unrelated namespace + +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wunused-function" +#endif + +class has_different_begin_end_types { + std::array<int, 5> elements{ {1, 2, 3, 4, 5} }; + + // Different type for the "end" iterator + struct iterator_end {}; + // Just a fake forward iterator, that only compares to a different + // type (so we can test two-type ranges). + struct iterator { + int const* start; + int const* end; + + using iterator_category = std::forward_iterator_tag; + using difference_type = std::ptrdiff_t; + using value_type = int; + using reference = int const&; + using pointer = int const*; + + + friend bool operator==( iterator iter, iterator_end ) { + return iter.start == iter.end; + } + friend bool operator!=( iterator iter, iterator_end ) { + return iter.start != iter.end; + } + iterator& operator++() { + ++start; + return *this; + } + iterator operator++(int) { + auto tmp(*this); + ++start; + return tmp; + } + reference operator*() const { + return *start; + } + pointer operator->() const { + return start; + } + }; + + +public: + iterator begin() const { + return { elements.data(), elements.data() + elements.size() }; + } + + iterator_end end() const { + return {}; + } +}; + +#if defined(__clang__) +# pragma clang diagnostic pop +#endif + + +struct with_mocked_iterator_access { + static constexpr size_t data_size = 5; + std::array<int, data_size> elements{ {1, 2, 3, 4, 5} }; + std::array<bool, data_size> touched{}; + std::array<bool, data_size> derefed{}; + + // We want to check which elements were touched when iterating, so + // we can check whether iterator-using code traverses range correctly + struct iterator { + with_mocked_iterator_access* m_origin; + size_t m_origin_idx; + + using iterator_category = std::forward_iterator_tag; + using difference_type = std::ptrdiff_t; + using value_type = int; + using reference = int const&; + using pointer = int const*; + + friend bool operator==(iterator lhs, iterator rhs) { + return lhs.m_origin == rhs.m_origin + && lhs.m_origin_idx == rhs.m_origin_idx; + } + friend bool operator!=(iterator lhs, iterator rhs) { + return !(lhs == rhs); + } + iterator& operator++() { + ++m_origin_idx; + assert(m_origin_idx < data_size + 1 && "Outside of valid alloc"); + if (m_origin_idx < data_size) { + m_origin->touched[m_origin_idx] = true; + } + return *this; + } + iterator operator++(int) { + auto tmp(*this); + ++(*this); + return tmp; + } + reference operator*() const { + assert(m_origin_idx < data_size && "Attempted to deref invalid position"); + m_origin->derefed[m_origin_idx] = true; + return m_origin->elements[m_origin_idx]; + } + pointer operator->() const { + assert(m_origin_idx < data_size && "Attempted to deref invalid position"); + return &m_origin->elements[m_origin_idx]; + } + + }; + + iterator begin() const { + // Const-cast away to avoid overcomplicating the iterators + // We should actually fix this over time + return { const_cast<with_mocked_iterator_access*>(this), 0 }; + } + iterator end() const { + return { const_cast<with_mocked_iterator_access*>(this), data_size }; + } + +}; + } // end anon namespace +namespace Catch { + template <> + struct StringMaker<with_mocked_iterator_access> { + static std::string convert(with_mocked_iterator_access const& access) { + // We have to avoid the type's iterators, because we check + // their use in tests + return ::Catch::Detail::stringify(access.elements); + } + }; +} + struct MoveOnlyTestElement { int num = 0; MoveOnlyTestElement(int n) :num(n) {} @@ -220,55 +356,190 @@ TEST_CASE("Usage of the SizeIs range matcher", "[matchers][templated][size]") { } } -TEST_CASE("Usage of the quantifiers matchers", "[matchers][templated][quantifiers]") { + +TEST_CASE("Usage of AllMatch range matcher", "[matchers][templated][quantifiers]") { using Catch::Matchers::AllMatch; - using Catch::Matchers::AnyMatch; - using Catch::Matchers::Contains; - using Catch::Matchers::EndsWith; - using Catch::Matchers::IsEmpty; - using Catch::Matchers::NoneMatch; - using Catch::Matchers::SizeIs; - using Catch::Matchers::StartsWith; - std::array<std::array<int, 5>, 5> int_arr_arr{{ - {{ 0, 1, 2, 3, 5 }}, - {{ 4,-3,-2, 5, 0 }}, - {{ 0, 0, 0, 5, 0 }}, - {{ 0,-5, 0, 5, 0 }}, - {{ 1, 0, 0,-1, 5 }} - }}; - std::vector<std::string> string_vector{ "Command+", "Catch2+", "CMake+", "C++", "Console+" }; - std::list<std::vector<int>> int_vectors_list{ { 1, 2 }, { 3, 4 }, { 5, 6 } }; - - SECTION("Usage of the AllMatch range matcher") { - REQUIRE_THAT(int_arr_arr, AllMatch(Contains(0))); - REQUIRE_THAT(int_arr_arr, AllMatch(SizeIs(5))); - - REQUIRE_THAT(string_vector, AllMatch(StartsWith("C"))); - REQUIRE_THAT(string_vector, AllMatch(EndsWith("+"))); - - REQUIRE_THAT(int_vectors_list, AllMatch(!IsEmpty())); - REQUIRE_THAT(int_vectors_list, AllMatch(SizeIs(2))); + using Catch::Matchers::Predicate; + + SECTION("Basic usage") { + using Catch::Matchers::Contains; + using Catch::Matchers::SizeIs; + + std::array<std::array<int, 5>, 5> data{{ + {{ 0, 1, 2, 3, 5 }}, + {{ 4,-3,-2, 5, 0 }}, + {{ 0, 0, 0, 5, 0 }}, + {{ 0,-5, 0, 5, 0 }}, + {{ 1, 0, 0,-1, 5 }} + }}; + + REQUIRE_THAT(data, AllMatch(SizeIs(5))); + REQUIRE_THAT(data, !AllMatch(Contains(0) && Contains(1))); } - SECTION("Usage of the AnyMatch range matcher") { - REQUIRE_THAT(int_arr_arr, AnyMatch(Contains(-2))); - REQUIRE_THAT(int_arr_arr, AnyMatch(SizeIs(5))); + SECTION("Type requires ADL found begin and end") { + unrelated::needs_ADL_begin needs_adl; + REQUIRE_THAT( needs_adl, AllMatch( Predicate<int>( []( int elem ) { + return elem < 6; + } ) ) ); + } + + SECTION("Shortcircuiting") { + with_mocked_iterator_access mocked; + SECTION("All are read") { + auto allMatch = AllMatch(Predicate<int>([](int elem) { + return elem < 10; + })); + REQUIRE_THAT(mocked, allMatch); + REQUIRE(mocked.derefed[0]); + REQUIRE(mocked.derefed[1]); + REQUIRE(mocked.derefed[2]); + REQUIRE(mocked.derefed[3]); + REQUIRE(mocked.derefed[4]); + } + SECTION("Short-circuited") { + auto allMatch = AllMatch(Predicate<int>([](int elem) { + return elem < 3; + })); + REQUIRE_THAT(mocked, !allMatch); + REQUIRE(mocked.derefed[0]); + REQUIRE(mocked.derefed[1]); + REQUIRE(mocked.derefed[2]); + REQUIRE_FALSE(mocked.derefed[3]); + REQUIRE_FALSE(mocked.derefed[4]); + } + } +} - REQUIRE_THAT(string_vector, AnyMatch(StartsWith("CMak"))); - REQUIRE_THAT(string_vector, AnyMatch(EndsWith("++"))); +TEST_CASE("Usage of AnyMatch range matcher", "[matchers][templated][quantifiers]") { + using Catch::Matchers::AnyMatch; + using Catch::Matchers::Predicate; + + SECTION("Basic usage") { + using Catch::Matchers::Contains; + using Catch::Matchers::SizeIs; + + std::array<std::array<int, 5>, 5> data{ { + {{ 0, 1, 2, 3, 5 }}, + {{ 4,-3,-2, 5, 0 }}, + {{ 0, 0, 0, 5, 0 }}, + {{ 0,-5, 0, 5, 0 }}, + {{ 1, 0, 0,-1, 5 }} + } }; + + REQUIRE_THAT(data, AnyMatch(SizeIs(5))); + REQUIRE_THAT(data, !AnyMatch(Contains(0) && Contains(10))); + } + + SECTION("Type requires ADL found begin and end") { + unrelated::needs_ADL_begin needs_adl; + REQUIRE_THAT( needs_adl, AnyMatch( Predicate<int>( []( int elem ) { + return elem < 3; + } ) ) ); + } - REQUIRE_THAT(int_vectors_list, AnyMatch(Contains(4))); - REQUIRE_THAT(int_vectors_list, AnyMatch(SizeIs(2))); + SECTION("Shortcircuiting") { + with_mocked_iterator_access mocked; + SECTION("All are read") { + auto anyMatch = AnyMatch( + Predicate<int>( []( int elem ) { return elem > 10; } ) ); + REQUIRE_THAT( mocked, !anyMatch ); + REQUIRE( mocked.derefed[0] ); + REQUIRE( mocked.derefed[1] ); + REQUIRE( mocked.derefed[2] ); + REQUIRE( mocked.derefed[3] ); + REQUIRE( mocked.derefed[4] ); + } + SECTION("Short-circuited") { + auto anyMatch = AnyMatch( + Predicate<int>( []( int elem ) { return elem < 3; } ) ); + REQUIRE_THAT( mocked, anyMatch ); + REQUIRE( mocked.derefed[0] ); + REQUIRE_FALSE( mocked.derefed[1] ); + REQUIRE_FALSE( mocked.derefed[2] ); + REQUIRE_FALSE( mocked.derefed[3] ); + REQUIRE_FALSE( mocked.derefed[4] ); + } } +} - SECTION("Usage of the NoneMatch range matcher") { - REQUIRE_THAT(int_arr_arr, NoneMatch(Contains(-6))); - REQUIRE_THAT(int_arr_arr, NoneMatch(SizeIs(42))); +TEST_CASE("Usage of NoneMatch range matcher", "[matchers][templated][quantifiers]") { + using Catch::Matchers::NoneMatch; + using Catch::Matchers::Predicate; + + SECTION("Basic usage") { + using Catch::Matchers::Contains; + using Catch::Matchers::SizeIs; + + std::array<std::array<int, 5>, 5> data{ { + {{ 0, 1, 2, 3, 5 }}, + {{ 4,-3,-2, 5, 0 }}, + {{ 0, 0, 0, 5, 0 }}, + {{ 0,-5, 0, 5, 0 }}, + {{ 1, 0, 0,-1, 5 }} + } }; + + REQUIRE_THAT(data, NoneMatch(SizeIs(6))); + REQUIRE_THAT(data, !NoneMatch(Contains(0) && Contains(1))); + } - REQUIRE_THAT(string_vector, NoneMatch(StartsWith("abd"))); - REQUIRE_THAT(string_vector, NoneMatch(EndsWith("#!--"))); + SECTION( "Type requires ADL found begin and end" ) { + unrelated::needs_ADL_begin needs_adl; + REQUIRE_THAT( needs_adl, NoneMatch( Predicate<int>( []( int elem ) { + return elem > 6; + } ) ) ); + } - REQUIRE_THAT(int_vectors_list, NoneMatch(IsEmpty())); - REQUIRE_THAT(int_vectors_list, NoneMatch(SizeIs(3))); + SECTION("Shortcircuiting") { + with_mocked_iterator_access mocked; + SECTION("All are read") { + auto noneMatch = NoneMatch( + Predicate<int>([](int elem) { return elem > 10; })); + REQUIRE_THAT(mocked, noneMatch); + REQUIRE(mocked.derefed[0]); + REQUIRE(mocked.derefed[1]); + REQUIRE(mocked.derefed[2]); + REQUIRE(mocked.derefed[3]); + REQUIRE(mocked.derefed[4]); + } + SECTION("Short-circuited") { + auto noneMatch = NoneMatch( + Predicate<int>([](int elem) { return elem < 3; })); + REQUIRE_THAT(mocked, !noneMatch); + REQUIRE(mocked.derefed[0]); + REQUIRE_FALSE(mocked.derefed[1]); + REQUIRE_FALSE(mocked.derefed[2]); + REQUIRE_FALSE(mocked.derefed[3]); + REQUIRE_FALSE(mocked.derefed[4]); + } } } + + +// This is a C++17 extension, and GCC refuses to compile such code +// unless it is set to C++17 or later +#if defined(CATCH_CPP17_OR_GREATER) + +TEST_CASE( "The quantifier range matchers support types with different types returned from begin and end", + "[matchers][templated][quantifiers][approvals]" ) { + using Catch::Matchers::AllMatch; + using Catch::Matchers::AnyMatch; + using Catch::Matchers::NoneMatch; + + using Catch::Matchers::Predicate; + + has_different_begin_end_types diff_types; + REQUIRE_THAT( diff_types, !AllMatch( Predicate<int>( []( int elem ) { + return elem < 3; + } ) ) ); + + REQUIRE_THAT( diff_types, AnyMatch( Predicate<int>( []( int elem ) { + return elem < 2; + } ) ) ); + + REQUIRE_THAT( diff_types, !NoneMatch( Predicate<int>( []( int elem ) { + return elem < 3; + } ) ) ); +} + +#endif