1
0
mirror of https://github.com/catchorg/Catch2.git synced 2025-01-16 07:08:01 +00:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Martin Hořeňovský
77643ce2e5 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`
2020-12-27 20:20:55 +01:00
Uriel García Rivas
552af8920d Added AnyMatch, AllMatch and NoneMatch 2020-12-27 20:20:55 +01:00
13 changed files with 1362 additions and 10 deletions

View File

@ -88,6 +88,7 @@ set(INTERNAL_HEADERS
${SOURCES_DIR}/matchers/catch_matchers_exception.hpp
${SOURCES_DIR}/matchers/catch_matchers_floating_point.hpp
${SOURCES_DIR}/matchers/catch_matchers_predicate.hpp
${SOURCES_DIR}/matchers/catch_matchers_quantifiers.hpp
${SOURCES_DIR}/matchers/catch_matchers_string.hpp
${SOURCES_DIR}/matchers/catch_matchers_templated.hpp
${SOURCES_DIR}/matchers/catch_matchers_vector.hpp

View File

@ -26,6 +26,7 @@
#include <catch2/matchers/catch_matchers_exception.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/matchers/catch_matchers_predicate.hpp>
#include <catch2/matchers/catch_matchers_quantifiers.hpp>
#include <catch2/matchers/catch_matchers_string.hpp>
#include <catch2/matchers/catch_matchers_templated.hpp>
#include <catch2/matchers/catch_matchers_vector.hpp>

View File

@ -0,0 +1,109 @@
// Copyright Catch2 Authors
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)
// SPDX-License-Identifier: BSL-1.0
#ifndef CATCH_MATCHERS_QUANTIFIERS_HPP_INCLUDED
#define CATCH_MATCHERS_QUANTIFIERS_HPP_INCLUDED
#include <catch2/matchers/catch_matchers_templated.hpp>
#include <utility>
namespace Catch {
namespace Matchers {
// Matcher for checking that all elements in range matches a given matcher.
template <typename Matcher>
class AllMatchMatcher final : public MatcherGenericBase {
Matcher m_matcher;
public:
AllMatchMatcher(Matcher matcher):
m_matcher(std::move(matcher))
{}
std::string describe() const override {
return "all match " + m_matcher.describe();
}
template <typename RangeLike>
bool match(RangeLike&& rng) const {
for (auto&& elem : rng) {
if (!m_matcher.match(elem)) {
return false;
}
}
return true;
}
};
// Matcher for checking that no element in range matches a given matcher.
template <typename Matcher>
class NoneMatchMatcher final : public MatcherGenericBase {
Matcher m_matcher;
public:
NoneMatchMatcher(Matcher matcher):
m_matcher(std::move(matcher))
{}
std::string describe() const override {
return "none match " + m_matcher.describe();
}
template <typename RangeLike>
bool match(RangeLike&& rng) const {
for (auto&& elem : rng) {
if (m_matcher.match(elem)) {
return false;
}
}
return true;
}
};
// Matcher for checking that at least one element in range matches a given matcher.
template <typename Matcher>
class AnyMatchMatcher final : public MatcherGenericBase {
Matcher m_matcher;
public:
AnyMatchMatcher(Matcher matcher):
m_matcher(std::move(matcher))
{}
std::string describe() const override {
return "any match " + m_matcher.describe();
}
template <typename RangeLike>
bool match(RangeLike&& rng) const {
for (auto&& elem : rng) {
if (m_matcher.match(elem)) {
return true;
}
}
return false;
}
};
// Creates a matcher that checks whether a range contains element matching a matcher
template <typename Matcher>
AllMatchMatcher<Matcher> AllMatch(Matcher&& matcher) {
return { std::forward<Matcher>(matcher) };
}
// Creates a matcher that checks whether no element in a range matches a matcher.
template <typename Matcher>
NoneMatchMatcher<Matcher> NoneMatch(Matcher&& matcher) {
return { std::forward<Matcher>(matcher) };
}
// Creates a matcher that checks whether any element in a range matches a matcher.
template <typename Matcher>
AnyMatchMatcher<Matcher> AnyMatch(Matcher&& matcher) {
return { std::forward<Matcher>(matcher) };
}
}
}
#endif // CATCH_MATCHERS_QUANTIFIERS_HPP_INCLUDED

View File

@ -237,6 +237,9 @@ 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 Use a custom approx
:test-result: PASS Variadic macros

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

View File

@ -1380,6 +1380,6 @@ due to unexpected exception with message:
Why would you throw a std::string?
===============================================================================
test cases: 351 | 277 passed | 70 failed | 4 failed as expected
assertions: 1992 | 1840 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
@ -15681,6 +16005,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: 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="2010" 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,6 +1280,18 @@ 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"/>

View File

@ -1265,6 +1265,18 @@ 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}"/>

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
@ -4010,5 +4100,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
ok {test-number} -
# xmlentitycheck
ok {test-number} -
1..2009
1..2054

View File

@ -577,6 +577,12 @@ 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='Use a custom approx']

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" >
@ -18598,9 +19021,9 @@ loose text artifact
</Section>
<OverallResult success="true"/>
</TestCase>
<OverallResults successes="1840" failures="149" expectedFailures="21"/>
<OverallResultsCases successes="261" failures="86" expectedFailures="4"/>
<OverallResults successes="1885" failures="149" expectedFailures="21"/>
<OverallResultsCases successes="264" failures="86" expectedFailures="4"/>
</Group>
<OverallResults successes="1840" failures="148" expectedFailures="21"/>
<OverallResultsCases successes="261" failures="86" expectedFailures="4"/>
<OverallResults successes="1885" failures="148" expectedFailures="21"/>
<OverallResultsCases successes="264" failures="86" expectedFailures="4"/>
</Catch>

View File

@ -5,6 +5,9 @@
#include <catch2/matchers/catch_matchers_container_properties.hpp>
#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>
#include <cmath>
@ -31,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) {}
@ -217,3 +355,191 @@ TEST_CASE("Usage of the SizeIs range matcher", "[matchers][templated][size]") {
REQUIRE_THAT(has_size{}, SizeIs(13));
}
}
TEST_CASE("Usage of AllMatch range matcher", "[matchers][templated][quantifiers]") {
using Catch::Matchers::AllMatch;
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("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]);
}
}
}
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