Private Member Functions |
void | printInput (std::ostream &out, const A &a, const B &b, const C &c, const D &d, const E &e) |
| Prints the given input arguments on the given output stream.
|
virtual size_t | sizeHint (size_t testNo) |
| Converts the random test number into a size hint.
|
virtual bool | _accepts (const A &a, const B &b, const C &c, const D &d, const E &e)=0 |
| Generic wrapper for Property::accepts.
|
virtual const std::string | _classify (const A &a, const B &b, const C &c, const D &d, const E &e)=0 |
| Generic wrapper for Property::classify.
|
virtual void | _generateInput (size_t n, A &a, B &b, C &c, D &d, E &e)=0 |
| Generic wrapper for Property::generateInput.
|
virtual bool | _holdsFor (const A &a, const B &b, const C &c, const D &d, const E &e)=0 |
| Generic wrappper for Property::holdsFor.
|
virtual bool | _isTrivialFor (const A &a, const B &b, const C &c, const D &d, const E &e)=0 |
| Generic wrapper for Property::isTrivialFor.
|
template<class A, class B, class C, class D, class E>
class quickcheck::PropertyBase< A, B, C, D, E >
Generic property.
This class models a verifiable property about some code fragment. It is not meant to be used or derived from directly but rather serves as a base for the various n-argument classes Property. This is just an artefact due to the fact that C++ 98 does not support variadic templates. It can model up to 5-arguments properties.
- Template Parameters
-
A | first argument type |
B | second argument type or Unit if less than two arguments |
C | third argument type or Unit if less than three arguments |
D | fourth argument type or Unit if less than four arguments |
E | fifth argument type or Unit if less than five arguments |
template<class A, class B, class C, class D, class E>
void quickcheck::PropertyBase< A, B, C, D, E >::_addFixed |
( |
const A & |
a, |
|
|
const B & |
b, |
|
|
const C & |
c, |
|
|
const D & |
d, |
|
|
const E & |
e |
|
) |
| |
|
protected |
Adds a fixed test case for with the given arguments.
This function allows to ensure that some carefully chosen test cases will be checked in addition to the randomly-generated ones.
- Parameters
-
a | the first argument of the test case |
b | the second argument of the test case |
c | the third argument of the test case |
d | the fourth argument of the test case |
e | the fifth argument of the test case |
template<class A , class B , class C , class D , class E >
bool quickcheck::PropertyBase< A, B, C, D, E >::check |
( |
size_t |
n = 100 , |
|
|
size_t |
max = 0 , |
|
|
bool |
isVerbose = false , |
|
|
std::ostream & |
out = std::cout |
|
) |
| |
Checks this property.
This method will verify that this property holds for all the fixed inputs and for a number of randomly generated inputs. It prints messages about success or failure (and optionally process) on the given output stream.
- Parameters
-
n | the number of random tests to run |
max | the maximum number of attempts to generate valid input (defaults to 5 * n if lower than n ) |
isVerbose | true if input should be printed before each test |
out | the output stream to use |
- Returns
true
if all tests succeeded and false
if a test failed or if a sufficient number of tests could not be generated