mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-02 21:35:40 +02:00
Add generic Contains matcher
It matches a range iff the range contains a specific element, or an element in the range matches the provided matcher.
This commit is contained in:
@@ -486,6 +486,30 @@ ok {test-number} - true
|
||||
ok {test-number} - true
|
||||
# Assertions then sections
|
||||
ok {test-number} - true
|
||||
# Basic use of the Contains range matcher
|
||||
ok {test-number} - a, Contains(1) for: { 1, 2, 3 } contains element 1
|
||||
# Basic use of the Contains range matcher
|
||||
ok {test-number} - b, Contains(1) for: { 0, 1, 2 } contains element 1
|
||||
# Basic use of the Contains range matcher
|
||||
ok {test-number} - c, !Contains(1) for: { 4, 5, 6 } not contains element 1
|
||||
# Basic use of the Contains range matcher
|
||||
ok {test-number} - a, Contains(0, close_enough) for: { 1, 2, 3 } contains element 0
|
||||
# Basic use of the Contains range matcher
|
||||
ok {test-number} - b, Contains(0, close_enough) for: { 0, 1, 2 } contains element 0
|
||||
# Basic use of the Contains range matcher
|
||||
ok {test-number} - c, !Contains(0, close_enough) for: { 4, 5, 6 } not contains element 0
|
||||
# Basic use of the Contains range matcher
|
||||
ok {test-number} - a, Contains(4, [](auto&& lhs, size_t sz) { return lhs.size() == sz; }) for: { "abc", "abcd", "abcde" } contains element 4
|
||||
# Basic use of the Contains range matcher
|
||||
ok {test-number} - in, Contains(1) for: { 1, 2, 3, 4, 5 } contains element 1
|
||||
# Basic use of the Contains range matcher
|
||||
ok {test-number} - in, !Contains(8) for: { 1, 2, 3, 4, 5 } not contains element 8
|
||||
# Basic use of the Contains range matcher
|
||||
ok {test-number} - in, Contains(MoveOnlyTestElement{ 2 }) for: { 1, 2, 3 } contains element 2
|
||||
# Basic use of the Contains range matcher
|
||||
ok {test-number} - in, !Contains(MoveOnlyTestElement{ 9 }) for: { 1, 2, 3 } not contains element 9
|
||||
# Basic use of the Contains range matcher
|
||||
ok {test-number} - in, Contains(Catch::Matchers::WithinAbs(0.5, 0.5)) for: { 1.0, 2.0, 3.0, 0.0 } contains element matching is within 0.5 of 0.5
|
||||
# CAPTURE can deal with complex expressions
|
||||
ok {test-number} - with 7 messages: 'a := 1' and 'b := 2' and 'c := 3' and 'a + b := 3' and 'a+b := 3' and 'c > b := true' and 'a == 1 := true'
|
||||
# CAPTURE can deal with complex expressions involving commas
|
||||
@@ -3704,5 +3728,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
|
||||
ok {test-number} -
|
||||
# xmlentitycheck
|
||||
ok {test-number} -
|
||||
1..1848
|
||||
1..1860
|
||||
|
||||
|
Reference in New Issue
Block a user