CppUnit project page | FAQ |
00001 #ifndef CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H 00002 #define CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H 00003 00004 #include <cppunit/Portability.h> 00005 #include <map> 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 00074 template<typename T> 00075 std::string getTestNameFor( const std::string &testMethodName, const T& value ) const 00076 { 00077 return m_namer.getTestNameFor(testMethodName, value); 00078 } 00079 00084 void addProperty( const std::string &key, 00085 const std::string &value ); 00086 00090 const std::string getStringProperty( const std::string &key ) const; 00091 00092 protected: 00093 TestFixture *makeTestFixture() const; 00094 00095 // Notes: we use a vector here instead of a map to work-around the 00096 // shared std::map in dll bug in VC6. 00097 // See http://www.dinkumware.com/vc_fixes.html for detail. 00098 typedef std::pair<std::string,std::string> Property; 00099 typedef std::vector<Property> Properties; 00100 00101 TestSuite &m_suite; 00102 const TestNamer &m_namer; 00103 TestFixtureFactory &m_factory; 00104 00105 private: 00106 Properties m_properties; 00107 }; 00108 00109 00114 template<class Fixture> 00115 class TestSuiteBuilderContext : public TestSuiteBuilderContextBase 00116 { 00117 public: 00118 typedef Fixture FixtureType; 00119 00120 TestSuiteBuilderContext( TestSuiteBuilderContextBase &contextBase ) 00121 : TestSuiteBuilderContextBase( contextBase ) 00122 { 00123 } 00124 00131 FixtureType *makeFixture() const 00132 { 00133 return CPPUNIT_STATIC_CAST( FixtureType *, 00134 TestSuiteBuilderContextBase::makeTestFixture() ); 00135 } 00136 }; 00137 00138 00139 CPPUNIT_NS_END 00140 00141 #if CPPUNIT_NEED_DLL_DECL 00142 #pragma warning( pop ) 00143 #endif 00144 00145 #endif // CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H 00146
Send comments to: CppUnit Developers |