From: <bl...@us...> - 2003-05-01 18:53:23
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv24787/src/rfta Modified Files: UnitTesting.h Log Message: * introduced RFTA_CUSTOM_ASSERT * moved common UnitTesting.h parts to include/rfta/test/UnitTesting.h Index: UnitTesting.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/UnitTesting.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** UnitTesting.h 8 Mar 2003 13:11:42 -0000 1.4 --- UnitTesting.h 1 May 2003 18:53:19 -0000 1.5 *************** *** 2,89 **** #define RFTA_UNITTESTING_H ! #include <cppunit/extensions/HelperMacros.h> ! #include <sstream> ! #include <typeinfo> ! ! namespace Refactoring ! { ! namespace Testing ! { ! template<typename FirstType ! ,typename SecondType ! > ! void checkEquals( const FirstType &expected, ! const SecondType &actual, ! const CppUnit::AdditionalMessage &message, ! const CppUnit::SourceLine &sourceLine ) ! { ! if ( expected == actual ) ! return; ! ! std::ostringstream sExpected; ! sExpected << expected; ! std::ostringstream sActual; ! sActual << actual; ! ! CppUnit::Message fixedMessage; ! if ( !message.shortDescription().empty() ) ! fixedMessage.addDetail( message.shortDescription() ); ! for ( int index =0; index < message.detailCount(); ++index ) ! fixedMessage.addDetail( message.detailAt( index ) ); ! ! CppUnit::Asserter::failNotEqual( sExpected.str(), ! sActual.str(), ! sourceLine, ! fixedMessage ); ! } ! ! ! inline void checkType( const std::type_info &expectedType, ! const std::type_info &actualType, ! const std::string &expression, ! const CppUnit::SourceLine &sourceLine ) ! { ! if ( expectedType == actualType ) ! return; ! ! CppUnit::Message message( "expression is not of the expected type" ); ! message.addDetail( std::string("Expected type: ") + expectedType.name() ); ! message.addDetail( std::string("Actual type: ") + actualType.name() ); ! if ( !expression.empty() ) ! message.addDetail( "Expression: " + expression ); ! ! CppUnit::Asserter::fail( message, sourceLine ); ! } ! ! } ! } ! ! ! #define RFTA_ASSERT_EQUAL( x, y ) \ ! Refactoring::Testing::checkEquals( x, y, "", CPPUNIT_SOURCELINE() ) ! ! #define RFTA_ASSERTM_EQUAL( x, y, message ) \ ! Refactoring::Testing::checkEquals( x, y, message, CPPUNIT_SOURCELINE() ) ! ! #define RFTA_ASSERT_THROW( expression, ExceptionType ) \ ! try { \ ! expression; \ ! { \ ! CPPUNIT_NS::Message message( "excepted exception of type " \ ! #ExceptionType " not thrown.", \ ! "Expression: " #expression ); \ ! CPPUNIT_NS::Asserter::fail( message, CPPUNIT_SOURCELINE() ); \ ! } \ ! } catch ( ExceptionType & ) { \ ! } #define RFTA_TEST_SUITE_REGISTRATION( FixtureType ) \ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FixtureType, "Refactoring" ) - #define RFTA_ASSERT_TYPE_IS( expectedType, expression ) \ - Refactoring::Testing::checkType( typeid(expectedType), \ - typeid(expression), \ - #expression, \ - CPPUNIT_SOURCELINE() ) #endif // RFTA_UNITTESTING_H --- 2,10 ---- #define RFTA_UNITTESTING_H ! #include <rfta/test/UnitTesting.h> #define RFTA_TEST_SUITE_REGISTRATION( FixtureType ) \ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FixtureType, "Refactoring" ) #endif // RFTA_UNITTESTING_H |