CppUnit project page | FAQ | CppUnit home page |
Defines | |
#define | CPPUNIT_ASSERT(condition) |
Assertions that a condition is true . | |
#define | CPPUNIT_ASSERT_MESSAGE(message, condition) |
Assertion with a user specified message. | |
#define | CPPUNIT_FAIL(message) |
Fails with the specified message. | |
#define | CPPUNIT_ASSERT_EQUAL(expected, actual) |
Asserts that two values are equals. | |
#define | CPPUNIT_ASSERT_EQUAL_MESSAGE(message, expected, actual) |
Asserts that two values are equals, provides additional messafe on failure. | |
#define | CPPUNIT_ASSERT_DOUBLES_EQUAL(expected, actual, delta) |
Macro for primitive value comparisons. | |
#define | CPPUNIT_ASSERT_THROW(expression, ExceptionType) |
Asserts that the given expression throws an exception of the specified type. | |
#define | CPPUNIT_ASSERT_NO_THROW(expression) |
Asserts that the given expression does not throw any exceptions. | |
#define | CPPUNIT_ASSERT_ASSERTION_FAIL(assertion) CPPUNIT_ASSERT_THROW( assertion, CPPUNIT_NS::Exception ) |
Asserts that an assertion fail. | |
#define | CPPUNIT_ASSERT_ASSERTION_PASS(assertion) CPPUNIT_ASSERT_NO_THROW( assertion ) |
Asserts that an assertion pass. |
|
Value: ( CPPUNIT_NS::Asserter::failIf( !(condition), \ CPPUNIT_NS::Message( "assertion failed", \ "Expression: " #condition), \ CPPUNIT_SOURCELINE() ) ) true .
|
|
Asserts that an assertion fail. Use to test assertions. Example of usage: CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT( 1 == 2 ) ); |
|
Asserts that an assertion pass. Use to test assertions. Example of usage: CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT( 1 == 1 ) ); |
|
Value: ( CPPUNIT_NS::assertDoubleEquals( (expected), \ (actual), \ (delta), \ CPPUNIT_SOURCELINE() ) )
|
|
Value: ( CPPUNIT_NS::assertEquals( (expected), \ (actual), \ CPPUNIT_SOURCELINE(), \ "" ) ) 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:
The last two requirements (serialization and comparison) can be removed by specializing the CppUnit::assertion_traits. |
|
Value: ( CPPUNIT_NS::assertEquals( (expected), \ (actual), \ CPPUNIT_SOURCELINE(), \ (message) ) ) 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:
The last two requirements (serialization and comparison) can be removed by specializing the CppUnit::assertion_traits. |
|
Value: ( CPPUNIT_NS::Asserter::failIf( !(condition), \ (message), \ CPPUNIT_SOURCELINE() ) )
|
|
Value: try { \ expression; \ } catch ( const std::exception &e ) { \ CPPUNIT_NS::Message message( "Unexpected exception caught" ); \ message.addDetail( "Type: " + \ CPPUNIT_EXTRACT_EXCEPTION_TYPE_( e, \ "std::exception or derived" ) ); \ message.addDetail( std::string("What: ") + e.what() ); \ CPPUNIT_NS::Asserter::fail( message, \ CPPUNIT_SOURCELINE() ); \ } catch ( ... ) { \ CPPUNIT_NS::Asserter::fail( "Unexpected exception caught", \ CPPUNIT_SOURCELINE() ); \ } Example of usage: std::vector<int> v; v.push_back( 10 ); CPPUNIT_ASSERT_NO_THROW( v.at( 0 ) ); |
|
Value: do { \ bool cpputExceptionThrown_ = false; \ try { \ expression; \ } catch ( const ExceptionType & ) { \ cpputExceptionThrown_ = true; \ } \ \ if ( cpputExceptionThrown_ ) \ break; \ \ CPPUNIT_NS::Asserter::fail( \ "Expected exception: " #ExceptionType \ " not thrown.", \ CPPUNIT_SOURCELINE() ); \ } while ( false ) Example of usage: std::vector<int> v; CPPUNIT_ASSERT_THROW( v.at( 50 ), std::out_of_range ); |
|
Value: ( CPPUNIT_NS::Asserter::fail( CPPUNIT_NS::Message( "forced failure", \ message ), \ CPPUNIT_SOURCELINE() ) )
|
|
hosts this site. |
Send comments to: CppUnit Developers |