Class IteratorGenerator

Synopsis

#include <include/internal/catch_generators_specific.hpp>

template <typename T>
class IteratorGenerator final : public IGenerator<T>

Description

No description yet.

Mentioned in

Inheritance

Ancestors: IGenerator

Methods

IteratorGenerator
get
next

Source

Lines 131-155 in include/internal/catch_generators_specific.hpp.

template <typename T>
class IteratorGenerator final : public IGenerator<T> {
    static_assert(!std::is_same<T, bool>::value,
        "IteratorGenerator currently does not support bools"
        "because of std::vector<bool> specialization");

    std::vector<T> m_elems;
    size_t m_current = 0;
public:
    template <typename InputIterator, typename InputSentinel>
    IteratorGenerator(InputIterator first, InputSentinel last):m_elems(first, last) {
        if (m_elems.empty()) {
            Catch::throw_exception(GeneratorException("IteratorGenerator received no valid values"));
        }
    }

    T const& get() const override {
        return m_elems[m_current];
    }

    bool next() override {
        ++m_current;
        return m_current != m_elems.size();
    }
};





Add Discussion as Guest

Log in