Struct ContainsElementMatcher

Synopsis

#include <include/internal/catch_matchers_vector.h>

template<typename T, typename Alloc>
struct ContainsElementMatcher : MatcherBase<std::vector<T, Alloc>>

Description

No description yet.

Inheritance

Ancestors: MatcherBase

Methods

ContainsElementMatcher
describe
match

Source

Lines 20-39 in include/internal/catch_matchers_vector.h.

template<typename T, typename Alloc>
struct ContainsElementMatcher : MatcherBase<std::vector<T, Alloc>> {
    ContainsElementMatcher(T const &comparator) : m_comparator( comparator) {}
    bool match(std::vector<T, Alloc> const &v) const override {
        for (auto const& el : v) {
            if (el == m_comparator) {
                return true;
            }
        }
        return false;
    }
    std::string describe() const override {
        return "Contains: " + ::Catch::Detail::stringify( m_comparator );
    }
    T const& m_comparator;
};





Add Discussion as Guest

Log in