CppUnit - The Unit Testing Library

CppUnit project page | FAQ

Classes | Macros | Functions
TestAssert.h File Reference
`#include <cppunit/Portability.h>`
`#include <cppunit/Exception.h>`
`#include <cppunit/Asserter.h>`
`#include <cppunit/portability/Stream.h>`
`#include <stdio.h>`
`#include <float.h>`

Go to the source code of this file.

## Classes
struct | assertion_traits< T >
| Traits used by CPPUNIT_ASSERT_EQUAL(). More...
struct | assertion_traits< double >
| Traits used by CPPUNIT_ASSERT_DOUBLES_EQUAL(). More...

## Macros
#define | CPPUNIT_ASSERT(condition)
| Assertions that a condition is `true`. More...
#define | CPPUNIT_ASSERT_MESSAGE(message, condition)
| Assertion with a user specified message. More...
#define | CPPUNIT_FAIL(message)
| Fails with the specified message. More...
#define | CPPUNIT_ASSERT_EQUAL(expected, actual)
| Asserts that two values are equals. More...
#define | CPPUNIT_ASSERT_EQUAL_MESSAGE(message, expected, actual)
| Asserts that two values are equals, provides additional message on failure. More...
#define | CPPUNIT_ASSERT_DOUBLES_EQUAL(expected, actual, delta)
| Macro for primitive double value comparisons.The assertion pass if both expected and actual are finite and `fabs`( `expected` - `actual` ) <= `delta`. If either `expected` or actual are infinite (+/- inf), the assertion pass if `expected` == `actual`. If either `expected` or `actual` is a NaN (not a number), then the assertion fails. More...
#define | CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(message, expected, actual, delta)
| Macro for primitive double value comparisons, setting a user-supplied message in case of failure. More...
#define | CPPUNIT_ASSERT_THROW(expression, ExceptionType)
| Asserts that the given expression throws an exception of the specified type. More...
#define | CPPUNIT_EXTRACT_EXCEPTION_TYPE_(exception, no_rtti_message) std::string( no_rtti_message )
#define | CPPUNIT_GET_PARAMETER_STRING(parameter) #parameter
#define | CPPUNIT_ASSERT_THROW_MESSAGE(message, expression, ExceptionType)
| Asserts that the given expression throws an exception of the specified type, setting a user supplied message in case of failure. More...
#define | CPPUNIT_ASSERT_NO_THROW(expression)
| Asserts that the given expression does not throw any exceptions. More...
#define | CPPUNIT_ASSERT_NO_THROW_MESSAGE(message, expression)
| Asserts that the given expression does not throw any exceptions, setting a user supplied message in case of failure. More...
#define | CPPUNIT_ASSERT_ASSERTION_FAIL(assertion) CPPUNIT_ASSERT_THROW( assertion, CPPUNIT_NS::Exception )
| Asserts that an assertion fail. More...
#define | CPPUNIT_ASSERT_ASSERTION_FAIL_MESSAGE(message, assertion) CPPUNIT_ASSERT_THROW_MESSAGE( message, assertion, CPPUNIT_NS::Exception )
| Asserts that an assertion fail, with a user-supplied message in case of error. More...
#define | CPPUNIT_ASSERT_ASSERTION_PASS(assertion) CPPUNIT_ASSERT_NO_THROW( assertion )
| Asserts that an assertion pass. More...
#define | CPPUNIT_ASSERT_ASSERTION_PASS_MESSAGE(message, assertion) CPPUNIT_ASSERT_NO_THROW_MESSAGE( message, assertion )
| Asserts that an assertion pass, with a user-supplied message in case of failure. More...

## Functions
template<class T >
void | assertEquals (const T &expected, const T &actual, SourceLine sourceLine, const std::string &message)
| (Implementation) Asserts that two objects of the same type are equals. Use CPPUNIT_ASSERT_EQUAL instead of this function. More...
void CPPUNIT_API | assertDoubleEquals (double expected, double actual, double delta, SourceLine sourceLine, const std::string &message)
| (Implementation) Asserts that two double are equals given a tolerance. Use CPPUNIT_ASSERT_DOUBLES_EQUAL instead of this function. More...

## Macro Definition Documentation

## § CPPUNIT_EXTRACT_EXCEPTION_TYPE_

#define CPPUNIT_EXTRACT_EXCEPTION_TYPE_ | ( |  | exception,
|  |  | no_rtti_message
| ) |  | std::string( no_rtti_message )

## § CPPUNIT_GET_PARAMETER_STRING

#define CPPUNIT_GET_PARAMETER_STRING | ( |  | parameter | ) | #parameter

## Function Documentation

## § assertDoubleEquals()

void CPPUNIT_API assertDoubleEquals | ( | double | expected,
|  | double | actual,
|  | double | delta,
|  | SourceLine | sourceLine,
|  | const std::string & | message
| ) |  |

(Implementation) Asserts that two double are equals given a tolerance. Use CPPUNIT_ASSERT_DOUBLES_EQUAL instead of this function.

See also
  Asserter::failNotEqual().
  CPPUNIT_ASSERT_DOUBLES_EQUAL for detailed semantic of the assertion.

## § assertEquals()

template<class T >

void assertEquals | ( | const T & | expected,
|  | const T & | actual,
|  | SourceLine | sourceLine,
|  | const std::string & | message
| ) |  |

(Implementation) Asserts that two objects of the same type are equals. Use CPPUNIT_ASSERT_EQUAL instead of this function.

See also
  assertion_traits, Asserter::failNotEqual().

| Send comments to: CppUnit Developers