Struct MatchAnyOf

Synopsis

#include <include/internal/catch_matchers.h>

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

Description

No description yet.

Methods

describe
match
operator||

Source

Lines 102-135 in include/internal/catch_matchers.h.

template<typename ArgT>
struct MatchAnyOf : MatcherBase<ArgT> {
    bool match( ArgT const& arg ) const override {
        for( auto matcher : m_matchers ) {
            if (matcher->match(arg))
                return true;
        }
        return false;
    }
    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 += " or ";
            description += matcher->toString();
        }
        description += " )";
        return description;
    }
    MatchAnyOf<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