Thread: [Cppunit-cvs] cppunit2/src/cpputtest cpputtest.vcproj,1.14,1.15 main.cpp,1.13,1.14 minitestrunner.h,
Brought to you by:
blep
From: Baptiste L. <bl...@us...> - 2005-02-27 16:12:23
|
Update of /cvsroot/cppunit/cppunit2/src/cpputtest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3706/src/cpputtest Modified Files: cpputtest.vcproj main.cpp minitestrunner.h SConscript testfixturetest.cpp testfixturetest.h Log Message: * ported the TestFixture tests back to the new framework architecture. Index: testfixturetest.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/testfixturetest.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** testfixturetest.h 17 Nov 2004 08:59:34 -0000 1.4 --- testfixturetest.h 27 Feb 2005 16:12:08 -0000 1.5 *************** *** 3,11 **** # include <cpput/assert.h> - # include <cpput/testcase.h> - # include <cpput/testsuite.h> - # include <cpput/testcontext.h> # include <cpput/testfixture.h> - # include <cpput/testrunresult.h> --- 3,7 ---- Index: main.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/main.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** main.cpp 27 Feb 2005 15:27:09 -0000 1.13 --- main.cpp 27 Feb 2005 16:12:07 -0000 1.14 *************** *** 7,11 **** #include "registrytest.h" #include "enumeratortest.h" ! //#include "testfixturetest.h" #include <cpput/testrunner.h> // cppunit2 testrunner for opentest --- 7,11 ---- #include "registrytest.h" #include "enumeratortest.h" ! #include "testfixturetest.h" #include <cpput/testrunner.h> // cppunit2 testrunner for opentest *************** *** 46,50 **** CppUT::TestSuitePtr allSuite = CppUT::makeTestSuite( "All tests" ); allSuite->add( RegistryTest::suite() ); ! // allSuite->add( TestFixtureTest::suite() ); allSuite->add( AssertStringTest::suite() ); allSuite->add( EnumeratorTest::suite() ); --- 46,50 ---- CppUT::TestSuitePtr allSuite = CppUT::makeTestSuite( "All tests" ); allSuite->add( RegistryTest::suite() ); ! allSuite->add( TestFixtureTest::suite() ); allSuite->add( AssertStringTest::suite() ); allSuite->add( EnumeratorTest::suite() ); Index: minitestrunner.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/minitestrunner.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** minitestrunner.h 27 Feb 2005 15:47:38 -0000 1.1 --- minitestrunner.h 27 Feb 2005 16:12:07 -0000 1.2 *************** *** 15,38 **** void run( CppUT::TestPtr test ) { ! if ( test->isTestSuite() ) ! run( CppTL::staticPointerCast<CppUT::TestSuite>( test ) ); ! else ! run( CppTL::staticPointerCast<CppUT::AbstractTestCase>( test ) ); } void run( CppUT::AbstractTestCasePtr test ) { ! ++tested_; ! if ( test->runTest() ) ! ++passed_; ! else ! ++failed_; } void run( CppUT::TestSuitePtr suite ) { ! ++suite_; ! for ( int index =0; index < suite->testCount(); ++index ) ! run( suite->testAt( index ) ); } --- 15,32 ---- void run( CppUT::TestPtr test ) { ! // This override prevent errors occuring during testing to ! // count has failure of the test running that testing. ! CppUT::TestInfo::ScopedContextOverride override; ! doRun( test ); } void run( CppUT::AbstractTestCasePtr test ) { ! run( CppTL::staticPointerCast<CppUT::Test>( test ) ); } void run( CppUT::TestSuitePtr suite ) { ! run( CppTL::staticPointerCast<CppUT::Test>( suite ) ); } *************** *** 49,52 **** --- 43,71 ---- int passed_; int failed_; + + private: + void doRun( CppUT::TestPtr test ) + { + if ( test->isTestSuite() ) + doRun( CppTL::staticPointerCast<CppUT::TestSuite>( test ) ); + else + doRun( CppTL::staticPointerCast<CppUT::AbstractTestCase>( test ) ); + } + + void doRun( CppUT::AbstractTestCasePtr test ) + { + ++tested_; + if ( test->runTest() ) + ++passed_; + else + ++failed_; + } + + void doRun( CppUT::TestSuitePtr suite ) + { + ++suite_; + for ( int index =0; index < suite->testCount(); ++index ) + doRun( suite->testAt( index ) ); + } }; Index: cpputtest.vcproj =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/cpputtest.vcproj,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** cpputtest.vcproj 27 Feb 2005 15:47:38 -0000 1.14 --- cpputtest.vcproj 27 Feb 2005 16:12:07 -0000 1.15 *************** *** 221,232 **** RelativePath="testfixturetest.cpp"> <FileConfiguration ! Name="Release|Win32" ! ExcludedFromBuild="TRUE"> <Tool Name="VCCLCompilerTool"/> </FileConfiguration> <FileConfiguration ! Name="Debug|Win32" ! ExcludedFromBuild="TRUE"> <Tool Name="VCCLCompilerTool"/> --- 221,230 ---- RelativePath="testfixturetest.cpp"> <FileConfiguration ! Name="Release|Win32"> <Tool Name="VCCLCompilerTool"/> </FileConfiguration> <FileConfiguration ! Name="Debug|Win32"> <Tool Name="VCCLCompilerTool"/> Index: testfixturetest.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/testfixturetest.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** testfixturetest.cpp 17 Nov 2004 08:59:34 -0000 1.4 --- testfixturetest.cpp 27 Feb 2005 16:12:08 -0000 1.5 *************** *** 1,3 **** --- 1,4 ---- #include "testfixturetest.h" + #include "minitestrunner.h" #include <set> *************** *** 146,150 **** const CppUT::TestSuitePtr &suite ) { ! suite->add( CppUT::makeTestCase( CppUT::makeMemFn0( fixture, testMethod ), testName ) ); } --- 147,151 ---- const CppUT::TestSuitePtr &suite ) { ! suite->add( CppUT::makeTestCase( CppTL::memfn0( fixture, testMethod ), testName ) ); } *************** *** 155,163 **** { CppUT::TestPtr suite = EmptyFixture::suite(); ! CppUT::TestContext context; ! CppUT::TestRunResult result; ! context.add( result ); ! suite->run( context ); ! CPPUT_ASSERT_EQUAL( 0, result.testCount() ); } --- 156,162 ---- { CppUT::TestPtr suite = EmptyFixture::suite(); ! MiniTestRunner runner; ! runner.run( suite ); ! CPPUT_ASSERT_EQUAL( 0, runner.tested_ ); } *************** *** 167,176 **** { CppUT::TestPtr suite = TwoTestFixture::suite(); ! CppUT::TestContext context; ! CppUT::TestRunResult result; ! context.add( result ); ! suite->run( context ); ! CPPUT_ASSERT_EQUAL( 2, result.testCount() ); ! CPPUT_ASSERT_EQUAL( 1, result.failureCount() ); } --- 166,173 ---- { CppUT::TestPtr suite = TwoTestFixture::suite(); ! MiniTestRunner runner; ! runner.run( suite ); ! CPPUT_ASSERT_EQUAL( 2, runner.tested_ ); ! CPPUT_ASSERT_EQUAL( 1, runner.failed_ ); } *************** *** 180,189 **** { CppUT::TestPtr suite = ExtendTestFixture::suite(); ! CppUT::TestContext context; ! CppUT::TestRunResult result; ! context.add( result ); ! suite->run( context ); ! CPPUT_ASSERT_EQUAL( 3, result.testCount() ); ! CPPUT_ASSERT_EQUAL( 2, result.failureCount() ); } --- 177,184 ---- { CppUT::TestPtr suite = ExtendTestFixture::suite(); ! MiniTestRunner runner; ! runner.run( suite ); ! CPPUT_ASSERT_EQUAL( 3, runner.tested_ ); ! CPPUT_ASSERT_EQUAL( 2, runner.failed_ ); } *************** *** 193,202 **** { CppUT::TestPtr suite = ConcretTestFixture::suite(); ! CppUT::TestContext context; ! CppUT::TestRunResult result; ! context.add( result ); ! suite->run( context ); ! CPPUT_ASSERT_EQUAL( 3, result.testCount() ); ! CPPUT_ASSERT_EQUAL( 3, result.failureCount() ); } --- 188,195 ---- { CppUT::TestPtr suite = ConcretTestFixture::suite(); ! MiniTestRunner runner; ! runner.run( suite ); ! CPPUT_ASSERT_EQUAL( 3, runner.tested_ ); ! CPPUT_ASSERT_EQUAL( 3, runner.failed_ ); } *************** *** 206,216 **** { CppUT::TestPtr suite = NoSharedFixtureTest::suite(); ! CppUT::TestContext context; ! CppUT::TestRunResult result; ! context.add( result ); SharedFixtureTestBase::instances_.clear(); ! suite->run( context ); ! CPPUT_ASSERT_EQUAL( 3, result.testCount() ); ! CPPUT_ASSERT_EQUAL( 0, result.failureCount() ); CPPUT_ASSERT_EQUAL( 3, int(SharedFixtureTestBase::instances_.size() ) ); } --- 199,207 ---- { CppUT::TestPtr suite = NoSharedFixtureTest::suite(); ! MiniTestRunner runner; SharedFixtureTestBase::instances_.clear(); ! runner.run( suite ); ! CPPUT_ASSERT_EQUAL( 3, runner.tested_ ); ! CPPUT_ASSERT_EQUAL( 0, runner.failed_ ); CPPUT_ASSERT_EQUAL( 3, int(SharedFixtureTestBase::instances_.size() ) ); } *************** *** 221,231 **** { CppUT::TestPtr suite = SharedFixtureTest::suite(); ! CppUT::TestContext context; ! CppUT::TestRunResult result; ! context.add( result ); SharedFixtureTestBase::instances_.clear(); ! suite->run( context ); ! CPPUT_ASSERT_EQUAL( 3, result.testCount() ); ! CPPUT_ASSERT_EQUAL( 0, result.failureCount() ); CPPUT_ASSERT_EQUAL( 1, int(SharedFixtureTestBase::instances_.size() ) ); } --- 212,220 ---- { CppUT::TestPtr suite = SharedFixtureTest::suite(); ! MiniTestRunner runner; SharedFixtureTestBase::instances_.clear(); ! runner.run( suite ); ! CPPUT_ASSERT_EQUAL( 3, runner.tested_ ); ! CPPUT_ASSERT_EQUAL( 0, runner.failed_ ); CPPUT_ASSERT_EQUAL( 1, int(SharedFixtureTestBase::instances_.size() ) ); } Index: SConscript =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/SConscript,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SConscript 27 Feb 2005 15:27:09 -0000 1.5 --- SConscript 27 Feb 2005 16:12:08 -0000 1.6 *************** *** 12,16 **** testbasicassertion.cpp testfunctor.cpp ! testfunctor3.cpp testtestcase.cpp testtestsuite.cpp --- 12,16 ---- testbasicassertion.cpp testfunctor.cpp ! testfixturetest.cpp testtestcase.cpp testtestsuite.cpp |