Hegel 0.11.4
Property-based testing for C++
Loading...
Searching...
No Matches
hegel::stateful::Rule< T > Class Template Reference

A rule is one possible action in a stateful test. More...

#include <stateful.h>

Public Member Functions

 Rule (std::string name, std::function< void(TestCase &, T &)> step)
 Declares a new Rule.
const std::string & name () const
 Returns the name of the rule.
const std::function< void(TestCase &, T &)> & step () const
 Returns the underlying step function of the rule.

Detailed Description

template<typename T>
class hegel::stateful::Rule< T >

A rule is one possible action in a stateful test.

"push", [](hegel::TestCase& tc, std::vector<int>& stack) {
stack.push_back(tc.draw(gs::integers<int>()));
});
Handle to the currently-executing test case.
Definition test_case.h:40
A rule is one possible action in a stateful test.
Definition stateful.h:289
Template Parameters
TThe state-machine type the rule acts on

Constructor & Destructor Documentation

◆ Rule()

template<typename T>
hegel::stateful::Rule< T >::Rule ( std::string name,
std::function< void(TestCase &, T &)> step )
inlineexplicit

Declares a new Rule.

Parameters
namename of the rule
stepfunction representing the step a rule takes. It mutates the state in place, drawing any arguments it needs from the test case. Always check preconditions with assume() before mutating. A rule that rejects after mutating leaves the state partially modified.

Member Function Documentation

◆ name()

template<typename T>
const std::string & hegel::stateful::Rule< T >::name ( ) const
inline

Returns the name of the rule.

Returns
const std::string&

◆ step()

template<typename T>
const std::function< void(TestCase &, T &)> & hegel::stateful::Rule< T >::step ( ) const
inline

Returns the underlying step function of the rule.

Returns
const std::function<void(TestCase&, T&)>&

The documentation for this class was generated from the following file: