From: <bl...@us...> - 2003-03-08 13:10:47
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv17238 Added Files: CodeModelGeneratorTest.cpp CodeModelGeneratorTest.h Log Message: * added test for declarator expression generation --- NEW FILE: CodeModelGeneratorTest.cpp --- // ////////////////////////////////////////////////////////////////////////// // (c)Copyright 2002, Baptiste Lepilleur. // Created: 2003/03/07 // ////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "CodeModelGeneratorTest.h" #include <rfta/refactoring/CodeModel.h> #include <rfta/refactoring/CodeModelStatements.h> #include <rfta/refactoring/CodeModelExpressions.h> namespace Refactoring { RFTA_TEST_SUITE_REGISTRATION( CodeModelGeneratorTest ); CodeModelGeneratorTest::CodeModelGeneratorTest() { } CodeModelGeneratorTest::~CodeModelGeneratorTest() { } void CodeModelGeneratorTest::setUp() { } void CodeModelGeneratorTest::tearDown() { } void CodeModelGeneratorTest::testGenerateDeclaratorExpression() { source_ = "int x = 3;"; parse(); RFTA_ASSERT_EQUAL( 1, sourceNode_->getChildCount() ); CodeModel::Generator generator; CodeModel::DeclaratorExpressionPtr &declExpression = generator.generateDeclarator( sourceNode_->getChildAt(0) ); RFTA_ASSERT_EQUAL( "int ", declExpression->getPrimaryType() ); RFTA_ASSERT_EQUAL( 1, declExpression->getDeclaratorCount() ); const CodeModel::Declarator &declarator = declExpression->getDeclaratorAt(0); RFTA_ASSERT_EQUAL( "", declarator.getType() ); RFTA_ASSERT_EQUAL( "", declarator.getTypeSuffix() ); RFTA_ASSERT_EQUAL( "x", declarator.getName() ); CPPUNIT_ASSERT( declarator.hasInitializer() ); CodeModel::AssignInitializerExpression &initializer = dynamic_cast<CodeModel::AssignInitializerExpression &>( *declarator.getInitializer() ); RFTA_ASSERT_EQUAL( " 3", initializer.getValue()->getText().getOriginalText() ); } } // namespace Refactoring --- NEW FILE: CodeModelGeneratorTest.h --- // ////////////////////////////////////////////////////////////////////////// // (c)Copyright 2002, Baptiste Lepilleur. // Created: 2003/03/07 // ////////////////////////////////////////////////////////////////////////// #ifndef RFTA_CODEMODELGENERATORTEST_H #define RFTA_CODEMODELGENERATORTEST_H #include "SourceBasedTestBase.h" namespace Refactoring { /// Unit tests for CodeModelGeneratorTest class CodeModelGeneratorTest : public SourceBasedTestBase { CPPUNIT_TEST_SUITE( CodeModelGeneratorTest ); CPPUNIT_TEST( testGenerateDeclaratorExpression ); CPPUNIT_TEST_SUITE_END(); public: /*! Constructs a CodeModelGeneratorTest object. */ CodeModelGeneratorTest(); /// Destructor. virtual ~CodeModelGeneratorTest(); void setUp(); void tearDown(); void testGenerateDeclaratorExpression(); private: }; // Inlines methods for CodeModelGeneratorTest: // ------------------------------------------- } // namespace Refactoring #endif // RFTA_CODEMODELGENERATORTEST_H |