1#ifndef HALCHECK_TEST_STRATEGY_HPP
2#define HALCHECK_TEST_STRATEGY_HPP
10#include <halcheck/lib/functional.hpp>
11#include <halcheck/lib/type_traits.hpp>
12#include <halcheck/lib/utility.hpp>
13#include <halcheck/lib/variant.hpp>
17namespace halcheck {
namespace test {
43 explicit strategy(lib::in_place_type_t<F>, Args &&...args) : _impl(new derived<F>(
std::forward<Args>(args)...)) {}
51 template<
typename F, HALCHECK_REQUIRE(lib::is_invocable<const lib::decay_t<F> &, lib::function_view<
void()>>())>
53 :
strategy(lib::in_place_type_t<lib::decay_t<F>>(),
std::forward<F>(func)) {}
68 virtual ~base() =
default;
69 virtual void invoke(lib::function_view<
void()>)
const = 0;
73 struct derived final : base {
74 template<
typename... Args>
75 explicit derived(Args &&...args) : value(
std::forward<Args>(args)...) {}
77 void invoke(lib::function_view<
void()> func)
const override {
lib::invoke(value, func); }
96 HALCHECK_REQUIRE(lib::is_invocable<
const F &, lib::function_view<
void()>>())>
strategy()=default
Constructs an empty strategy.
void operator()(lib::function_view< void()> func) const
Executes the function stored in this strategy.
Definition strategy.hpp:59
strategy(F &&func)
Constructs a strategy.
Definition strategy.hpp:52
strategy(lib::in_place_type_t< F >, Args &&...args)
Constructs a strategy.
Definition strategy.hpp:43
A strategy executes a nullary function while handling effects or performing other operations such as ...
Definition strategy.hpp:23
HALCHECK_INLINE_CONSTEXPR struct halcheck::lib::@20 invoke
An implementation of std::invoke.
#define HALCHECK_REQUIRE(...)
Expands to a template argument that is only valid if the given argument evaluates to true.
Definition type_traits.hpp:24
test::strategy make_strategy(Args &&...args)
Constructs a strategy of the given type.
Definition strategy.hpp:97
test::strategy operator|(test::strategy lhs, test::strategy rhs)
Composes one strategy inside another.
test::strategy operator&(test::strategy lhs, test::strategy rhs)
Composes two strategies sequentially.
An implementation of std::is_invocable.
Definition invoke.hpp:66