Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
Catch::Generators::RepeatGenerator< T > Class Template Reference

#include <catch_generators_generic.hpp>

Inheritance diagram for Catch::Generators::RepeatGenerator< T >:
Collaboration diagram for Catch::Generators::RepeatGenerator< T >:

Public Member Functions

 RepeatGenerator (size_t repeats, GeneratorWrapper< T > &&generator)
 
T const & get () const override
 
bool next () override
 
 RepeatGenerator (size_t repeats, GeneratorWrapper< T > &&generator)
 
T const & get () const override
 
bool next () override
 
- Public Member Functions inherited from Catch::Generators::IGenerator< T >
virtual ~IGenerator ()=default
 
virtual ~IGenerator ()=default
 
- Public Member Functions inherited from Catch::Generators::GeneratorUntypedBase
 GeneratorUntypedBase ()=default
 
virtual ~GeneratorUntypedBase ()
 
 GeneratorUntypedBase ()=default
 
virtual ~GeneratorUntypedBase ()
 

Additional Inherited Members

- Public Types inherited from Catch::Generators::IGenerator< T >
using type = T
 

Detailed Description

template<typename T>
class Catch::Generators::RepeatGenerator< T >

Definition at line 3775 of file catch.hpp.

Constructor & Destructor Documentation

◆ RepeatGenerator() [1/2]

template<typename T >
Catch::Generators::RepeatGenerator< T >::RepeatGenerator ( size_t repeats,
GeneratorWrapper< T > && generator )
inline

Definition at line 100 of file catch_generators_generic.hpp.

100 :
101 m_generator(std::move(generator)),
102 m_target_repeats(repeats)
103 {
104 assert(m_target_repeats > 0 && "Repeat generator must repeat at least once");
105 }

◆ RepeatGenerator() [2/2]

template<typename T >
Catch::Generators::RepeatGenerator< T >::RepeatGenerator ( size_t repeats,
GeneratorWrapper< T > && generator )
inline

Definition at line 3782 of file catch.hpp.

3782 :
3783 m_generator(std::move(generator)),
3784 m_target_repeats(repeats)
3785 {
3786 assert(m_target_repeats > 0 && "Repeat generator must repeat at least once");
3787 }

Member Function Documentation

◆ get() [1/2]

template<typename T >
T const & Catch::Generators::RepeatGenerator< T >::get ( ) const
inlineoverridevirtual

Implements Catch::Generators::IGenerator< T >.

Definition at line 107 of file catch_generators_generic.hpp.

107 {
108 if (m_current_repeat == 0) {
109 m_returned.push_back(m_generator.get());
110 return m_returned.back();
111 }
112 return m_returned[m_repeat_index];
113 }

◆ get() [2/2]

template<typename T >
T const & Catch::Generators::RepeatGenerator< T >::get ( ) const
inlineoverridevirtual

Implements Catch::Generators::IGenerator< T >.

Definition at line 3789 of file catch.hpp.

3789 {
3790 if (m_current_repeat == 0) {
3791 m_returned.push_back(m_generator.get());
3792 return m_returned.back();
3793 }
3794 return m_returned[m_repeat_index];
3795 }
Here is the call graph for this function:

◆ next() [1/2]

template<typename T >
bool Catch::Generators::RepeatGenerator< T >::next ( )
inlineoverridevirtual

Implements Catch::Generators::GeneratorUntypedBase.

Definition at line 115 of file catch_generators_generic.hpp.

115 {
116 // There are 2 basic cases:
117 // 1) We are still reading the generator
118 // 2) We are reading our own cache
119
120 // In the first case, we need to poke the underlying generator.
121 // If it happily moves, we are left in that state, otherwise it is time to start reading from our cache
122 if (m_current_repeat == 0) {
123 const auto success = m_generator.next();
124 if (!success) {
125 ++m_current_repeat;
126 }
127 return m_current_repeat < m_target_repeats;
128 }
129
130 // In the second case, we need to move indices forward and check that we haven't run up against the end
131 ++m_repeat_index;
132 if (m_repeat_index == m_returned.size()) {
133 m_repeat_index = 0;
134 ++m_current_repeat;
135 }
136 return m_current_repeat < m_target_repeats;
137 }

◆ next() [2/2]

template<typename T >
bool Catch::Generators::RepeatGenerator< T >::next ( )
inlineoverridevirtual

Implements Catch::Generators::GeneratorUntypedBase.

Definition at line 3797 of file catch.hpp.

3797 {
3798 // There are 2 basic cases:
3799 // 1) We are still reading the generator
3800 // 2) We are reading our own cache
3801
3802 // In the first case, we need to poke the underlying generator.
3803 // If it happily moves, we are left in that state, otherwise it is time to start reading from our cache
3804 if (m_current_repeat == 0) {
3805 const auto success = m_generator.next();
3806 if (!success) {
3807 ++m_current_repeat;
3808 }
3809 return m_current_repeat < m_target_repeats;
3810 }
3811
3812 // In the second case, we need to move indices forward and check that we haven't run up against the end
3813 ++m_repeat_index;
3814 if (m_repeat_index == m_returned.size()) {
3815 m_repeat_index = 0;
3816 ++m_current_repeat;
3817 }
3818 return m_current_repeat < m_target_repeats;
3819 }
Here is the call graph for this function:

The documentation for this class was generated from the following files: