Function next

Synopsis

#include <include/internal/catch_generators_generic.hpp>

bool next() override

Description

No description yet.

Source

Lines 119-141 in include/internal/catch_generators_generic.hpp.

bool next() override {
    // There are 2 basic cases:
    // 1) We are still reading the generator
    // 2) We are reading our own cache
    // In the first case, we need to poke the underlying generator.
    // If it happily moves, we are left in that state, otherwise it is time to start reading from our cache
    if (m_current_repeat == 0) {
        const auto success = m_generator.next();
        if (!success) {
            ++m_current_repeat;
        }
        return m_current_repeat < m_target_repeats;
    }
    // In the second case, we need to move indices forward and check that we haven't run up against the end
    ++m_repeat_index;
    if (m_repeat_index == m_returned.size()) {
        m_repeat_index = 0;
        ++m_current_repeat;
    }
    return m_current_repeat < m_target_repeats;
}





Add Discussion as Guest

Log in