From: <net...@us...> - 2003-09-24 20:30:16
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv15370/rftaparser Modified Files: UnparsedDeclarationMutatorTest.h UnparsedDeclarationMutatorTest.cpp Log Message: -- corrected some tests -- added enum-test Index: UnparsedDeclarationMutatorTest.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclarationMutatorTest.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** UnparsedDeclarationMutatorTest.h 6 Sep 2003 21:35:59 -0000 1.10 --- UnparsedDeclarationMutatorTest.h 24 Sep 2003 20:29:59 -0000 1.11 *************** *** 27,30 **** --- 27,31 ---- CPPUNIT_TEST( testEnumDeclaration ); CPPUNIT_TEST( testUnamedEnumDeclaration ); + CPPUNIT_TEST( testEnumTypeUse ); CPPUNIT_TEST( testPointerDecl ); CPPUNIT_TEST( testFctPointer ); *************** *** 75,78 **** --- 76,80 ---- void testEnumDeclaration(); void testUnamedEnumDeclaration(); + void testEnumTypeUse(); void testPointerDecl(); void testFctPointer(); Index: UnparsedDeclarationMutatorTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/UnparsedDeclarationMutatorTest.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** UnparsedDeclarationMutatorTest.cpp 6 Sep 2003 21:35:59 -0000 1.15 --- UnparsedDeclarationMutatorTest.cpp 24 Sep 2003 20:29:59 -0000 1.16 *************** *** 231,235 **** // CHECK CLASS NAME PROPERTY: RFTA_ASSERT_NODE_PROPERTY_HAS( specifier, ! ASTNodeProperties::classNameProperty, ASTNodeTypes::localScopeIdentifier, source.getKeyedIndex("CLASS-NAME",0), --- 231,235 ---- // CHECK CLASS NAME PROPERTY: RFTA_ASSERT_NODE_PROPERTY_HAS( specifier, ! ASTNodeProperties::compositeNameProperty, ASTNodeTypes::localScopeIdentifier, source.getKeyedIndex("CLASS-NAME",0), *************** *** 273,277 **** // CHECK CLASS NAME PROPERTY: RFTA_ASSERT_NODE_PROPERTY_HAS( specifier, ! ASTNodeProperties::classNameProperty, ASTNodeTypes::localScopeIdentifier, source.getKeyedIndex("CLASS-NAME",0), --- 273,277 ---- // CHECK CLASS NAME PROPERTY: RFTA_ASSERT_NODE_PROPERTY_HAS( specifier, ! ASTNodeProperties::compositeNameProperty, ASTNodeTypes::localScopeIdentifier, source.getKeyedIndex("CLASS-NAME",0), *************** *** 315,319 **** { Testing::KeyedString source; ! source.addKeyed(SPECIFIER , "class RFTA_API SourceRange;" ); SourceASTNodePtr sourceNode = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source ); --- 315,319 ---- { Testing::KeyedString source; ! source.addKeyed(SPECIFIER , "class RFTA_API SourceRange" ) << ";"; SourceASTNodePtr sourceNode = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source ); *************** *** 333,337 **** { Testing::KeyedString source; ! source.addKeyed(SPECIFIER , "enum x { a = 0, b, c }" ) << ";"; SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source ); --- 333,339 ---- { Testing::KeyedString source; ! source.setKeyStart(SPECIFIER) << "enum "; ! source.addKeyed("ENUM-NAME" , "x") << " { a = 0, b, c }"; ! source.setKeyEnd(SPECIFIER) << ";"; SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source ); *************** *** 343,347 **** // check specifier types: ASTNodePtr specifierList = node->getProperty( ASTNodeProperties::declarationSpecifiersProperty ); ! RFTA_ASSERT_NODE_TYPE( specifierList->getChildAt(0), ASTNodeTypes::enumSpecifier, "enum-specifier" ); } --- 345,357 ---- // check specifier types: ASTNodePtr specifierList = node->getProperty( ASTNodeProperties::declarationSpecifiersProperty ); ! ASTNodePtr specifier = specifierList->getChildAt(0); ! RFTA_ASSERT_NODE_TYPE( specifier, ASTNodeTypes::enumSpecifier, "enum-specifier" ); ! ! RFTA_ASSERT_NODE_PROPERTY_HAS( specifier, ! ASTNodeProperties::compositeNameProperty, ! ASTNodeTypes::localScopeIdentifier, ! source.getKeyedIndex("ENUM-NAME",0), ! source.getKeyedLen("ENUM-NAME",0) ! ); } *************** *** 365,368 **** --- 375,416 ---- source.getKeyedIndex(SPECIFIER,0), source.getKeyedLen(SPECIFIER,0) ); + } + + void + UnparsedDeclarationMutatorTest::testEnumTypeUse() + { + Testing::KeyedString source; + source.setKeyStart(SPECIFIERLIST); + source.setKeyStart(SPECIFIER) << "enum "; + source.addKeyed("ENUM-NAME", "X"); + source.setKeyEnd(SPECIFIER); + source.setKeyEnd(SPECIFIERLIST) << " "; + source.addKeyed("DECLARATOR","Y=0" ) << ";"; + + + SourceASTNodePtr sourceAST = RFTA_ASSERT_DECLARATION_MUTATOR_PASS( source ); + ASTNodePtr node = sourceAST->getChildAt(0); + + // check AST: + RFTA_ASSERT_DECLARATION( source, sourceAST ); + + // check specifier types: + ASTNodePtr specifierList = node->getProperty( ASTNodeProperties::declarationSpecifiersProperty ); + ASTNodePtr enumSpecifier = specifierList->getChildAt(0); + RFTA_ASSERT_NODE_HAS( enumSpecifier, ASTNodeTypes::elaboratedTypeSpecifier, + source.getKeyedIndex(SPECIFIER,0), + source.getKeyedLen(SPECIFIER,0) ); + + RFTA_ASSERT_NODE_PROPERTY_HAS( enumSpecifier, + ASTNodeProperties::compositeNameProperty, + ASTNodeTypes::localScopeIdentifier, + source.getKeyedIndex("ENUM-NAME",0), + source.getKeyedLen("ENUM-NAME",0) + ); + // check declarator: + RFTA_ASSERT_NODE_HAS( node->getChildAt(0), ASTNodeTypes::unparsedDeclarator, + source.getKeyedIndex("DECLARATOR",0), + source.getKeyedLen("DECLARATOR",0) + ); } |