CppUnit project page FAQ CppUnit home page

Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Making assertions


Defines

#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 messafe on failure. More...

#define CPPUNIT_ASSERT_DOUBLES_EQUAL(expected, actual, delta)
 Macro for primitive value comparisons. More...


Define Documentation

#define CPPUNIT_ASSERT condition   
 

Value:

( ::CppUnit::Asserter::failIf( !(condition),             \
                                 (#condition),             \
                                 CPPUNIT_SOURCELINE() ) )
Assertions that a condition is true.

#define CPPUNIT_ASSERT_DOUBLES_EQUAL expected,
actual,
delta   
 

Value:

( ::CppUnit::TestAssert::assertDoubleEquals( (expected),        \
                                               (actual),          \
                                               (delta),           \
                                               CPPUNIT_SOURCELINE() ) )
Macro for primitive value comparisons.

#define CPPUNIT_ASSERT_EQUAL expected,
actual   
 

Value:

( ::CppUnit::TestAssert::assertEquals( (expected),              \
                                         (actual),                \
                                         CPPUNIT_SOURCELINE() ) )
Asserts that two values are equals.

Equality and string representation can be defined with an appropriate CppUnit::assertion_traits class.

A diagnostic is printed if actual and expected values disagree.

Requirement for expected and actual parameters:

  • They are exactly of the same type
  • They are serializable into a std::strstream using operator<<.
  • They can be compared using operator==.
The last two requirements (serialization and comparison) can be removed by specializing the CppUnit::assertion_traits.

#define CPPUNIT_ASSERT_EQUAL_MESSAGE message,
expected,
actual   
 

Value:

( ::CppUnit::TestAssert::assertEquals( (expected),              \
                                         (actual),                \
                                         CPPUNIT_SOURCELINE(),    \
                                         (message) ) )
Asserts that two values are equals, provides additional messafe on failure.

Equality and string representation can be defined with an appropriate assertion_traits class.

A diagnostic is printed if actual and expected values disagree. The message is printed in addition to the expected and actual value to provide additional information.

Requirement for expected and actual parameters:

  • They are exactly of the same type
  • They are serializable into a std::strstream using operator<<.
  • They can be compared using operator==.
The last two requirements (serialization and comparison) can be removed by specializing the CppUnit::assertion_traits.

#define CPPUNIT_ASSERT_MESSAGE message,
condition   
 

Value:

( ::CppUnit::Asserter::failIf( !(condition),             \
                                 (message),                \
                                 CPPUNIT_SOURCELINE() ) )
Assertion with a user specified message.

Parameters:
message  Message reported in diagnostic if condition evaluates to false.
condition  If this condition evaluates to false then the test failed.

#define CPPUNIT_FAIL message   
 

Value:

( ::CppUnit::Asserter::fail( message,                    \
                               CPPUNIT_SOURCELINE() ) )
Fails with the specified message.

Parameters:
message  Message reported in diagnostic.


SourceForge Logo hosts this site. Send comments to:
CppUnit Developers