Add more comprehensive tests for the quantifier matchers

This includes
* Testing both positive and negative path through the matchers
* Testing them with types whose `begin` and `end` member functions
require ADL
* Testing them with types that return different types from `begin`
and `end`
This commit is contained in:
Martin Hořeňovský 2020-12-26 23:09:51 +01:00
parent 552af8920d
commit 77643ce2e5
10 changed files with 1238 additions and 394 deletions

View File

@ -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

View File

@ -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 )

View File

@ -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

View File

@ -12220,6 +12220,330 @@ UniquePtr.tests.cpp:<line number>: PASSED:
with expansion:
3 == 3
-------------------------------------------------------------------------------
Usage of AllMatch range matcher
Basic usage
-------------------------------------------------------------------------------
MatchersRanges.tests.cpp:<line number>
...............................................................................
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( data, AllMatch(SizeIs(5)) )
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
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( data, !AllMatch(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 } } 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( needs_adl, AllMatch( Predicate<int>( []( int elem ) { return elem < 6; } ) ) )
with expansion:
{ 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( mocked, allMatch )
with expansion:
{ 1, 2, 3, 4, 5 } 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( mocked.derefed[3] )
with expansion:
true
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE( mocked.derefed[4] )
with expansion:
true
-------------------------------------------------------------------------------
Usage of AllMatch range matcher
Shortcircuiting
Short-circuited
-------------------------------------------------------------------------------
MatchersRanges.tests.cpp:<line number>
...............................................................................
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( mocked, !allMatch )
with expansion:
{ 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 AnyMatch range matcher
Basic usage
-------------------------------------------------------------------------------
MatchersRanges.tests.cpp:<line number>
...............................................................................
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( data, AnyMatch(SizeIs(5)) )
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
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 AnyMatch range matcher
Type requires ADL found begin and end
-------------------------------------------------------------------------------
MatchersRanges.tests.cpp:<line number>
...............................................................................
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( needs_adl, AnyMatch( Predicate<int>( []( int elem ) { return elem < 3; } ) ) )
with expansion:
{ 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( mocked, !anyMatch )
with expansion:
{ 1, 2, 3, 4, 5 } not any 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( mocked.derefed[3] )
with expansion:
true
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE( mocked.derefed[4] )
with expansion:
true
-------------------------------------------------------------------------------
Usage of AnyMatch range matcher
Shortcircuiting
Short-circuited
-------------------------------------------------------------------------------
MatchersRanges.tests.cpp:<line number>
...............................................................................
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( mocked, anyMatch )
with expansion:
{ 1, 2, 3, 4, 5 } any match matches undescribed predicate
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE( mocked.derefed[0] )
with expansion:
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 NoneMatch range matcher
Basic usage
-------------------------------------------------------------------------------
MatchersRanges.tests.cpp:<line number>
...............................................................................
MatchersRanges.tests.cpp:<line number>: PASSED:
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 has size == 6
MatchersRanges.tests.cpp:<line number>: PASSED:
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 } } 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( needs_adl, NoneMatch( Predicate<int>( []( int elem ) { return elem > 6; } ) ) )
with expansion:
{ 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( mocked.derefed[3] )
with expansion:
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( mocked, !noneMatch )
with expansion:
{ 1, 2, 3, 4, 5 } not 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_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
@ -12286,129 +12610,6 @@ MatchersRanges.tests.cpp:<line number>: PASSED:
with expansion:
{?} has size == 13
-------------------------------------------------------------------------------
Usage of the quantifiers matchers
Usage of the AllMatch range matcher
-------------------------------------------------------------------------------
MatchersRanges.tests.cpp:<line number>
...............................................................................
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( int_arr_arr, AllMatch(Contains(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 } } all match contains element 0
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( int_arr_arr, AllMatch(SizeIs(5)) )
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
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( string_vector, AllMatch(StartsWith("C")) )
with expansion:
{ "Command+", "Catch2+", "CMake+", "C++", "Console+" } all match starts with:
"C"
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( string_vector, AllMatch(EndsWith("+")) )
with expansion:
{ "Command+", "Catch2+", "CMake+", "C++", "Console+" } all match ends with:
"+"
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( int_vectors_list, AllMatch(!IsEmpty()) )
with expansion:
{ { 1, 2 }, { 3, 4 }, { 5, 6 } } all match not is empty
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( int_vectors_list, AllMatch(SizeIs(2)) )
with expansion:
{ { 1, 2 }, { 3, 4 }, { 5, 6 } } all match has size == 2
-------------------------------------------------------------------------------
Usage of the quantifiers matchers
Usage of the AnyMatch range matcher
-------------------------------------------------------------------------------
MatchersRanges.tests.cpp:<line number>
...............................................................................
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( int_arr_arr, AnyMatch(Contains(-2)) )
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
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( int_arr_arr, AnyMatch(SizeIs(5)) )
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
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( string_vector, AnyMatch(StartsWith("CMak")) )
with expansion:
{ "Command+", "Catch2+", "CMake+", "C++", "Console+" } any match starts with:
"CMak"
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( string_vector, AnyMatch(EndsWith("++")) )
with expansion:
{ "Command+", "Catch2+", "CMake+", "C++", "Console+" } any match ends with:
"++"
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( int_vectors_list, AnyMatch(Contains(4)) )
with expansion:
{ { 1, 2 }, { 3, 4 }, { 5, 6 } } any match contains element 4
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( int_vectors_list, AnyMatch(SizeIs(2)) )
with expansion:
{ { 1, 2 }, { 3, 4 }, { 5, 6 } } any match has size == 2
-------------------------------------------------------------------------------
Usage of the quantifiers matchers
Usage of the NoneMatch range matcher
-------------------------------------------------------------------------------
MatchersRanges.tests.cpp:<line number>
...............................................................................
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( int_arr_arr, NoneMatch(Contains(-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
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( int_arr_arr, NoneMatch(SizeIs(42)) )
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
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( string_vector, NoneMatch(StartsWith("abd")) )
with expansion:
{ "Command+", "Catch2+", "CMake+", "C++", "Console+" } none match starts
with: "abd"
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( string_vector, NoneMatch(EndsWith("#!--")) )
with expansion:
{ "Command+", "Catch2+", "CMake+", "C++", "Console+" } none match ends with:
"#!--"
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( int_vectors_list, NoneMatch(IsEmpty()) )
with expansion:
{ { 1, 2 }, { 3, 4 }, { 5, 6 } } none match is empty
MatchersRanges.tests.cpp:<line number>: PASSED:
REQUIRE_THAT( int_vectors_list, NoneMatch(SizeIs(3)) )
with expansion:
{ { 1, 2 }, { 3, 4 }, { 5, 6 } } none match has size == 3
-------------------------------------------------------------------------------
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

View File

@ -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"/>

View File

@ -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}"/>

View File

@ -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

View File

@ -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']

View File

@ -14536,6 +14536,429 @@ There is no extra whitespace here
</Section>
<OverallResult success="true"/>
</TestCase>
<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>
data, 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>
data, !AllMatch(Contains(0) &amp;&amp; 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 } } not all 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>
needs_adl, AllMatch( Predicate&lt;int>( []( int elem ) { return elem &lt; 6; } ) )
</Original>
<Expanded>
{ 1, 2, 3, 4, 5 } all 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, 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 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>
data, AnyMatch(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 } } any match has size == 5
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" >
<Original>
data, !AnyMatch(Contains(0) &amp;&amp; Contains(10))
</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 } } 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>
needs_adl, AnyMatch( Predicate&lt;int>( []( int elem ) { return elem &lt; 3; } ) )
</Original>
<Expanded>
{ 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="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>
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 } } none match has size == 6
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" >
<Original>
data, !NoneMatch(Contains(0) &amp;&amp; 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 } } 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>
needs_adl, NoneMatch( Predicate&lt;int>( []( int elem ) { return elem > 6; } ) )
</Original>
<Expanded>
{ 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" >
@ -14620,162 +15043,6 @@ There is no extra whitespace here
</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>
<Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" >
<Original>
string_vector, AllMatch(EndsWith("+"))
</Original>
<Expanded>
{ "Command+", "Catch2+", "CMake+", "C++", "Console+" } all match ends with: "+"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" >
<Original>
int_vectors_list, AllMatch(!IsEmpty())
</Original>
<Expanded>
{ { 1, 2 }, { 3, 4 }, { 5, 6 } } all match not is empty
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" >
<Original>
int_vectors_list, AllMatch(SizeIs(2))
</Original>
<Expanded>
{ { 1, 2 }, { 3, 4 }, { 5, 6 } } all match has size == 2
</Expanded>
</Expression>
<OverallResults successes="6" failures="0" expectedFailures="0"/>
</Section>
<Section name="Usage of the AnyMatch 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, AnyMatch(Contains(-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 } } any match contains element -2
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" >
<Original>
int_arr_arr, AnyMatch(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 } } any match has size == 5
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" >
<Original>
string_vector, AnyMatch(StartsWith("CMak"))
</Original>
<Expanded>
{ "Command+", "Catch2+", "CMake+", "C++", "Console+" } any match starts with: "CMak"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" >
<Original>
string_vector, AnyMatch(EndsWith("++"))
</Original>
<Expanded>
{ "Command+", "Catch2+", "CMake+", "C++", "Console+" } any match ends with: "++"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" >
<Original>
int_vectors_list, AnyMatch(Contains(4))
</Original>
<Expanded>
{ { 1, 2 }, { 3, 4 }, { 5, 6 } } any match contains element 4
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" >
<Original>
int_vectors_list, AnyMatch(SizeIs(2))
</Original>
<Expanded>
{ { 1, 2 }, { 3, 4 }, { 5, 6 } } any match has size == 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))
</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
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" >
<Original>
int_arr_arr, NoneMatch(SizeIs(42))
</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
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" >
<Original>
string_vector, NoneMatch(StartsWith("abd"))
</Original>
<Expanded>
{ "Command+", "Catch2+", "CMake+", "C++", "Console+" } none match starts with: "abd"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" >
<Original>
string_vector, NoneMatch(EndsWith("#!--"))
</Original>
<Expanded>
{ "Command+", "Catch2+", "CMake+", "C++", "Console+" } none match ends with: "#!--"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" >
<Original>
int_vectors_list, NoneMatch(IsEmpty())
</Original>
<Expanded>
{ { 1, 2 }, { 3, 4 }, { 5, 6 } } none match is empty
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE_THAT" filename="tests/<exe-name>/UsageTests/MatchersRanges.tests.cpp" >
<Original>
int_vectors_list, NoneMatch(SizeIs(3))
</Original>
<Expanded>
{ { 1, 2 }, { 3, 4 }, { 5, 6 } } none match has size == 3
</Expanded>
</Expression>
<OverallResults successes="6" failures="0" expectedFailures="0"/>
</Section>
<OverallResult success="true"/>
</TestCase>
<TestCase name="Use a custom approx" tags="[Approx][custom]" filename="tests/<exe-name>/UsageTests/Approx.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Approx.tests.cpp" >
<Original>
@ -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>

View File

@ -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 } };
using Catch::Matchers::Predicate;
SECTION("Usage of the AllMatch range matcher") {
REQUIRE_THAT(int_arr_arr, AllMatch(Contains(0)));
REQUIRE_THAT(int_arr_arr, AllMatch(SizeIs(5)));
SECTION("Basic usage") {
using Catch::Matchers::Contains;
using Catch::Matchers::SizeIs;
REQUIRE_THAT(string_vector, AllMatch(StartsWith("C")));
REQUIRE_THAT(string_vector, AllMatch(EndsWith("+")));
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(int_vectors_list, AllMatch(!IsEmpty()));
REQUIRE_THAT(int_vectors_list, AllMatch(SizeIs(2)));
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)));
REQUIRE_THAT(string_vector, AnyMatch(StartsWith("CMak")));
REQUIRE_THAT(string_vector, AnyMatch(EndsWith("++")));
REQUIRE_THAT(int_vectors_list, AnyMatch(Contains(4)));
REQUIRE_THAT(int_vectors_list, AnyMatch(SizeIs(2)));
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("Usage of the NoneMatch range matcher") {
REQUIRE_THAT(int_arr_arr, NoneMatch(Contains(-6)));
REQUIRE_THAT(int_arr_arr, NoneMatch(SizeIs(42)));
REQUIRE_THAT(string_vector, NoneMatch(StartsWith("abd")));
REQUIRE_THAT(string_vector, NoneMatch(EndsWith("#!--")));
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 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]);
}
}
}
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;
} ) ) );
}
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] );
}
}
}
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)));
}
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;
} ) ) );
}
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