-
Notifications
You must be signed in to change notification settings - Fork 17
Tutorial
thejohnfreeman edited this page Jan 4, 2013
·
13 revisions
This tutorial mimics the one for QuickCheck++.
The code here can be found in tutorial/reverse.cpp.
#include <autocheck/autocheck.hpp>
namespace ac = autocheck;
A property is simply a callable object returning a bool
from its arguments. It can be a function:
template <typename Container>
bool reverse_prop_f(const Container& xs) {
Container ys(xs);
std::reverse(ys.begin(), ys.end());
std::reverse(ys.begin(), ys.end());
return xs == ys;
}
... or a function object:
struct reverse_prop_t {
template <typename Container>
bool operator() (const Container& xs) const {
return reverse_prop_f(xs);
}
};
... or even a closure built from a lambda expression.
Properties can take arguments by const
or non-const
reference. Function objects can have const
or non-const
function-call operators.