quickcheck::PropertyBase< A, B, C, D, E > Class Template Reference

Generic property. More...

#include <Property.hh>

Inheritance diagram for quickcheck::PropertyBase< A, B, C, D, E >:

quickcheck::Property< A, B, C, D, E > quickcheck::Property< A > quickcheck::Property< A, B > quickcheck::Property< A, B, C > quickcheck::Property< A, B, C, D >

List of all members.

Public Member Functions

 PropertyBase ()
 Constructor.
virtual ~PropertyBase ()
 Destructor.
bool check (size_t n=100, size_t max=0, bool isVerbose=false, std::ostream &out=std::cout)
 Checks this property.

Protected Member Functions

void _addFixed (const A &a, const B &b, const C &c, const D &d, const E &e)
 Adds a fixed test case for with the given arguments.

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.

Private Attributes

std::vector< Input_fixedInputs
 A vector of fixed inputs that are tested in addition to randomly-generated inputs.

Classes

struct  Input
 Input type. More...


Detailed Description

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

Constructor & Destructor Documentation

template<class A, class B, class C, class D, class E>
quickcheck::PropertyBase< A, B, C, D, E >::PropertyBase (  )  [inline, explicit]

Constructor.

template<class A, class B, class C, class D, class E>
quickcheck::PropertyBase< A, B, C, D, E >::~PropertyBase (  )  [inline, virtual]

Destructor.


Member Function Documentation

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 
) [inline]

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

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 
) [inline, 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>
void quickcheck::PropertyBase< A, B, C, D, E >::printInput ( std::ostream &  out,
const A &  a,
const B &  b,
const C &  c,
const D &  d,
const E &  e 
) [inline, private]

Prints the given input arguments on the given output stream.

Parameters:
out the output stream to use
a the first argument
b the second argument or UNIT if less than two arguments
c the third argument or UNIT if less than three arguments
d the fourth argument or UNIT if less than four arguments
e the fifth argument or UNIT if less than five arguments

template<class A, class B, class C, class D, class E>
size_t quickcheck::PropertyBase< A, B, C, D, E >::sizeHint ( size_t  testNo  )  [inline, private, virtual]

Converts the random test number into a size hint.

Parameters:
testNo the number of the current random test
Returns:
a size hint for _generateInput

template<class A, class B, class C, class D, class E>
virtual bool quickcheck::PropertyBase< A, B, C, D, E >::_accepts ( const A &  a,
const B &  b,
const C &  c,
const D &  d,
const E &  e 
) [private, pure virtual]

Generic wrapper for Property::accepts.

Parameters:
a the first argument
b the second argument or UNIT if less than two arguments
c the third argument or UNIT if less than three arguments
d the fourth argument or UNIT if less than four arguments
e the fifth argument or UNIT if less than five arguments
Returns:
true if arguments forms valid input and false otherwise

Implemented in quickcheck::Property< A, B, C, D, E >.

template<class A, class B, class C, class D, class E>
virtual const std::string quickcheck::PropertyBase< A, B, C, D, E >::_classify ( const A &  a,
const B &  b,
const C &  c,
const D &  d,
const E &  e 
) [private, pure virtual]

Generic wrapper for Property::classify.

Parameters:
a the first argument
b the second argument or UNIT if less than two arguments
c the third argument or UNIT if less than three arguments
d the fourth argument or UNIT if less than four arguments
e the fifth argument or UNIT if less than five arguments
Returns:
a string representing the input class

Implemented in quickcheck::Property< A, B, C, D, E >.

template<class A, class B, class C, class D, class E>
virtual void quickcheck::PropertyBase< A, B, C, D, E >::_generateInput ( size_t  n,
A &  a,
B &  b,
C &  c,
D &  d,
E &  e 
) [private, pure virtual]

Generic wrapper for Property::generateInput.

Parameters:
n the size hint
a the first argument
b the second argument or UNIT if less than two arguments
c the third argument or UNIT if less than three arguments
d the fourth argument or UNIT if less than four arguments
e the fifth argument or UNIT if less than five arguments

Implemented in quickcheck::Property< A, B, C, D, E >.

template<class A, class B, class C, class D, class E>
virtual bool quickcheck::PropertyBase< A, B, C, D, E >::_holdsFor ( const A &  a,
const B &  b,
const C &  c,
const D &  d,
const E &  e 
) [private, pure virtual]

Generic wrappper for Property::holdsFor.

Parameters:
a the first argument
b the second argument or UNIT if less than two arguments
c the third argument or UNIT if less than three arguments
d the fourth argument or UNIT if less than four arguments
e the fifth argument or UNIT if less than five arguments
Returns:
true if the property holds and false otherwise

Implemented in quickcheck::Property< A, B, C, D, E >.

template<class A, class B, class C, class D, class E>
virtual bool quickcheck::PropertyBase< A, B, C, D, E >::_isTrivialFor ( const A &  a,
const B &  b,
const C &  c,
const D &  d,
const E &  e 
) [private, pure virtual]

Generic wrapper for Property::isTrivialFor.

Parameters:
a the first argument
b the second argument or UNIT if less than two arguments
c the third argument or UNIT if less than three arguments
d the fourth argument or UNIT if less than four arguments
e the fifth argument or UNIT if less than five arguments
Returns:
true if the property is trivial for given arguments and false otherwise

Implemented in quickcheck::Property< A, B, C, D, E >.


Member Data Documentation

template<class A, class B, class C, class D, class E>
std::vector<Input> quickcheck::PropertyBase< A, B, C, D, E >::_fixedInputs [private]

A vector of fixed inputs that are tested in addition to randomly-generated inputs.


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

Generated on Thu Apr 9 14:09:57 2009 for QuickCheck++ by  doxygen 1.5.6