Class RandomIntegerGenerator
Synopsis
#include <include/internal/catch_generators_specific.hpp>
template <typename Integer>
class RandomIntegerGenerator final : public IGenerator<Integer>
Description
No description yet.
Mentioned in
- Writing tests / Data Generators / Provided generators
Inheritance
Ancestors: IGenerator
Methods
RandomIntegerGenerator | ||
get | ||
next |
Source
Lines 42-62 in include/internal/catch_generators_specific.hpp.
template <typename Integer>
class RandomIntegerGenerator final : public IGenerator<Integer> {
Catch::SimplePcg32& m_rng;
std::uniform_int_distribution<Integer> m_dist;
Integer m_current_number;
public:
RandomIntegerGenerator(Integer a, Integer b):
m_rng(rng()),
m_dist(a, b) {
static_cast<void>(next());
}
Integer const& get() const override {
return m_current_number;
}
bool next() override {
m_current_number = m_dist(m_rng);
return true;
}
};