// // 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"); static constexpr auto range_min = std::numeric_limits::min(); static constexpr auto range_max = std::numeric_limits::max(); random_value() : rng_(rd_()), uid_(range_min, range_max) {} T operator()() { auto value = uid_(rng_); BOOST_ASSERT(range_min <= value && value <= range_max); return static_cast(value); } std::random_device rd_; std::mt19937 rng_; std::uniform_int_distribution::type> uid_; }; }}}} // namespace boost::gil::test::fixture #endif