quickcheck Namespace Reference

All classes, data generators and printers exported by QuickCheck++ are in the quickcheck namespace. More...


Classes

class  PropertyBase
 Generic property. More...
class  Property
 5-argument property. More...
class  Property< A, B, C, D >
 4-argument property. More...
class  Property< A, B, C >
 3-argument property. More...
class  Property< A, B >
 2-argument property. More...
class  Property< A >
 1-argument property. More...

Enumerations

enum  Unit { UNIT }
 A dummy type to help simulating variadic templates. More...

Functions

template<class A>
generateInRange (A low, A high)
 Generates a value in a range.
template<class A, class Iter>
oneOf (Iter first, Iter last)
 Chooses randomly an element out of a sequence.
template<class A>
generateInteger (size_t n)
 Generates randomly an integer value.
static void generate (size_t, bool &out)
 Generates a boolean value randomly.
static void generate (size_t n, char &out)
 Generates a character at random.
static void generate (size_t n, unsigned char &out)
static void generate (size_t n, short &out)
 Generates a short integer in range [-n, n].
static void generate (size_t n, unsigned short &out)
 Generates an unsigned short integer in range [0, n].
static void generate (size_t n, int &out)
 Generates an integer in range [-n, n].
static void generate (size_t n, unsigned int &out)
 Generates an unsigned integer in range [0, n].
static void generate (size_t n, long &out)
 Generates a long integer in range [-n, n].
static void generate (size_t n, unsigned long &out)
 Generates an unsigned long integer in range [0, n].
static void generate (size_t n, float &out)
 Generates a single-precision floating point value in range [-n, n].
static void generate (size_t n, double &out)
 Generates a double-precision floating point value in range [-n, n].
static void generate (size_t n, long double &out)
 Generates a long double floating point value in range [-n, n].
template<class A>
void generate (size_t n, std::vector< A > &out)
 Generates a vector of 0 to n randomly-generated values of type A.
template<class A>
std::ostream & operator<< (std::ostream &out, const std::vector< A > &xs)
 Insertion operator for vectors.
template<class A>
void printArgument (std::ostream &out, size_t n, const A &a)
 Prints an argument.
template<>
void printArgument (std::ostream &, size_t, const Unit &)
 Specialisation of printArgument for Unit.
template<class Prop>
bool check (const char *msg, size_t n=100, size_t max=0, bool isVerbose=false, std::ostream &out=std::cout)
 Creates and verifies a property.


Detailed Description

All classes, data generators and printers exported by QuickCheck++ are in the quickcheck namespace.

Todo:
tools to build test suites

Enumeration Type Documentation

A dummy type to help simulating variadic templates.

The name comes from type theory (Unit is a type containing a single element, generally also called unit, and often denoted by ()).

Enumerator:
UNIT 


Function Documentation

template<class Prop>
bool quickcheck::check ( const char *  msg,
size_t  n = 100,
size_t  max = 0,
bool  isVerbose = false,
std::ostream &  out = std::cout 
) [inline]

Creates and verifies a property.

Prints "Checking that\c msg..." and then instantiate and verifies the property Prop.

Template Parameters:
Prop the property type
Parameters:
msg the message identifying the property
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 verification succeeded and false otherwise

template<class A>
void quickcheck::generate ( size_t  n,
std::vector< A > &  out 
) [inline]

Generates a vector of 0 to n randomly-generated values of type A.

Template Parameters:
A the element type
Parameters:
n the size hint
out the reference to be set to the generated value

static void quickcheck::generate ( size_t  n,
long double &  out 
) [inline, static]

Generates a long double floating point value in range [-n, n].

Parameters:
n the size hint
out the reference to be set to the generated value

static void quickcheck::generate ( size_t  n,
double &  out 
) [inline, static]

Generates a double-precision floating point value in range [-n, n].

Parameters:
n the size hint
out the reference to be set to the generated value

static void quickcheck::generate ( size_t  n,
float &  out 
) [inline, static]

Generates a single-precision floating point value in range [-n, n].

Parameters:
n the size hint
out the reference to be set to the generated value

static void quickcheck::generate ( size_t  n,
unsigned long &  out 
) [inline, static]

Generates an unsigned long integer in range [0, n].

Parameters:
n the size hint
out the reference to be set to the generated value

static void quickcheck::generate ( size_t  n,
long &  out 
) [inline, static]

Generates a long integer in range [-n, n].

Parameters:
n the size hint
out the reference to be set to the generated value

static void quickcheck::generate ( size_t  n,
unsigned int &  out 
) [inline, static]

Generates an unsigned integer in range [0, n].

Parameters:
n the size hint
out the reference to be set to the generated value

static void quickcheck::generate ( size_t  n,
int &  out 
) [inline, static]

Generates an integer in range [-n, n].

Parameters:
n the size hint
out the reference to be set to the generated value

static void quickcheck::generate ( size_t  n,
unsigned short &  out 
) [inline, static]

Generates an unsigned short integer in range [0, n].

Parameters:
n the size hint
out the reference to be set to the generated value

static void quickcheck::generate ( size_t  n,
short &  out 
) [inline, static]

Generates a short integer in range [-n, n].

Parameters:
n the size hint
out the reference to be set to the generated value

static void quickcheck::generate ( size_t  n,
unsigned char &  out 
) [inline, static]

Generates a character at random.

For low values of n, the character is alphanumeric. For intermediate values, it is ASCII and printable. For high values of n, the generated character can have any value in its range, even if it means it is not ASCII and/or not printable.

Warning:
the zero character may be generated by this generator (n > 94)

the zero character is not generated very often by this generator (and only for n > 94)

Parameters:
n the size hint, influences the basicness of generated character
out the reference to be set to the generated character

static void quickcheck::generate ( size_t  n,
char &  out 
) [inline, static]

Generates a character at random.

For low values of n, the character is alphanumeric. For intermediate values, it is ASCII and printable. For high values of n, the generated character can have any value in its range, even if it means it is not ASCII and/or not printable.

Warning:
the zero character may be generated by this generator (n > 94)

the zero character is not generated very often by this generator (and only for n > 94)

Parameters:
n the size hint, influences the basicness of generated character
out the reference to be set to the generated character

static void quickcheck::generate ( size_t  ,
bool &  out 
) [inline, static]

Generates a boolean value randomly.

The size hint is ignored.

Parameters:
out the reference to be set to true or false at random

template<class A>
A quickcheck::generateInRange ( low,
high 
) [inline]

Generates a value in a range.

Template Parameters:
A the value type (must be numeric)
Parameters:
low the lower bound (inclusive)
high the higher bound (inclusive)
Returns:
a value between low and high (both inclusive).

template<class A>
A quickcheck::generateInteger ( size_t  n  )  [inline]

Generates randomly an integer value.

The value is taken in interval [0, n] for unsigned values and in interval [-n, n] for signed values. These intervals are of course clipped to the minimum and maximum values admissible for the returned type.

Template Parameters:
A the return type
Parameters:
n the size hint
Returns:
a random integer in the intersection of [-n, n] and the A's range

template<class A, class Iter>
A quickcheck::oneOf ( Iter  first,
Iter  last 
) [inline]

Chooses randomly an element out of a sequence.

Parameters:
first an iterator pointing to first element
last an iterator pointing to after-last element
Returns:
the chosen element

template<class A>
std::ostream& quickcheck::operator<< ( std::ostream &  out,
const std::vector< A > &  xs 
) [inline]

Insertion operator for vectors.

Parameters:
out the output stream to be printed on
xs the vector to print
Returns:
the output stream after printing

template<>
void quickcheck::printArgument ( std::ostream &  ,
size_t  ,
const Unit &   
) [inline]

Specialisation of printArgument for Unit.

Prints nothing.

template<class A>
void quickcheck::printArgument ( std::ostream &  out,
size_t  n,
const A &  a 
) [inline]

Prints an argument.

This template is used internally in PropertyBase to print input in case of failure or when verbose checking is requested.

Template Parameters:
A the argument type
Parameters:
out the output stream to use
n the argument number
a the argument


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