Private Member Functions |
virtual bool | accepts (const A &a, const B &b, const C &c, const D &d, const E &e) |
| Tells whether or not this property should accept given arguments.
|
virtual const std::string | classify (const A &a, const B &b, const C &c, const D &d, const E &e) |
| Classifies input to allow observation of input distribution.
|
virtual void | generateInput (size_t n, A &a, B &b, C &c, D &d, E &e) |
| Generates input randomly.
|
virtual bool | holdsFor (const A &a, const B &b, const C &c, const D &d, const E &e)=0 |
| Tells whether or not this property holds for the given input.
|
virtual bool | isTrivialFor (const A &a, const B &b, const C &c, const D &d, const E &e) |
| Tells whether or not the property is trivially true for the given input.
|
bool | _accepts (const A &a, const B &b, const C &c, const D &d, const E &e) |
const std::string | _classify (const A &a, const B &b, const C &c, const D &d, const E &e) |
void | _generateInput (size_t n, A &a, B &b, C &c, D &d, E &e) |
bool | _holdsFor (const A &a, const B &b, const C &c, const D &d, const E &e) |
bool | _isTrivialFor (const A &a, const B &b, const C &c, const D &d, const E &e) |
template<class A, class B = Unit, class C = Unit, class D = Unit, class E = Unit>
class quickcheck::Property< A, B, C, D, E >
5-argument property.
This class models a property (see PropertyBase) with 5-argument input. Default parameters serve the purpose of simulating variadic templates.
e.g. Property<A, B, C> (which is the same as Property<A, B, C, Unit, Unit>) is in fact a property of 3 arguments.
All templates arguments should have both a generator and an output stream operator.
Specialisation of this template class are provided for properties of 1, 2, 3 and 4 arguments.
- Template Parameters
-
A | type of first argument |
B | type of second argument (if Unit , then all later arguments should also be Unit and 1-argument property will be used instead) |
C | type of third argument (if Unit , then all later arguments should also be Unit and n-argument property ( n = 1 or 2) will be used instead) |
D | type of fourth argument (if Unit , then all later arguments should also be Unit and n-argument property ( n = 1, 2 or 3) will be used instead) |
E | type of fourth argument (if Unit , then n-argument property (n = 1, 2, 3 or 4) will be used instead) |
template<class A , class B , class C , class D , class E >
bool quickcheck::Property< A, B, C, D, E >::accepts |
( |
const A & |
a, |
|
|
const B & |
b, |
|
|
const C & |
c, |
|
|
const D & |
d, |
|
|
const E & |
e |
|
) |
| |
|
privatevirtual |
Tells whether or not this property should accept given arguments.
This predicate is used to filter generated input arguments to respect this property possible precondition.
Note that if too much inputs are rejected, the property may fail verification due to the impossibility to generate a sufficient number of valid inputs in the given number of attempts. If this occurs, you can augment the maximum number of allowed attempts when calling check or define a custom generator generateInput.
Also pay attention to the fact that filtering input arguments may lead to a biased distribution which is not representative of the set of valid inputs. You should inspect your input distribution with isTrivialFor or classify when using this predicate and you will often do better by defining a custom generator by re-implementing generateInput.
- Parameters
-
a | the first argument |
b | the second argument |
c | the third argument |
d | the fourth argument |
e | the fifth argument |
- Returns
true
if arguments forms valid input and false
otherwise
template<class A , class B , class C , class D , class E >
const std::string quickcheck::Property< A, B, C, D, E >::classify |
( |
const A & |
a, |
|
|
const B & |
b, |
|
|
const C & |
c, |
|
|
const D & |
d, |
|
|
const E & |
e |
|
) |
| |
|
privatevirtual |
Classifies input to allow observation of input distribution.
An input class is simply represented by a string which is used both as an input class identifier (i.e. same class string means same input class) and as output to the user. The empty string "" is used as a no-class tag and is not printed in input distribution.
- Parameters
-
a | the first argument |
b | the second argument |
c | the third argument |
d | the fourth argument |
e | the fifth argument |
- Returns
- the input class associated to input or empty string "" if none
template<class A , class B , class C , class D , class E >
void quickcheck::Property< A, B, C, D, E >::generateInput |
( |
size_t |
n, |
|
|
A & |
a, |
|
|
B & |
b, |
|
|
C & |
c, |
|
|
D & |
d, |
|
|
E & |
e |
|
) |
| |
|
privatevirtual |
Generates input randomly.
Override this method if you need a custom input generator.
All input arguments given here are out values, i.e. they can be assumed default or empty on entry and should be initialised to a sensible random value by this method.
The size of generated values should be somehow correlated to the size hint n
. When calling generators recursively to build compound data structures, you should pass a lower size hint to compound member generators to avoid the construction of overly large (or even infinite) data structures.
The quickcheck namespace contains a lot of generators that can be used to build your owns.
- Parameters
-
n | the size hint |
a | the first argument |
b | the second argument |
c | the third argument |
d | the fourth argument |
e | the fifth argument |
template<class A , class B = Unit, class C = Unit, class D = Unit, class E = Unit>
virtual bool quickcheck::Property< A, B, C, D, E >::holdsFor |
( |
const A & |
a, |
|
|
const B & |
b, |
|
|
const C & |
c, |
|
|
const D & |
d, |
|
|
const E & |
e |
|
) |
| |
|
privatepure virtual |
Tells whether or not this property holds for the given input.
This method is the core of the property which define what the property is all about. If the code under test is correct, it should return true
for all valid inputs. If the code under test is not correct, it should return false
for at least some valid input.
- Parameters
-
a | the first argument |
b | the second argument |
c | the third argument |
d | the fourth argument |
e | the fifth argument |
- Returns
true
if the property holds for given input and false
otherwise
template<class A , class B , class C , class D , class E >
bool quickcheck::Property< A, B, C, D, E >::isTrivialFor |
( |
const A & |
a, |
|
|
const B & |
b, |
|
|
const C & |
c, |
|
|
const D & |
d, |
|
|
const E & |
e |
|
) |
| |
|
privatevirtual |
Tells whether or not the property is trivially true for the given input.
This predicate allows to ensure that a sufficient number of tests were interesting. It is a restricted form of input classification.
- See Also
- classify
- Parameters
-
a | the first argument |
b | the second argument |
c | the third argument |
d | the fourth argument |
e | the fifth argument |
- Returns
true
if the property is trivial for given input and false
otherwise