mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-03 22:05:39 +02:00
Added AnyMatch, AllMatch and NoneMatch
This commit is contained in:

committed by
Martin Hořeňovský

parent
ce54ec185f
commit
552af8920d
@@ -12286,6 +12286,129 @@ 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
|
||||
-------------------------------------------------------------------------------
|
||||
@@ -15681,6 +15804,6 @@ Misc.tests.cpp:<line number>
|
||||
Misc.tests.cpp:<line number>: PASSED:
|
||||
|
||||
===============================================================================
|
||||
test cases: 351 | 261 passed | 86 failed | 4 failed as expected
|
||||
assertions: 2009 | 1840 passed | 148 failed | 21 failed as expected
|
||||
test cases: 352 | 262 passed | 86 failed | 4 failed as expected
|
||||
assertions: 2027 | 1858 passed | 148 failed | 21 failed as expected
|
||||
|
||||
|
Reference in New Issue
Block a user