diff options
Diffstat (limited to 'include/cppunit')
31 files changed, 196 insertions, 160 deletions
diff --git a/include/cppunit/Asserter.h b/include/cppunit/Asserter.h index da6cab8..55987dd 100644 --- a/include/cppunit/Asserter.h +++ b/include/cppunit/Asserter.h @@ -11,23 +11,23 @@ namespace CppUnit namespace Asserter { - void fail( std::string message, - SourceLine sourceLine = SourceLine() ); - - void failIf( bool shouldFail, - std::string message, - SourceLine sourceLine = SourceLine() ); - - void failNotEqual( std::string expected, - std::string actual, - SourceLine sourceLine = SourceLine(), - std::string additionalMessage ="" ); - - void failNotEqualIf( bool shouldFail, - std::string expected, - std::string actual, - SourceLine sourceLine = SourceLine(), - std::string additionalMessage ="" ); + void CPPUNIT_API fail( std::string message, + SourceLine sourceLine = SourceLine() ); + + void CPPUNIT_API failIf( bool shouldFail, + std::string message, + SourceLine sourceLine = SourceLine() ); + + void CPPUNIT_API failNotEqual( std::string expected, + std::string actual, + SourceLine sourceLine = SourceLine(), + std::string additionalMessage ="" ); + + void CPPUNIT_API failNotEqualIf( bool shouldFail, + std::string expected, + std::string actual, + SourceLine sourceLine = SourceLine(), + std::string additionalMessage ="" ); } // namespace Asserter } // namespace CppUnit diff --git a/include/cppunit/CompilerOutputter.h b/include/cppunit/CompilerOutputter.h index eb15875..3827017 100644 --- a/include/cppunit/CompilerOutputter.h +++ b/include/cppunit/CompilerOutputter.h @@ -18,7 +18,7 @@ class TestResultCollector; /*! \class CompilerOutputter * \brief This class implements output test result in a compiler compatible format. */ -class CompilerOutputter : public Outputter +class CPPUNIT_API CompilerOutputter : public Outputter { public: /*! Constructs a CompilerOutputter object. diff --git a/include/cppunit/Exception.h b/include/cppunit/Exception.h index f94eca5..2b4edb5 100644 --- a/include/cppunit/Exception.h +++ b/include/cppunit/Exception.h @@ -13,7 +13,7 @@ namespace CppUnit { * Exception is an exception that serves * descriptive strings through its what() method */ -class Exception : public std::exception +class CPPUNIT_API Exception : public std::exception { public: diff --git a/include/cppunit/NotEqualException.h b/include/cppunit/NotEqualException.h index ba48dbb..3831247 100644 --- a/include/cppunit/NotEqualException.h +++ b/include/cppunit/NotEqualException.h @@ -7,7 +7,7 @@ namespace CppUnit { -class NotEqualException : public Exception +class CPPUNIT_API NotEqualException : public Exception { public: NotEqualException( std::string expected, diff --git a/include/cppunit/Outputter.h b/include/cppunit/Outputter.h index 1ff00c1..62ee1d0 100644 --- a/include/cppunit/Outputter.h +++ b/include/cppunit/Outputter.h @@ -9,7 +9,7 @@ namespace CppUnit /*! This class represents an abstract outputter. */ -class Outputter +class CPPUNIT_API Outputter { public: /// Destructor. diff --git a/include/cppunit/Portability.h b/include/cppunit/Portability.h index 881980c..3bb34a9 100644 --- a/include/cppunit/Portability.h +++ b/include/cppunit/Portability.h @@ -34,6 +34,12 @@ #define CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION 1 #endif +// CPPUNIT_API is defined in <config_msvc6.h> if required (building or using as dll) +#ifndef CPPUNIT_API +#define CPPUNIT_API +#undef CPPUNIT_NEED_DLL_DECL +#define CPPUNIT_NEED_DLL_DECL 0 +#endif /* perform portability hacks */ diff --git a/include/cppunit/SourceLine.h b/include/cppunit/SourceLine.h index d80f74b..c1b0b7a 100644 --- a/include/cppunit/SourceLine.h +++ b/include/cppunit/SourceLine.h @@ -17,7 +17,7 @@ namespace CppUnit /*! \class SourceLine * \brief This class represents the location of a line of text in a specified file. */ -class SourceLine +class CPPUNIT_API SourceLine { public: SourceLine(); diff --git a/include/cppunit/SynchronizedObject.h b/include/cppunit/SynchronizedObject.h index 3e8496d..f9e498c 100644 --- a/include/cppunit/SynchronizedObject.h +++ b/include/cppunit/SynchronizedObject.h @@ -19,7 +19,7 @@ namespace CppUnit * * See src/msvc6/MfcSynchronizedObject.h for an example. */ -class SynchronizedObject +class CPPUNIT_API SynchronizedObject { public: class SynchronizationObject diff --git a/include/cppunit/Test.h b/include/cppunit/Test.h index ca494ae..98f1764 100644 --- a/include/cppunit/Test.h +++ b/include/cppunit/Test.h @@ -1,6 +1,7 @@ #ifndef CPPUNIT_TEST_H #define CPPUNIT_TEST_H +#include <cppunit/Portability.h> #include <string> namespace CppUnit { @@ -18,7 +19,7 @@ class TestResult; * \see TestCase * \see TestSuite */ -class Test +class CPPUNIT_API Test { public: virtual ~Test () {}; diff --git a/include/cppunit/TestAssert.h b/include/cppunit/TestAssert.h index 4c1478b..46071ee 100644 --- a/include/cppunit/TestAssert.h +++ b/include/cppunit/TestAssert.h @@ -28,15 +28,15 @@ namespace CppUnit { namespace TestAssert { #ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED - void assertImplementation( bool condition, - std::string conditionExpression = "", - long lineNumber, - std::string fileName ); - - void assertNotEqualImplementation( std::string expected, - std::string actual, - long lineNumber, - std::string fileName ); + void CPPUNIT_API assertImplementation( bool condition, + std::string conditionExpression = "", + long lineNumber, + std::string fileName ); + + void CPPUNIT_API assertNotEqualImplementation( std::string expected, + std::string actual, + long lineNumber, + std::string fileName ); template <class T> @@ -54,11 +54,11 @@ namespace CppUnit { } } - void assertEquals( double expected, - double actual, - double delta, - long lineNumber, - std::string fileName ); + void CPPUNIT_API assertEquals( double expected, + double actual, + double delta, + long lineNumber, + std::string fileName ); #else // using SourceLine @@ -77,10 +77,10 @@ namespace CppUnit { } } - void assertDoubleEquals( double expected, - double actual, - double delta, - SourceLine sourceLine ); + void CPPUNIT_API assertDoubleEquals( double expected, + double actual, + double delta, + SourceLine sourceLine ); #endif } diff --git a/include/cppunit/TestCaller.h b/include/cppunit/TestCaller.h index 03ecab2..d967ab3 100644 --- a/include/cppunit/TestCaller.h +++ b/include/cppunit/TestCaller.h @@ -12,7 +12,7 @@ namespace CppUnit { -class NoExceptionExpected +class CPPUNIT_API NoExceptionExpected { private: // Nobody must be able to construct an exception of this type. diff --git a/include/cppunit/TestCase.h b/include/cppunit/TestCase.h index c40198c..b1a5652 100644 --- a/include/cppunit/TestCase.h +++ b/include/cppunit/TestCase.h @@ -89,7 +89,7 @@ class TestResult; * */ -class TestCase : public Test +class CPPUNIT_API TestCase : public Test { public: diff --git a/include/cppunit/TestFailure.h b/include/cppunit/TestFailure.h index 61f4018..b1e1d8f 100644 --- a/include/cppunit/TestFailure.h +++ b/include/cppunit/TestFailure.h @@ -19,7 +19,7 @@ class Test; * TestFailure assumes lifetime control for any exception * passed to it. */ -class TestFailure +class CPPUNIT_API TestFailure { public: TestFailure( Test *failedTest, diff --git a/include/cppunit/TestListener.h b/include/cppunit/TestListener.h index d9d482a..17a550e 100644 --- a/include/cppunit/TestListener.h +++ b/include/cppunit/TestListener.h @@ -16,7 +16,7 @@ class TestFailure; * * \see TestResult */ -class TestListener +class CPPUNIT_API TestListener { public: virtual ~TestListener() {} diff --git a/include/cppunit/TestResult.h b/include/cppunit/TestResult.h index 9c2930a..162095d 100644 --- a/include/cppunit/TestResult.h +++ b/include/cppunit/TestResult.h @@ -11,6 +11,9 @@ class Test; class TestFailure; class TestListener; +#if CPPUNIT_NEED_DLL_DECL + template class CPPUNIT_API std::deque<TestListener *>; +#endif /** * A TestResult collects the results of executing a test case. It is an @@ -33,8 +36,7 @@ class TestListener; * * \see Test, TestResultCollector */ - -class TestResult : protected SynchronizedObject +class CPPUNIT_API TestResult : protected SynchronizedObject { public: TestResult( SynchronizationObject *syncObject = 0 ); diff --git a/include/cppunit/TestResultCollector.h b/include/cppunit/TestResultCollector.h index bd2f0b1..b20385f 100644 --- a/include/cppunit/TestResultCollector.h +++ b/include/cppunit/TestResultCollector.h @@ -9,6 +9,12 @@ namespace CppUnit { +#if CPPUNIT_NEED_DLL_DECL + template class CPPUNIT_API std::deque<TestFailure *>; + template class CPPUNIT_API std::deque<Test *>; +#endif + + /*! * A TestResultCollector is a TestListener which collects the results of executing * a test case. It is an instance of the Collecting Parameter pattern. @@ -18,7 +24,7 @@ namespace CppUnit * unanticipated problems signified by exceptions that are not generated * by the framework. */ -class TestResultCollector : public TestSucessListener +class CPPUNIT_API TestResultCollector : public TestSucessListener { public: typedef std::deque<TestFailure *> TestFailures; diff --git a/include/cppunit/TestSucessListener.h b/include/cppunit/TestSucessListener.h index 20e1d6b..bdaa60d 100644 --- a/include/cppunit/TestSucessListener.h +++ b/include/cppunit/TestSucessListener.h @@ -10,8 +10,8 @@ namespace CppUnit /*! A TestSucessListener is a TestListener which check if any test case failed. */ -class TestSucessListener : public TestListener, - public SynchronizedObject +class CPPUNIT_API TestSucessListener : public TestListener, + public SynchronizedObject { public: /*! Constructs a TestSucessListener object. diff --git a/include/cppunit/TestSuite.h b/include/cppunit/TestSuite.h index 11be9ee..369f89d 100644 --- a/include/cppunit/TestSuite.h +++ b/include/cppunit/TestSuite.h @@ -10,6 +10,11 @@ namespace CppUnit { class TestResult; +#if CPPUNIT_NEED_DLL_DECL + template class CPPUNIT_API std::vector<Test *>; +#endif + + /*! \brief A Composite of Tests. * * It runs a collection of test cases. Here is an example. @@ -29,29 +34,29 @@ class TestResult; */ -class TestSuite : public Test +class CPPUNIT_API TestSuite : public Test { public: - TestSuite (std::string name = ""); - ~TestSuite (); + TestSuite( std::string name = "" ); + ~TestSuite(); - void run (TestResult *result); - int countTestCases () const; - std::string getName () const; - std::string toString () const; + void run( TestResult *result ); + int countTestCases() const; + std::string getName() const; + std::string toString() const; - void addTest (Test *test); - const std::vector<Test *> & getTests() const; + void addTest( Test *test ); + const std::vector<Test *> &getTests() const; - virtual void deleteContents (); + virtual void deleteContents(); private: - TestSuite (const TestSuite& other); - TestSuite& operator= (const TestSuite& other); + TestSuite( const TestSuite &other ); + TestSuite &operator =( const TestSuite &other ); private: - std::vector<Test *> m_tests; - const std::string m_name; + std::vector<Test *> m_tests; + const std::string m_name; }; diff --git a/include/cppunit/TextOutputter.h b/include/cppunit/TextOutputter.h index 22010a1..6ce0b61 100644 --- a/include/cppunit/TextOutputter.h +++ b/include/cppunit/TextOutputter.h @@ -16,7 +16,7 @@ class TestFailure; /*! Print a TestResultCollector in text format. */ -class TextOutputter : public Outputter +class CPPUNIT_API TextOutputter : public Outputter { public: TextOutputter( TestResultCollector *result, diff --git a/include/cppunit/TextTestProgressListener.h b/include/cppunit/TextTestProgressListener.h index c8911cd..b65c16a 100644 --- a/include/cppunit/TextTestProgressListener.h +++ b/include/cppunit/TextTestProgressListener.h @@ -10,7 +10,7 @@ namespace CppUnit /*! \class TextTestProgressListener * \brief This class represents */ -class TextTestProgressListener : public TestListener +class CPPUNIT_API TextTestProgressListener : public TestListener { public: /*! Constructs a TextTestProgressListener object. diff --git a/include/cppunit/TextTestResult.h b/include/cppunit/TextTestResult.h index dd2cf31..78ddaa2 100644 --- a/include/cppunit/TextTestResult.h +++ b/include/cppunit/TextTestResult.h @@ -15,8 +15,8 @@ class Test; * * Use class TextTestProgressListener and TextOutputter instead. */ -class TextTestResult : public TestResult, - public TestResultCollector +class CPPUNIT_API TextTestResult : public TestResult, + public TestResultCollector { public: TextTestResult(); diff --git a/include/cppunit/TextTestRunner.h b/include/cppunit/TextTestRunner.h index b005487..23f7387 100644 --- a/include/cppunit/TextTestRunner.h +++ b/include/cppunit/TextTestRunner.h @@ -32,7 +32,7 @@ class TestResultCollector; * runner.run( "", true ); // Run all tests and wait * \endcode */ -class TextTestRunner +class CPPUNIT_API TextTestRunner { public: /*! Constructs a new text runner. diff --git a/include/cppunit/XmlOutputter.h b/include/cppunit/XmlOutputter.h index f7afda3..55157ef 100644 --- a/include/cppunit/XmlOutputter.h +++ b/include/cppunit/XmlOutputter.h @@ -20,7 +20,7 @@ class TestResultCollector; /*! Outputs a TestResultCollector in XML format. */ -class XmlOutputter : public Outputter +class CPPUNIT_API XmlOutputter : public Outputter { public: /*! Constructs a XmlOutputter object. @@ -46,7 +46,7 @@ public: * \warning This class will probably be replaced with an abstract * builder in future version. */ - class Node + class CPPUNIT_API Node { public: Node( std::string elementName, @@ -118,6 +118,7 @@ private: }; + } // namespace CppUnit #endif // CPPUNIT_XMLTESTRESULTOUTPUTTER_H diff --git a/include/cppunit/config-msvc6.h b/include/cppunit/config-msvc6.h index 0eac74e..da828b1 100644 --- a/include/cppunit/config-msvc6.h +++ b/include/cppunit/config-msvc6.h @@ -38,6 +38,21 @@ #define CPPUNIT_PACKAGE "cppunit" #endif +// define CPPUNIT_DLL when linking to CppUnit dll. +#ifdef CPPUNIT_DLL +#undef CPPUNIT_API +#define CPPUNIT_API __declspec(dllimport) +#undef CPPUNIT_NEED_DLL_DECL +#define CPPUNIT_NEED_DLL_DECL 1 +#endif + +// define CPPUNIT_DLL_BUILD when building CppUnit dll. +#ifdef CPPUNIT_BUILD_DLL +#undef CPPUNIT_API +#define CPPUNIT_API __declspec(dllexport) +#undef CPPUNIT_NEED_DLL_DECL +#define CPPUNIT_NEED_DLL_DECL 1 +#endif #if _MSC_VER > 1000 // VC++ diff --git a/include/cppunit/extensions/RepeatedTest.h b/include/cppunit/extensions/RepeatedTest.h index e27b53e..067fd20 100644 --- a/include/cppunit/extensions/RepeatedTest.h +++ b/include/cppunit/extensions/RepeatedTest.h @@ -1,6 +1,7 @@ #ifndef CPPUNIT_EXTENSIONS_REPEATEDTEST_H #define CPPUNIT_EXTENSIONS_REPEATEDTEST_H +#include <cppunit/Portability.h> #include <cppunit/extensions/TestDecorator.h> namespace CppUnit { @@ -13,7 +14,7 @@ class TestResult; * * Does not assume ownership of the test it decorates */ -class RepeatedTest : public TestDecorator +class CPPUNIT_API RepeatedTest : public TestDecorator { public: RepeatedTest( Test *test, diff --git a/include/cppunit/extensions/TestDecorator.h b/include/cppunit/extensions/TestDecorator.h index 2a6b9d7..c3dc343 100644 --- a/include/cppunit/extensions/TestDecorator.h +++ b/include/cppunit/extensions/TestDecorator.h @@ -1,6 +1,7 @@ #ifndef CPPUNIT_EXTENSIONS_TESTDECORATOR_H #define CPPUNIT_EXTENSIONS_TESTDECORATOR_H +#include <cppunit/Portability.h> #include <cppunit/Test.h> namespace CppUnit { @@ -16,7 +17,7 @@ class TestResult; * * Does not assume ownership of the test it decorates */ -class TestDecorator : public Test +class CPPUNIT_API TestDecorator : public Test { public: TestDecorator (Test *test); diff --git a/include/cppunit/extensions/TestFactory.h b/include/cppunit/extensions/TestFactory.h index 0658a09..3b1f001 100644 --- a/include/cppunit/extensions/TestFactory.h +++ b/include/cppunit/extensions/TestFactory.h @@ -1,22 +1,24 @@ #ifndef CPPUNIT_EXTENSIONS_TESTFACTORY_H #define CPPUNIT_EXTENSIONS_TESTFACTORY_H +#include <cppunit/Portability.h> + namespace CppUnit { - class Test; +class Test; - /** This class represents an abstract Test factory. - */ - class TestFactory - { - public: - virtual ~TestFactory() {} +/** This class represents an abstract Test factory. + */ +class CPPUNIT_API TestFactory +{ +public: + virtual ~TestFactory() {} - /** Makes a new test. - * \return A new Test. - */ - virtual Test* makeTest() = 0; - }; + /** Makes a new test. + * \return A new Test. + */ + virtual Test* makeTest() = 0; +}; } // namespace CppUnit diff --git a/include/cppunit/extensions/TestFactoryRegistry.h b/include/cppunit/extensions/TestFactoryRegistry.h index a9edea2..5583d1a 100644 --- a/include/cppunit/extensions/TestFactoryRegistry.h +++ b/include/cppunit/extensions/TestFactoryRegistry.h @@ -8,66 +8,71 @@ namespace CppUnit { - class TestSuite; +class TestSuite; + +#if CPPUNIT_NEED_DLL_DECL + template class CPPUNIT_API std::map<std::string, TestFactory *>; +#endif + + +/** This class implements a registry for test factory. + * + * Note that the registry assume lifetime control for any registered test. + */ +class CPPUNIT_API TestFactoryRegistry : public TestFactory +{ +public: + /** Constructs the registry with the specified name. + * \param name Name of the registry. + */ + TestFactoryRegistry( std::string name = "All Tests" ); + + /// Destructor. + virtual ~TestFactoryRegistry(); + + /** Makes a suite containing all the registered test. + * \return A new suite containing all the registered test. + */ + virtual Test *makeTest(); + + /** Returns the registry. + * \return Registry. + */ + static TestFactoryRegistry &getRegistry(); + + /** Returns a named registry. + * \param name Name of the registry to return. + * \return Registry. If the registry does not exist, it is created. + */ + static TestFactoryRegistry &getRegistry( const std::string &name ); - /** This class implements a registry for test factory. - * - * Note that the registry assume lifetime control for any registered test. + /** Adds the registered test to the specified suite. + * \param suite Suite the test are added to. */ - class TestFactoryRegistry : public TestFactory - { - public: - /** Constructs the registry with the specified name. - * \param name Name of the registry. - */ - TestFactoryRegistry( std::string name = "All Tests" ); - - /// Destructor. - virtual ~TestFactoryRegistry(); - - /** Makes a suite containing all the registered test. - * \return A new suite containing all the registered test. - */ - virtual Test *makeTest(); - - /** Returns the registry. - * \return Registry. - */ - static TestFactoryRegistry &getRegistry(); - - /** Returns a named registry. - * \param name Name of the registry to return. - * \return Registry. If the registry does not exist, it is created. - */ - static TestFactoryRegistry &getRegistry( const std::string &name ); - - /** Adds the registered test to the specified suite. - * \param suite Suite the test are added to. - */ - void addTestToSuite( TestSuite *suite ); - - /** Registers a test factory with the specified name. - * \param name Name associated to the factory. - * \param factory Factory to register. - */ - void registerFactory( const std::string &name, - TestFactory *factory ); - - /** Registers a test factory using its class name. - * \param factory Factory to register. - */ - void registerFactory( TestFactory *factory ); - - private: - TestFactoryRegistry( const TestFactoryRegistry © ); - void operator =( const TestFactoryRegistry © ); - - private: - typedef std::map<std::string, TestFactory *> Factories; - Factories m_factories; - - std::string m_name; - }; + void addTestToSuite( TestSuite *suite ); + + /** Registers a test factory with the specified name. + * \param name Name associated to the factory. + * \param factory Factory to register. + */ + void registerFactory( const std::string &name, + TestFactory *factory ); + + /** Registers a test factory using its class name. + * \param factory Factory to register. + */ + void registerFactory( TestFactory *factory ); + +private: + TestFactoryRegistry( const TestFactoryRegistry © ); + void operator =( const TestFactoryRegistry © ); + +private: + typedef std::map<std::string, TestFactory *> Factories; + Factories m_factories; + + std::string m_name; +}; diff --git a/include/cppunit/extensions/TestSetUp.h b/include/cppunit/extensions/TestSetUp.h index c97402c..0fe2663 100644 --- a/include/cppunit/extensions/TestSetUp.h +++ b/include/cppunit/extensions/TestSetUp.h @@ -9,16 +9,16 @@ class Test; class TestResult; -class TestSetUp : public TestDecorator +class CPPUNIT_API TestSetUp : public TestDecorator { public: - TestSetUp (Test *test) : TestDecorator (test) {} + TestSetUp( Test *test ); - void run (TestResult *result); + void run( TestResult *result ); protected: - virtual void setUp () {} - virtual void tearDown () {} + virtual void setUp(); + virtual void tearDown(); private: TestSetUp( const TestSetUp & ); @@ -26,15 +26,6 @@ private: }; -inline void -TestSetUp::run (TestResult *result) -{ - setUp (); - TestDecorator::run (result); - tearDown (); -} - - } // namespace CppUnit #endif // CPPUNIT_EXTENSIONS_TESTSETUP_H diff --git a/include/cppunit/extensions/TestSuiteFactory.h b/include/cppunit/extensions/TestSuiteFactory.h index a54311b..cc07471 100644 --- a/include/cppunit/extensions/TestSuiteFactory.h +++ b/include/cppunit/extensions/TestSuiteFactory.h @@ -8,7 +8,7 @@ namespace CppUnit { class Test; template<typename TestCaseType> - class TestSuiteFactory : public TestFactory + class TestSuiteFactory : public TestFactory { public: virtual Test *makeTest() diff --git a/include/cppunit/extensions/TypeInfoHelper.h b/include/cppunit/extensions/TypeInfoHelper.h index f4008ef..5199a70 100644 --- a/include/cppunit/extensions/TypeInfoHelper.h +++ b/include/cppunit/extensions/TypeInfoHelper.h @@ -12,7 +12,7 @@ namespace CppUnit { /** Helper to use type_info. */ - class TypeInfoHelper + class CPPUNIT_API TypeInfoHelper { public: /** Get the class name of the specified type_info. |
