Thread: [Cppunit-cvs] cppunit2/include/cpput forwards.h,1.9,1.10 test.h,1.2,1.3 testcase.h,1.4,1.5 testconte
Brought to you by:
blep
From: Baptiste L. <bl...@us...> - 2004-11-17 21:47:21
|
Update of /cvsroot/cppunit/cppunit2/include/cpput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv508/include/cpput Modified Files: forwards.h test.h testcase.h testcontext.h testlistener.h testsuite.h Log Message: * started removing TestDriver stuff from CppUnit 2 * Removed Test::run(), Test::totalTestCount and Test::parent * User can only subclass AbstractTestSuite or AbstractTestCase. * AbstractTest has been inlined into Test * Test no longer have parent * Removed TestListener::enterTest() & TestListener::exitTest() * Moved responsibility of running TestCase from AbstractTestCase to TestContext::run( AbstractTestCase &test ). * Removed method related to suite and enter/exit event from TestContext. * Disabled some unit tests (rely on running test which will change again shortly) Index: testcase.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/testcase.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** testcase.h 17 Nov 2004 08:59:05 -0000 1.4 --- testcase.h 17 Nov 2004 21:47:09 -0000 1.5 *************** *** 13,34 **** ! class CPPUT_API AbstractTestCase : public AbstractTest { public: AbstractTestCase( const std::string &name ); ! // overridden from AbstractTest ! void run( TestContext &context ); ! void accept( TestVisitor &visitor ); ! int totalTestCount() const; ! ! private: ! void runTest( TestContext *context ); virtual void setUp(); ! virtual void doRun() = 0; virtual void tearDown(); --- 13,31 ---- ! class CPPUT_API AbstractTestCase : public Test { public: AbstractTestCase( const std::string &name ); ! public: // overridden from Test void accept( TestVisitor &visitor ); ! /// Returns \c true if the class is derived from AbstractTestCase. ! bool isTestCase() const; + public: virtual void setUp(); ! virtual void run() = 0; virtual void tearDown(); *************** *** 47,54 **** const std::string &name ); ! private: // overridden from AbstractTestCase void setUp(); ! void doRun(); void tearDown(); --- 44,51 ---- const std::string &name ); ! public: // overridden from AbstractTestCase void setUp(); ! void run(); void tearDown(); Index: testsuite.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/testsuite.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** testsuite.h 27 Jan 2004 23:37:21 -0000 1.2 --- testsuite.h 17 Nov 2004 21:47:09 -0000 1.3 *************** *** 8,12 **** namespace CppUT { ! class CPPUT_API AbstractTestSuite : public AbstractTest { public: --- 8,12 ---- namespace CppUT { ! class CPPUT_API AbstractTestSuite : public Test { public: *************** *** 19,31 **** virtual TestPtr testAt( int index ) const = 0; ! // overridden from AbstractTest void accept( TestVisitor &visitor ); ! void run( TestContext &context ); ! ! int totalTestCount() const; ! ! private: ! virtual void runTests( TestContext *context ) = 0; }; --- 19,27 ---- virtual TestPtr testAt( int index ) const = 0; ! public: // overridden from Test void accept( TestVisitor &visitor ); ! /// Returns \c true if the class is derived from AbstractTestCase. ! bool isTestCase() const; }; *************** *** 49,55 **** private: ! void runTests( TestContext *context ); ! ! typedef std::deque<TestPtr> Tests; Tests tests_; }; --- 45,49 ---- private: ! typedef std::deque<TestPtr> Tests; Tests tests_; }; Index: testcontext.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/testcontext.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** testcontext.h 4 Aug 2004 19:41:19 -0000 1.7 --- testcontext.h 17 Nov 2004 21:47:09 -0000 1.8 *************** *** 14,22 **** TestContext(); ! void protectTestRun( Test &test, ! Functor1<TestContext *> runTest ); ! ! bool protect( Test &test, ! const Functor0 &functor ); void add( TestListener &listener ); --- 14,18 ---- TestContext(); ! void run( AbstractTestCase &test ); void add( TestListener &listener ); *************** *** 29,37 **** private: ! void dispatchTestEvent( Test &test, ! void (TestListener::*eventMethod)( Test &, TestContext &) ); ! ! void dispatchSuiteEvent( AbstractTestSuite &suite, ! void (TestListener::*eventMethod)( AbstractTestSuite &, TestContext &) ) ; void dispatchTestResult( TestResult &result ); --- 25,30 ---- private: ! bool protect( Test &test, ! const Functor0 &functor ); void dispatchTestResult( TestResult &result ); Index: testlistener.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/testlistener.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** testlistener.h 4 Aug 2004 06:43:53 -0000 1.4 --- testlistener.h 17 Nov 2004 21:47:09 -0000 1.5 *************** *** 15,21 **** } ! virtual void enterTest( Test &test, TestContext &context ) ! { ! } virtual void processTestResult( TestResult &result, --- 15,21 ---- } ! //virtual void enterTest( Test &test, TestContext &context ) ! //{ ! //} virtual void processTestResult( TestResult &result, *************** *** 24,30 **** } ! virtual void exitTest( Test &test, TestContext &context ) ! { ! } }; --- 24,30 ---- } ! //virtual void exitTest( Test &test, TestContext &context ) ! //{ ! //} }; Index: test.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/test.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test.h 4 Aug 2004 21:17:17 -0000 1.2 --- test.h 17 Nov 2004 21:47:09 -0000 1.3 *************** *** 2,6 **** # define CPPUT_TEST_H_INCLUDED - # include <cpput/config.h> # include <cpput/forwards.h> # include <string> --- 2,5 ---- *************** *** 13,75 **** class CPPUT_API Test { public: ! virtual std::string name() const = 0; ! ! virtual void run( TestContext &context ) = 0; ! ! virtual void accept( TestVisitor &visitor ) = 0; ! ! virtual void setParentTest( Test &parentTest ) = 0; ! ! virtual Test *parentTest() const = 0; ! ! virtual int totalTestCount() const =0; ! }; ! ! class CPPUT_API AbstractTest : public Test ! { ! public: ! AbstractTest() ! : parentTest_( 0 ) { } ! AbstractTest( const std::string &name ) ! : name_( name ) ! , parentTest_( 0 ) { } ! // overridden from Test ! std::string name() const { ! return name_; } ! void setParentTest( Test &parentTest ) { - parentTest_ = &parentTest; } ! Test *parentTest() const { - return parentTest_; } private: std::string name_; - Test *parentTest_; }; - inline std::string CPPUT_API path( Test &test ) - { - if ( test.parentTest() ) - return path( *test.parentTest() ) + "/" + test.name(); - return test.name(); - } - - } // namespace CppUT --- 12,62 ---- class CPPUT_API Test { + // ensure that this class can only be derived by AbstractTestCase and + // AbstractTestSuite. + friend class AbstractTestCase; + friend class AbstractTestSuite; public: ! virtual ~Test() ! { ! } ! std::string name() const { + return name_; } ! /// @warning You must never change the name of the test after ! /// registering the test or scheduling it for running. ! void setName( const std::string &name ) { + name_ = name; } ! /// Returns \c true if the class is derived from AbstractTestSuite. ! bool isTestSuite() const { ! return !isTestCase(); } ! virtual void accept( TestVisitor &visitor ) = 0; ! ! /// Returns \c true if the class is derived from AbstractTestCase. ! virtual bool isTestCase() const = 0; ! ! private: ! Test() { } ! Test( const std::string &name ) ! : name_( name ) { } private: std::string name_; }; } // namespace CppUT Index: forwards.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/forwards.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** forwards.h 17 Nov 2004 08:59:05 -0000 1.9 --- forwards.h 17 Nov 2004 21:47:09 -0000 1.10 *************** *** 8,11 **** --- 8,12 ---- namespace CppUT { + class AbstractTestCase; class AbstractTestSuite; class AssertException; |