7#ifndef TWOBLUECUBES_CATCH_GENERATORS_SPECIFIC_HPP_INCLUDED
8#define TWOBLUECUBES_CATCH_GENERATORS_SPECIFIC_HPP_INCLUDED
19template <
typename Float>
20class RandomFloatingGenerator final :
public IGenerator<Float> {
22 std::minstd_rand m_rand;
23 std::uniform_real_distribution<Float> m_dist;
24 Float m_current_number;
30 static_cast<void>(
next());
33 Float
const&
get()
const override {
34 return m_current_number;
37 m_current_number = m_dist(m_rand);
42template <
typename Integer>
43class RandomIntegerGenerator final :
public IGenerator<Integer> {
44 std::minstd_rand m_rand;
45 std::uniform_int_distribution<Integer> m_dist;
46 Integer m_current_number;
52 static_cast<void>(
next());
55 Integer
const&
get()
const override {
56 return m_current_number;
59 m_current_number = m_dist(m_rand);
67typename std::enable_if<std::is_integral<T>::value && !std::is_same<T, bool>::value,
68GeneratorWrapper<T>>::type
76typename std::enable_if<std::is_floating_point<T>::value,
77GeneratorWrapper<T>>::type
86class RangeGenerator final :
public IGenerator<T> {
97 m_positive(m_step >
T(0))
99 assert(m_current != m_end &&
"Range start and end cannot be equal");
100 assert(m_step !=
T(0) &&
"Step size cannot be zero");
101 assert(((m_positive && m_current <= m_end) || (!m_positive && m_current >= m_end)) &&
"Step moves away from end");
108 T const&
get()
const override {
114 return (m_positive) ? (m_current < m_end) : (m_current > m_end);
120 static_assert(std::is_integral<T>::value && !std::is_same<T, bool>::value,
"Type must be an integer");
126 static_assert(std::is_integral<T>::value && !std::is_same<T, bool>::value,
"Type must be an integer");
Float const & get() const override
RandomFloatingGenerator(Float a, Float b)
RandomIntegerGenerator(Integer a, Integer b)
Integer const & get() const override
T const & get() const override
RangeGenerator(T const &start, T const &end, T const &step)
RangeGenerator(T const &start, T const &end)
std::unique_ptr< T > make_unique(Args &&... args)
GeneratorWrapper< T > range(T const &start, T const &end, T const &step)
IContext & getCurrentContext()
FloatingPoint< float > Float
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
#define T(meth, val, expected)