CPUnit 0.95 (beta)
The REAL C++ port of JUnit.
cpunit Namespace Reference

Namespaces

namespace  impl
namespace  priv

Classes

class  AssertionException
 Thrown when an assert fails, or if someone calls cpunit::fail(). More...
class  BasicTestRunner
 The only implementation of TestRunner that actually executes tests. More...
class  Callable
class  CmdLineParser
 Class implementing command line parsing functionality. More...
class  ConformityChecker
class  CPUnitException
 Common superclass for all exceptions thrown by the CPUnit test framework. More...
class  ErrorReportFormat
class  ExceptionExpectedCall
struct  AnyType
class  ExceptionExpectedCall< AnyType >
class  ExceptionTestRegistrar
class  ExecutionReport
class  FixtureRegistrar
class  FuncTestRegistrar
class  FunctionCall
class  GlobMatcher
class  IllegalArgumentException
 Signals that a method has been called with wrong arguments. More...
class  RegInfo
 Registration data for unit tests. More...
class  RunAllTestRunner
class  StopWatch
class  StringFlyweightStore
 Flyweight pattern implementation for std::string objects. More...
class  StringFlyweightStoreUsage
 Users of the StringFlyweightStore may contain an instance of StringFlyweightStoreUsage to make sure the StringFlyweightStore is not disposed before the user object dies. More...
class  TestExecutionFacade
class  TestRunner
class  TestRunnerDecorator
 This class implements functionality enabling objects to be part of the test runner chain. More...
class  TestStore
 This class is where all tests are registered. More...
class  TestTreeNode
class  SafeTearDown
class  TestUnit
class  TimeFormat
class  TimeGuardRunner
class  WrongSetupException
 Thrown to signal wrong usage of CPUnit. More...

Functions

template<class T >
void assert_equals (const std::string &msg, const T &expected, const T &actual)
 Check that two objects are equal, using ==.
template<class T >
void assert_equals (const T &expected, const T &actual)
 Check that two objects are equal, using ==.
template<class T , class Eq >
void assert_equals (const std::string &msg, const T &expected, const T &actual, const Eq &eq)
 Check that two objects are equal, using a custom comparator.
template<class T , class Eq >
void assert_equals (const T &expected, const T &actual, const Eq &eq)
 Check that two objects are equal, using a custom comparator.
void assert_equals (const std::string &msg, const double expected, const double actual, const double error)
 Check that two floating point numbers are sufficiently closed to be reckoned as equal.
void assert_equals (const double expected, const double actual, const double error)
 Check that two floating point numbers are sufficiently closed to be reckoned as equal.
void assert_equals (const std::string &msg, const char *expected, const char *actual)
 Check that two C-strings are equal, using the == operator of std::string.
void assert_equals (const char *expected, const char *actual)
 Check that two C-strings are equal, using the == operator of std::string.
void assert_equals (const std::string &msg, const std::string &expected, const std::string &actual)
 Check that two strings are equal, using the == operator of std::string.
void assert_equals (const std::string &expected, const std::string &actual)
 Check that two strings are equal, using the == operator of std::string.
void assert_true (const std::string &msg, const bool statement)
 Checks that a statement is true.
void assert_true (const bool statement)
 Checks that a statement is true.
void assert_false (const std::string &msg, const bool statement)
 Checks that a statement is false.
void assert_false (const bool statement)
 Checks that a statement is false.
void assert_not_null (const std::string &msg, const void *data)
 Checks that a pointer is not NULL.
void assert_not_null (const void *data)
 Checks that a pointer is not NULL.
void assert_null (const std::string &msg, const void *data)
 Checks that a pointer is NULL.
void assert_null (const void *data)
 Checks that a pointer is NULL.
void fail (const std::string &msg)
 Causes an AssertionException to be thrown.
void fail ()
 Causes an AssertionException to be thrown.
template<>
std::string CmdLineParser::value_of< std::string > (const std::string &arg) const
CmdLineParser get_cmd_line_parser ()
 Creates a command line parser initialized with default values.
int main (const int argc, const char **args)
 Forward your program parameters directly from main to this function to start CPUnit.
int main (const CmdLineParser &parser)
 If you have extra command line parameters, you may use this method to start CPUnit after you have done your own.
template<class T , class A >
std::ostream & operator<< (std::ostream &out, const std::vector< T, A > &vec)
template<class T , class A >
std::ostream & operator<< (std::ostream &out, const std::list< T, A > &lst)
template<class T , class A >
std::ostream & operator<< (std::ostream &out, const std::deque< T, A > &d)
template<class T , class C >
std::ostream & operator<< (std::ostream &out, const std::set< T, C > &s)
template<class K , class C , class A >
std::ostream & operator<< (std::ostream &out, const std::multiset< K, C, A > &s)
template<class K , class T , class C , class A >
std::ostream & operator<< (std::ostream &out, const std::map< K, T, C, A > &m)
template<class K , class T , class C , class A >
std::ostream & operator<< (std::ostream &out, const std::multimap< K, T, C, A > &m)
template<class Iterator >
std::ostream & stream_objects (std::ostream &out, const Iterator &start, const int count, const char *bounds)
template<class Iterator >
std::ostream & stream_pairs (std::ostream &out, const Iterator &start, const int count, const char *bounds)
std::ostream & operator<< (std::ostream &out, const TimeFormat &f)

Variables

static const int max_list_display = 20
static const int alt_list_display = 5

Function Documentation

template<class T >
void cpunit::assert_equals ( const std::string &  msg,
const T &  expected,
const T &  actual 
)

Check that two objects are equal, using ==.

If you need comparisons on objects which do not support ==, or == is insufficient, please use assert_equals(const std::string&, const T&, const T&, const Eq&).

Template Parameters:
TThe type of the objects to compare. The type must support the operator '==' as well as the stream operator std::ostream& operator << (std::ostream&, const T&)
Parameters:
msgA text to be displayed together with the error message if the comparison fails.
expectedThe expected value.
actualThe actual value to test against the facit 'expected'.
Exceptions:
AssertionExceptionif the assert fails.

Definition at line 50 of file cpunit_Assert.tcc.

template<class T >
void cpunit::assert_equals ( const T &  expected,
const T &  actual 
)

Check that two objects are equal, using ==.

If you need comparisons on objects which do not support ==, or == is insufficient, please use assert_equals(const T&, const T&, const Eq&).

Template Parameters:
TThe type of the objects to compare. The type must support the operator '==' as well as the stream operator std::ostream& operator << (std::ostream&, const T&)
Parameters:
expectedThe expected value.
actualThe actual value to test against the facit 'expected'.
Exceptions:
AssertionExceptionif the assert fails.

Definition at line 68 of file cpunit_Assert.tcc.

template<class T , class Eq >
void cpunit::assert_equals ( const T &  expected,
const T &  actual,
const Eq &  eq 
)

Check that two objects are equal, using a custom comparator.

Template Parameters:
TThe type of the objects to compare. The type must support the operator '==' as well as the stream operator std::ostream& operator << (std::ostream&, const T&)
EqThe type of comparator to use. The type must offer an operator 'bool operator () (const T&, const T&) const'.
Parameters:
expectedThe expected value.
actualThe actual value to test against the facit 'expected'.
eqThe comparator object to use.
Exceptions:
AssertionExceptionif the assert fails.

Definition at line 105 of file cpunit_Assert.tcc.

void cpunit::assert_equals ( const char *  expected,
const char *  actual 
)

Check that two C-strings are equal, using the == operator of std::string.

Parameters:
expectedThe expected value.
actualThe actual value to test against the facit 'expected'.
Exceptions:
AssertionExceptionif the assert fails.

Definition at line 144 of file cpunit_Assert.cpp.

void cpunit::assert_equals ( const std::string &  msg,
const std::string &  expected,
const std::string &  actual 
)

Check that two strings are equal, using the == operator of std::string.

Parameters:
msgA text to be displayed together with the error message if the comparison fails.
expectedThe expected value.
actualThe actual value to test against the facit 'expected'.
Exceptions:
AssertionExceptionif the assert fails.

Definition at line 155 of file cpunit_Assert.cpp.

void cpunit::assert_equals ( const std::string &  msg,
const double  expected,
const double  actual,
const double  error 
)

Check that two floating point numbers are sufficiently closed to be reckoned as equal.

The expected and actual values are considered equal if abs(expected - actual) <= error.

Parameters:
msgA text to be displayed together with the error message if the comparison fails.
expectedThe expected value.
actualThe actual value to test against the facit 'expected'.
errorThe maximal allowed difference between 'expected' and 'actual'.
Exceptions:
AssertionExceptionif the assert fails.

Definition at line 109 of file cpunit_Assert.cpp.

void cpunit::assert_equals ( const std::string &  expected,
const std::string &  actual 
)

Check that two strings are equal, using the == operator of std::string.

Parameters:
expectedThe expected value.
actualThe actual value to test against the facit 'expected'.
Exceptions:
AssertionExceptionif the assert fails.

Definition at line 167 of file cpunit_Assert.cpp.

template<class T , class Eq >
void cpunit::assert_equals ( const std::string &  msg,
const T &  expected,
const T &  actual,
const Eq &  eq 
)

Check that two objects are equal, using a custom comparator.

Template Parameters:
TThe type of the objects to compare. The type must support the operator '==' as well as the stream operator std::ostream& operator << (std::ostream&, const T&)
EqThe type of comparator to use. The type must offer an operator 'bool operator () (const T&, const T&) const'.
Parameters:
msgA text to be displayed together with the error message if the comparison fails.
expectedThe expected value.
actualThe actual value to test against the facit 'expected'.
eqThe comparator object to use.
Exceptions:
AssertionExceptionif the assert fails.

Definition at line 86 of file cpunit_Assert.tcc.

void cpunit::assert_equals ( const double  expected,
const double  actual,
const double  error 
)

Check that two floating point numbers are sufficiently closed to be reckoned as equal.

The expected and actual values are considered equal if abs(expected - actual) <= error.

Parameters:
expectedThe expected value.
actualThe actual value to test against the facit 'expected'.
errorThe maximal allowed difference between 'expected' and 'actual'.
Exceptions:
AssertionExceptionif the assert fails.

Definition at line 123 of file cpunit_Assert.cpp.

void cpunit::assert_equals ( const std::string &  msg,
const char *  expected,
const char *  actual 
)

Check that two C-strings are equal, using the == operator of std::string.

Parameters:
msgA text to be displayed together with the error message if the comparison fails.
expectedThe expected value.
actualThe actual value to test against the facit 'expected'.
Exceptions:
AssertionExceptionif the assert fails.

Definition at line 134 of file cpunit_Assert.cpp.

void cpunit::assert_false ( const std::string &  msg,
const bool  statement 
)

Checks that a statement is false.

Parameters:
msgA text to be displayed together with the error message if the assertion fails.
statementThe statement to check for falseness.
Exceptions:
AssertionExceptionif the assert fails.

Definition at line 83 of file cpunit_Assert.cpp.

void cpunit::assert_false ( const bool  statement)

Checks that a statement is false.

Parameters:
statementThe statement to check for falseness.
Exceptions:
AssertionExceptionif the assert fails.

Definition at line 96 of file cpunit_Assert.cpp.

void cpunit::assert_not_null ( const void *  data)

Checks that a pointer is not NULL.

Parameters:
dataThe pointer to test.
Exceptions:
AssertionExceptionif the assert fails.

Definition at line 192 of file cpunit_Assert.cpp.

void cpunit::assert_not_null ( const std::string &  msg,
const void *  data 
)

Checks that a pointer is not NULL.

Parameters:
msgA text to be displayed together with the error message if the test fails.
dataThe pointer to test.
Exceptions:
AssertionExceptionif the assert fails.

Definition at line 179 of file cpunit_Assert.cpp.

void cpunit::assert_null ( const std::string &  msg,
const void *  data 
)

Checks that a pointer is NULL.

Parameters:
msgA text to be displayed together with the error message if the test fails.
dataThe pointer to test.
Exceptions:
AssertionExceptionif the assert fails.

Definition at line 202 of file cpunit_Assert.cpp.

void cpunit::assert_null ( const void *  data)

Checks that a pointer is NULL.

Parameters:
dataThe pointer to test.
Exceptions:
AssertionExceptionif the assert fails.

Definition at line 215 of file cpunit_Assert.cpp.

void cpunit::assert_true ( const std::string &  msg,
const bool  statement 
)

Checks that a statement is true.

Parameters:
msgA text to be displayed together with the error message if the assertion fails.
statementThe statement to check for truthfulness.
Exceptions:
AssertionExceptionif the assert fails.

Definition at line 60 of file cpunit_Assert.cpp.

void cpunit::assert_true ( const bool  statement)

Checks that a statement is true.

Parameters:
statementThe statement to check for truthfulness.
Exceptions:
AssertionExceptionif the assert fails.

Definition at line 73 of file cpunit_Assert.cpp.

template<>
std::string cpunit::CmdLineParser::value_of< std::string > ( const std::string &  arg) const
void cpunit::fail ( const std::string &  msg)

Causes an AssertionException to be thrown.

Parameters:
msgThe error message to display.
Exceptions:
AssertionExceptionallways.

Definition at line 40 of file cpunit_Assert.cpp.

void cpunit::fail ( )

Causes an AssertionException to be thrown.

Exceptions:
AssertionExceptionallways.

Definition at line 50 of file cpunit_Assert.cpp.

CmdLineParser cpunit::get_cmd_line_parser ( )

Creates a command line parser initialized with default values.

Returns:
a command line parser initialized with default values.

Definition at line 233 of file cpunit_EntryPoint.cpp.

int cpunit::main ( const int  argc,
const char **  args 
)

Forward your program parameters directly from main to this function to start CPUnit.

Parameters:
argcThe number of arguments, including the program name.
argsThe program arguments, including the program name.
Returns:
0 if all tests succeed, and >0 elsewise.

Definition at line 255 of file cpunit_EntryPoint.cpp.

int cpunit::main ( const CmdLineParser &  parser)

If you have extra command line parameters, you may use this method to start CPUnit after you have done your own.

You should use get_cmd_line_parser() to obtain a parser which is already set up to accept the CPUnit specific command line parameters, and then use CmdLineParser.add_legal to specify the arguments you expect in addition.

Parameters:
parserA parser contaiing the command line arguments, excluding the program name. I.e. from main(int& argc,char** args), the parser would be called as parser.parse(arcg-1,args+1).
Returns:
0 if all tests succeed, and >0 elsewise.

Definition at line 272 of file cpunit_EntryPoint.cpp.

std::ostream & cpunit::operator<< ( std::ostream &  out,
const TimeFormat &  f 
)

Definition at line 54 of file cpunit_TimeFormat.cpp.

template<class K , class T , class C , class A >
std::ostream & cpunit::operator<< ( std::ostream &  out,
const std::multimap< K, T, C, A > &  m 
)

Definition at line 117 of file cpunit_Ostreams.tcc.

template<class T , class C >
std::ostream & cpunit::operator<< ( std::ostream &  out,
const std::set< T, C > &  s 
)

Definition at line 99 of file cpunit_Ostreams.tcc.

template<class T , class A >
std::ostream & cpunit::operator<< ( std::ostream &  out,
const std::deque< T, A > &  d 
)

Definition at line 93 of file cpunit_Ostreams.tcc.

template<class T , class A >
std::ostream & cpunit::operator<< ( std::ostream &  out,
const std::list< T, A > &  lst 
)

Definition at line 87 of file cpunit_Ostreams.tcc.

template<class K , class C , class A >
std::ostream & cpunit::operator<< ( std::ostream &  out,
const std::multiset< K, C, A > &  s 
)

Definition at line 105 of file cpunit_Ostreams.tcc.

template<class T , class A >
std::ostream & cpunit::operator<< ( std::ostream &  out,
const std::vector< T, A > &  vec 
)

Definition at line 81 of file cpunit_Ostreams.tcc.

template<class K , class T , class C , class A >
std::ostream & cpunit::operator<< ( std::ostream &  out,
const std::map< K, T, C, A > &  m 
)

Definition at line 111 of file cpunit_Ostreams.tcc.

template<class Iterator >
std::ostream & cpunit::stream_objects ( std::ostream &  out,
const Iterator &  start,
const int  count,
const char *  bounds 
)

Definition at line 36 of file cpunit_Ostreams.tcc.

template<class Iterator >
std::ostream & cpunit::stream_pairs ( std::ostream &  out,
const Iterator &  start,
const int  count,
const char *  bounds 
)

Definition at line 58 of file cpunit_Ostreams.tcc.


Variable Documentation

const int cpunit::alt_list_display = 5 [static]

Definition at line 75 of file cpunit_Ostreams.hpp.

const int cpunit::max_list_display = 20 [static]

Definition at line 72 of file cpunit_Ostreams.hpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines