1 #pragma once 2 3 #include <memory> 4 5 #include "rapidcheck/Gen.h" 6 7 namespace rc { 8 namespace state { 9 10 /// Tests a stateful system. This function has assertion semantics (i.e. a 11 /// failure is equivalent to calling `RC_FAIL` and success is equivalent to 12 /// `RC_SUCCEED`) so it is intended to be used from a property. 13 /// 14 /// @param initialState The initial model state. 15 /// @param sut The system under test. 16 /// @param generationFunc A callable which takes the current model state as a 17 /// parameter and returns a generator for a (possibly) 18 /// suitable command. 19 template <typename Model, typename Sut, typename GenFunc> 20 void check(const Model &initialState, Sut &sut, GenFunc &&generationFunc); 21 22 /// Equivalent to `check(Model, Sut, GenFunc)` but instead of taking the state 23 /// directly, takes a callable returning the state. 24 template <typename MakeInitialState, 25 typename Sut, 26 typename GenFunc, 27 typename = decltype( 28 std::declval<GenFunc>()(std::declval<MakeInitialState>()()))> 29 void check(MakeInitialState &&makeInitialState, Sut &sut, GenFunc &&generationFunc); 30 31 /// Checks whether command is valid for the given state. 32 template <typename Model, typename Sut> 33 bool isValidCommand(const Command<Model, Sut> &command, const Model &s0); 34 35 } // namespace state 36 } // namespace rc 37 38 #include "State.hpp" 39