Struct MatchAllOf

Synopsis

#include <include/internal/catch_matchers.h>

template<typename ArgT>
struct MatchAllOf : MatcherBase<ArgT>

Description

No description yet.

Methods

describe
match
operator&&

Source

Lines 69-101 in include/internal/catch_matchers.h.

template<typename ArgT>
struct MatchAllOf : MatcherBase<ArgT> {
    bool match( ArgT const& arg ) const override {
        for( auto matcher : m_matchers ) {
            if (!matcher->match(arg))
                return false;
        }
        return true;
    }
    std::string describe() const override {
        std::string description;
        description.reserve( 4 + m_matchers.size()*32 );
        description += "( ";
        bool first = true;
        for( auto matcher : m_matchers ) {
            if( first )
                first = false;
            else
                description += " and ";
            description += matcher->toString();
        }
        description += " )";
        return description;
    }
    MatchAllOf<ArgT> operator && ( MatcherBase<ArgT> const& other ) {
        auto copy(*this);
        copy.m_matchers.push_back( &other );
        return copy;
    }
    std::vector<MatcherBase<ArgT> const*> m_matchers;
};





Add Discussion as Guest

Log in