// // Copyright 2019 Mateusz Loskot // // Distributed under the Boost Software License, Version 1.0 // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt // #ifndef BOOST_GIL_TEST_CORE_TEST_FIXTURE_HPP #define BOOST_GIL_TEST_CORE_TEST_FIXTURE_HPP #include #include #include #include #include #include #include #include namespace boost { namespace gil { namespace test { namespace fixture { template struct consecutive_value { consecutive_value(T start) : current_(start) { BOOST_ASSERT(static_cast(current_) >= 0); } T operator()() { BOOST_ASSERT(static_cast(current_) + 1 > 0); current_++; return current_; } T current_; }; template struct reverse_consecutive_value { reverse_consecutive_value(T start) : current_(start) { BOOST_ASSERT(static_cast(current_) > 0); } T operator()() { BOOST_ASSERT(static_cast(current_) + 1 >= 0); current_--; return current_; } T current_; }; template struct random_value { static_assert(std::is_integral::value, "T must be integral type"); random_value(T range_min = std::numeric_limits::min(), T range_max = std::numeric_limits::max()) : uid_(range_min, range_max) {} random_value(std::uint32_t seed, T minimum, T maximum) : rng_(seed), uid_(minimum, maximum) {} T operator()() { return uid_(rng_); } T range_min() const noexcept { return uid_.a(); } T range_max() const noexcept { return uid_.b(); } std::mt19937 rng_; std::uniform_int_distribution::type> uid_; }; }}}} // namespace boost::gil::test::fixture #endif