|
From: <bl...@us...> - 2003-05-01 18:53:25
|
Update of /cvsroot/cpptool/rfta/src/rftaparser
In directory sc8-pr-cvs1:/tmp/cvs-serv24787/src/rftaparser
Modified Files:
ParserTesting.h rftaparser.dsp UnitTesting.h
Log Message:
* introduced RFTA_CUSTOM_ASSERT
* moved common UnitTesting.h parts to include/rfta/test/UnitTesting.h
Index: ParserTesting.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/ParserTesting.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ParserTesting.h 26 Apr 2003 10:50:58 -0000 1.4
--- ParserTesting.h 1 May 2003 18:53:20 -0000 1.5
***************
*** 17,20 ****
--- 17,69 ----
};
+ struct NodeTypeAsserter : public Asserter<NodeTypeAsserter>
+ {
+ void operator()( const ASTNodePtr &node,
+ const ASTNodeType &expectedType,
+ const std::string &whichNode = "node" )
+ {
+ failIf( !node, "invalid node: " + whichNode );
+ checkEquals( expectedType.getName(), node->getType().getName(), whichNode + ": bad node type." );
+ }
+ };
+
+
+ struct NodeAsserter : public Asserter<NodeAsserter>
+ {
+ void operator()( const ASTNodePtr &node,
+ const ASTNodeType &type,
+ int index,
+ int length,
+ const std::string &whichNode = "node" )
+ {
+ NodeTypeAsserter().chain( *this )( node, type, whichNode );
+
+ checkEquals( type.getName(), node->getType().getName(),
+ whichNode + ": bad node type." );
+ checkEquals( index, node->getStartIndex(),
+ whichNode + ": bad node start index." );
+ checkEquals( length, node->getLength(),
+ whichNode + ": bad node length." );
+ }
+ };
+
+ struct NodePropertyAsserter : public Asserter<NodePropertyAsserter>
+ {
+ void operator()( const ASTNodePtr &node,
+ const ASTNodeProperty &property,
+ const ASTNodeType &type,
+ int index,
+ int length,
+ const std::string &whichNode )
+ {
+ std::string what = whichNode + ", property=" + property.getName();
+ if ( !node->hasProperty( property ) )
+ fail( what + ": does not exist" );
+
+ NodeAsserter().chain(*this)( node->getProperty( property ), type, index, length, what );
+ }
+ };
+
+
inline void checkASTNodeType( const ASTNodePtr &node,
const ASTNodeType &type,
***************
*** 26,30 ****
whichNode + ": bad node type." );
}
!
inline void checkASTNodeHas( const ASTNodePtr &node,
--- 75,79 ----
whichNode + ": bad node type." );
}
!
inline void checkASTNodeHas( const ASTNodePtr &node,
***************
*** 65,68 ****
--- 114,118 ----
+
template<typename ParserType>
void checkParserFail( const std::string &source,
***************
*** 208,225 ****
}
! #define RFTA_ASSERT_NODE_TYPE( node, type ) \
! Refactoring::Testing::checkASTNodeType( node, type, \
! CPPUNIT_SOURCELINE(), \
! #node )
#define RFTA_ASSERT_NODE_HAS( node, type, index, length ) \
! Refactoring::Testing::checkASTNodeHas( node, type, index, length, \
! CPPUNIT_SOURCELINE(), \
! #node )
#define RFTA_ASSERT_NODE_PROPERTY_HAS( node, property, type, index, length ) \
! Refactoring::Testing::checkASTNodePropertyHas( \
node, property, type, index, length, \
- CPPUNIT_SOURCELINE(), \
#node )
--- 258,270 ----
}
! #define RFTA_ASSERT_NODE_TYPE( node, expectedType ) \
! RFTA_CUSTOM_ASSERT( ::Refactoring::Testing::NodeTypeAsserter )( node, expectedType, #node )
#define RFTA_ASSERT_NODE_HAS( node, type, index, length ) \
! RFTA_CUSTOM_ASSERT( Refactoring::Testing::NodeAsserter )( node, type, index, length, #node )
#define RFTA_ASSERT_NODE_PROPERTY_HAS( node, property, type, index, length ) \
! RFTA_CUSTOM_ASSERT( Refactoring::Testing::NodePropertyAsserter )( \
node, property, type, index, length, \
#node )
Index: rftaparser.dsp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/rftaparser.dsp,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -d -r1.46 -r1.47
*** rftaparser.dsp 29 Apr 2003 22:03:43 -0000 1.46
--- rftaparser.dsp 1 May 2003 18:53:21 -0000 1.47
***************
*** 1438,1444 ****
--- 1438,1460 ----
# End Source File
# End Group
+ # Begin Group "RftaTest"
+
+ # PROP Default_Filter ""
+ # Begin Source File
+
+ SOURCE=..\..\include\rfta\test\UnitTesting.h
+ # End Source File
+ # End Group
# Begin Source File
SOURCE=..\..\include\rfta\parser\Config.h
+ # End Source File
+ # Begin Source File
+
+ SOURCE=.\DeclarationDetailsParserTest.cpp
+ # End Source File
+ # Begin Source File
+
+ SOURCE=.\DeclarationDetailsParserTest.h
# End Source File
# Begin Source File
Index: UnitTesting.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnitTesting.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** UnitTesting.h 27 Oct 2002 16:59:36 -0000 1.3
--- UnitTesting.h 1 May 2003 18:53:21 -0000 1.4
***************
*** 1,60 ****
! #ifndef RFTA_UNITTESTING_H
! #define RFTA_UNITTESTING_H
!
! #include <cppunit/extensions/HelperMacros.h>
! #include <sstream>
!
! 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 );
! }
! }
! }
!
!
! #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 RFTAPARSER_TEST_SUITE_REGISTRATION( FixtureType ) \
--- 1,7 ----
! #ifndef RFTAPARSER_UNITTESTING_H
! #define RFTAPARSER_UNITTESTING_H
! #include <rfta/test/UnitTesting.h>
#define RFTAPARSER_TEST_SUITE_REGISTRATION( FixtureType ) \
***************
*** 63,66 ****
! #endif // RFTA_UNITTESTING_H
--- 10,13 ----
! #endif // RFTAPARSER_UNITTESTING_H
|