Struct ContainsMatcher

Synopsis

#include <include/internal/catch_matchers_vector.h>

template<typename T, typename AllocComp, typename AllocMatch>
struct ContainsMatcher : MatcherBase<std::vector<T, AllocMatch>>

Description

No description yet.

Inheritance

Ancestors: MatcherBase

Methods

ContainsMatcher
describe
match

Source

Lines 41-69 in include/internal/catch_matchers_vector.h.

template<typename T, typename AllocComp, typename AllocMatch>
struct ContainsMatcher : MatcherBase<std::vector<T, AllocMatch>> {
    ContainsMatcher(std::vector<T, AllocComp> const &comparator) : m_comparator( comparator ) {}
    bool match(std::vector<T, AllocMatch> const &v) const override {
        // !TBD: see note in EqualsMatcher
        if (m_comparator.size() > v.size())
            return false;
        for (auto const& comparator : m_comparator) {
            auto present = false;
            for (const auto& el : v) {
                if (el == comparator) {
                    present = true;
                    break;
                }
            }
            if (!present) {
                return false;
            }
        }
        return true;
    }
    std::string describe() const override {
        return "Contains: " + ::Catch::Detail::stringify( m_comparator );
    }
    std::vector<T, AllocComp> const& m_comparator;
};





Add Discussion as Guest

Log in