CppUnit project page FAQ CppUnit home page

Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

TestSuiteBuilderContext.h

Go to the documentation of this file.
00001 #ifndef CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H 00002 #define CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H 00003 00004 #include <cppunit/Portability.h> 00005 #include <cppunit/portability/CppUnitMap.h> 00006 #include <string> 00007 00008 #if CPPUNIT_NEED_DLL_DECL 00009 #pragma warning( push ) 00010 #pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z 00011 #endif 00012 00013 00014 CPPUNIT_NS_BEGIN 00015 00016 class TestSuite; 00017 class TestFixture; 00018 class TestFixtureFactory; 00019 class TestNamer; 00020 00029 class CPPUNIT_API TestSuiteBuilderContextBase 00030 { 00031 public: 00037 TestSuiteBuilderContextBase( TestSuite &suite, 00038 const TestNamer &namer, 00039 TestFixtureFactory &factory ); 00040 00041 virtual ~TestSuiteBuilderContextBase(); 00042 00047 void addTest( Test *test ); 00048 00053 std::string getFixtureName() const; 00054 00063 std::string getTestNameFor( const std::string &testMethodName ) const; 00064 00069 void addProperty( const std::string &key, 00070 const std::string &value ); 00071 00075 const std::string getStringProperty( const std::string &key ) const; 00076 00077 protected: 00078 TestFixture *makeTestFixture() const; 00079 00080 // Notes: we use a vector here instead of a map to work-around the 00081 // shared std::map in dll bug in VC6. 00082 // See http://www.dinkumware.com/vc_fixes.html for detail. 00083 typedef std::pair<std::string,std::string> Property; 00084 typedef CppUnitVector<Property> Properties; 00085 00086 TestSuite &m_suite; 00087 const TestNamer &m_namer; 00088 TestFixtureFactory &m_factory; 00089 00090 private: 00091 Properties m_properties; 00092 }; 00093 00094 00099 template<class Fixture> 00100 class TestSuiteBuilderContext : public TestSuiteBuilderContextBase 00101 { 00102 public: 00103 typedef Fixture FixtureType; 00104 00105 TestSuiteBuilderContext( TestSuiteBuilderContextBase &contextBase ) 00106 : TestSuiteBuilderContextBase( contextBase ) 00107 { 00108 } 00109 00116 FixtureType *makeFixture() const 00117 { 00118 return CPPUNIT_STATIC_CAST( FixtureType *, 00119 TestSuiteBuilderContextBase::makeTestFixture() ); 00120 } 00121 }; 00122 00123 00124 CPPUNIT_NS_END 00125 00126 #if CPPUNIT_NEED_DLL_DECL 00127 #pragma warning( pop ) 00128 #endif 00129 00130 #endif // CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H 00131

SourceForge Logo hosts this site. Send comments to:
CppUnit Developers