CPUnit 0.7 (beta)
The REAL C++ port of JUnit.
unittest Namespace Reference

Namespaces

namespace  impl
namespace  priv

Classes

class  AssertionException
 Thrown when an assert fails, or if someone calls unittest::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  ErrorReportFormat
class  ExecutionReport
class  FixtureRegistrar
class  FuncTestRegistrar
class  FunctionCall
class  GlobMatcher
class  IllegalArgumentException
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
class  TestTreeNode
class  SafeTearDown
class  TestUnit
class  TimeFormat
class  TimeGuardRunner
class  UnitTestException
class  WrongSetupException

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_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)

Function Documentation

template<class T >
void unittest::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 unittest_Assert.tcc.

template<class T >
void unittest::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 unittest_Assert.tcc.

template<class T , class Eq >
void unittest::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 unittest_Assert.tcc.

void unittest::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 unittest_Assert.cpp.

template<class T , class Eq >
void unittest::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 unittest_Assert.tcc.

void unittest::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 unittest_Assert.cpp.

void unittest::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 unittest_Assert.cpp.

void unittest::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 unittest_Assert.cpp.

void unittest::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 133 of file unittest_Assert.cpp.

void unittest::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 146 of file unittest_Assert.cpp.

void unittest::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 156 of file unittest_Assert.cpp.

void unittest::assert_null ( const void *  data)

Checks that a pointer is NULL.

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

Definition at line 169 of file unittest_Assert.cpp.

void unittest::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 unittest_Assert.cpp.

void unittest::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 unittest_Assert.cpp.

template<>
std::string unittest::CmdLineParser::value_of< std::string > ( const std::string  arg) const
void unittest::fail ( )

Causes an AssertionException to be thrown.

Exceptions:
AssertionExceptionallways.

Definition at line 50 of file unittest_Assert.cpp.

void unittest::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 unittest_Assert.cpp.

CmdLineParser unittest::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 unittest_EntryPoint.cpp.

int unittest::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 unittest_EntryPoint.cpp.

int unittest::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 unittest_EntryPoint.cpp.

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

Definition at line 105 of file unittest_Ostreams.tcc.

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

Definition at line 99 of file unittest_Ostreams.tcc.

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

Definition at line 81 of file unittest_Ostreams.tcc.

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

Definition at line 93 of file unittest_Ostreams.tcc.

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

Definition at line 51 of file unittest_TimeFormat.cpp.

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

Definition at line 117 of file unittest_Ostreams.tcc.

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

Definition at line 111 of file unittest_Ostreams.tcc.

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

Definition at line 87 of file unittest_Ostreams.tcc.

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

Definition at line 36 of file unittest_Ostreams.tcc.

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

Definition at line 58 of file unittest_Ostreams.tcc.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines