From: Baptiste L. <bl...@us...> - 2004-06-20 10:08:05
|
Update of /cvsroot/cpptool/CppParser/examples/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6749/examples/parser Modified Files: parser.vcproj symboltabletest.cpp symboltabletest.h Log Message: * the list of tests for the symbol table is now read from __tests__.txt Index: parser.vcproj =================================================================== RCS file: /cvsroot/cpptool/CppParser/examples/parser/parser.vcproj,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** parser.vcproj 19 Jun 2004 15:27:02 -0000 1.2 --- parser.vcproj 20 Jun 2004 10:07:56 -0000 1.3 *************** *** 238,241 **** --- 238,244 ---- Filter=""> <File + RelativePath=".\testdata\symbol_table\__tests__.txt"> + </File> + <File RelativePath=".\testdata\symbol_table\class1.txt"> </File> Index: symboltabletest.cpp =================================================================== RCS file: /cvsroot/cpptool/CppParser/examples/parser/symboltabletest.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** symboltabletest.cpp 20 Jun 2004 08:25:24 -0000 1.3 --- symboltabletest.cpp 20 Jun 2004 10:07:56 -0000 1.4 *************** *** 15,21 **** - CPPUT_REGISTER_SUITE_TO_DEFAULT( SymbolTableTest ); - - namespace { --- 15,18 ---- *************** *** 552,562 **** } - - } // anonymous namespace - #define LOCAL_CHECK_DECLARATIONS \ - CPPUT_BEGIN_ASSERTION_MACRO() \ - checkSymbolDeclarations --- 549,554 ---- *************** *** 564,588 **** // /////////////////////////////////////////////////////////////// ! ! void ! SymbolTableTest::setUp() { - symbolTablePath_ = "testdata/symbol_table/"; - tracker_.reset( new LocationTracker() ); - project_.reset( new TestProject() ); } void ! SymbolTableTest::tearDown() { ! tracker_.reset(); ! project_.reset(); } void ! SymbolTableTest::checkSymbolDeclarations( const std::string &path ) { SymbolTableTestProcessor processor( *tracker_, *project_ ); processor.processFile( path ); --- 556,580 ---- // /////////////////////////////////////////////////////////////// ! SymbolTableTestCase::SymbolTableTestCase( const std::string &basePath, ! const std::string &testPath ) ! : CppUT::AbstractTestCase( testPath ) ! , basePath_( basePath ) ! , testPath_( testPath ) { } void ! SymbolTableTestCase::setUp() { ! tracker_.reset( new LocationTracker() ); ! project_.reset( new TestProject() ); } void ! SymbolTableTestCase::doRun() { + std::string path = basePath_ + testPath_; SymbolTableTestProcessor processor( *tracker_, *project_ ); processor.processFile( path ); *************** *** 594,620 **** void ! SymbolTableTest::testTypedefTest1() { ! LOCAL_CHECK_DECLARATIONS( symbolTablePath_ + "typedef1.txt" ); } ! void ! SymbolTableTest::testTypedefTest2() { ! LOCAL_CHECK_DECLARATIONS( symbolTablePath_ + "typedef2.txt" ); } void ! SymbolTableTest::testNamespace1() { ! LOCAL_CHECK_DECLARATIONS( symbolTablePath_ + "namespace1.txt" ); } ! void ! SymbolTableTest::testNamespace2() { ! LOCAL_CHECK_DECLARATIONS( symbolTablePath_ + "namespace2.txt" ); } --- 586,674 ---- void ! SymbolTableTestCase::tearDown() { ! tracker_.reset(); ! project_.reset(); } ! // template class TestListProcessor ! // //////////////////////////////////////////////////////////////////////// ! ! template<class TestCaseType> ! class TestListProcessor : public LineProcessor { ! public: ! TestListProcessor( CppUT::TestSuite &suite, ! const std::string &basePath, ! const std::string &testListFilename ); ! ! public: // overridden from LineProcessor ! void doProcessLine( const std::string &line ); ! ! bool doStateChange( const std::string &name, ! const std::string ¶meter ) ! { ! return false; ! } ! ! void doProcessReadFile( const std::string &path, ! const std::string &content ) ! { ! } ! ! void doTerminateCurrentAction() ! { ! } ! ! private: ! std::string basePath_; ! CppUT::TestSuite &suite_; ! LocationTracker dummyLocationTracker_; ! }; ! ! ! template<class TestCaseType> ! TestListProcessor<TestCaseType>::TestListProcessor( CppUT::TestSuite &suite, ! const std::string &basePath, ! const std::string &testListFilename ) ! : LineProcessor( dummyLocationTracker_ ) ! , basePath_( basePath ) ! , suite_( suite ) ! { ! std::string testListPath = basePath + testListFilename; ! try ! { ! processFile( testListPath ); ! } ! catch ( InputProcessorError &e ) ! { ! suite_.add( CppUT::makeFailingTestCase( "CriticalError", e.what() ) ); ! } } + template<class TestCaseType> void ! TestListProcessor<TestCaseType>::doProcessLine( const std::string &line ) { ! std::string trimedLine = StlHelper::trim( line ); ! if ( trimedLine.empty() ) ! return; ! ! suite_.add( CppUT::TestPtr( new TestCaseType( basePath_, trimedLine ) ) ); } ! // class SymbolTableTestSuite ! // ///////////////////////////////////////////////////////////////////////////// ! ! CPPUT_REGISTER_SUITE_TO_DEFAULT( SymbolTableTestSuite ); ! ! SymbolTableTestSuite::SymbolTableTestSuite() ! : CppUT::TestSuite( "SymbolTableTest" ) { ! TestListProcessor<SymbolTableTestCase> processor( *this, ! "testdata/symbol_table/", ! "__tests__.txt" ); } Index: symboltabletest.h =================================================================== RCS file: /cvsroot/cpptool/CppParser/examples/parser/symboltabletest.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** symboltabletest.h 8 Jun 2004 20:23:18 -0000 1.1.1.1 --- symboltabletest.h 20 Jun 2004 10:07:56 -0000 1.2 *************** *** 7,34 **** ! class SymbolTableTest : public CppUT::TestFixture { public: ! CPPUT_TESTSUITE_BEGIN( SymbolTableTest ); ! CPPUT_TEST( testTypedefTest1 ); ! CPPUT_TEST( testTypedefTest2 ); ! CPPUT_TEST( testNamespace1 ); ! CPPUT_TEST( testNamespace2 ); ! CPPUT_TESTSUITE_END(); ! void setUp(); void tearDown(); ! void testTypedefTest1(); ! void testTypedefTest2(); ! void testNamespace1(); ! void testNamespace2(); private: void checkSymbolDeclarations( const std::string &path ); - std::string symbolTablePath_; CppUT::SmartPtr<LocationTracker> tracker_; CppUT::SmartPtr<TestProject> project_; }; --- 7,41 ---- ! class SymbolTableTestCase : public CppUT::AbstractTestCase { public: ! SymbolTableTestCase( const std::string &basePath, ! const std::string &testPath ); ! void setUp(); void tearDown(); ! private: // overridden from CppUT::AbstractTestCase ! void doRun(); private: void checkSymbolDeclarations( const std::string &path ); CppUT::SmartPtr<LocationTracker> tracker_; CppUT::SmartPtr<TestProject> project_; + std::string basePath_; + std::string testPath_; + }; + + + class SymbolTableTestSuite : public CppUT::TestSuite + { + public: + SymbolTableTestSuite(); + + static CppUT::TestPtr suite( std::string suiteName = std::string("SymbolTableTestSuite") ) + { + return CppUT::TestPtr( new SymbolTableTestSuite() ); + } }; |