diff options
Diffstat (limited to '3rdParty/CppUnit/src/include/cppunit/extensions')
11 files changed, 1307 insertions, 0 deletions
diff --git a/3rdParty/CppUnit/src/include/cppunit/extensions/AutoRegisterSuite.h b/3rdParty/CppUnit/src/include/cppunit/extensions/AutoRegisterSuite.h new file mode 100644 index 0000000..e04adb5 --- /dev/null +++ b/3rdParty/CppUnit/src/include/cppunit/extensions/AutoRegisterSuite.h @@ -0,0 +1,83 @@ +#ifndef CPPUNIT_EXTENSIONS_AUTOREGISTERSUITE_H +#define CPPUNIT_EXTENSIONS_AUTOREGISTERSUITE_H + +#include <cppunit/extensions/TestSuiteFactory.h> +#include <cppunit/extensions/TestFactoryRegistry.h> +#include <string> + +CPPUNIT_NS_BEGIN + + +/*! \brief (Implementation) Automatically register the test suite of the specified type. + * + * You should not use this class directly. Instead, use the following macros: + * - CPPUNIT_TEST_SUITE_REGISTRATION() + * - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION() + * + * This object will register the test returned by TestCaseType::suite() + * when constructed to the test registry. + * + * This object is intented to be used as a static variable. + * + * + * \param TestCaseType Type of the test case which suite is registered. + * \see CPPUNIT_TEST_SUITE_REGISTRATION, CPPUNIT_TEST_SUITE_NAMED_REGISTRATION + * \see CppUnit::TestFactoryRegistry. + */ +template<class TestCaseType> +class AutoRegisterSuite +{ +public: +  /** Auto-register the suite factory in the global registry. +   */ +  AutoRegisterSuite() +      : m_registry( &TestFactoryRegistry::getRegistry() ) +  { +    m_registry->registerFactory( &m_factory ); +  } + +  /** Auto-register the suite factory in the specified registry. +   * \param name Name of the registry. +   */ +  AutoRegisterSuite( const std::string &name ) +      : m_registry( &TestFactoryRegistry::getRegistry( name ) ) +  { +    m_registry->registerFactory( &m_factory ); +  } + +  ~AutoRegisterSuite() +  { +    if ( TestFactoryRegistry::isValid() ) +      m_registry->unregisterFactory( &m_factory ); +  } + +private: +  TestFactoryRegistry *m_registry; +  TestSuiteFactory<TestCaseType> m_factory; +}; + + +/*! \brief (Implementation) Automatically adds a registry into another registry. + * + * Don't use this class. Use the macros CPPUNIT_REGISTRY_ADD() and + * CPPUNIT_REGISTRY_ADD_TO_DEFAULT() instead. + */ +class AutoRegisterRegistry +{ +public: +  AutoRegisterRegistry( const std::string &which, +                        const std::string &to ) +  { +    TestFactoryRegistry::getRegistry( to ).addRegistry( which ); +  } + +  AutoRegisterRegistry( const std::string &which ) +  { +    TestFactoryRegistry::getRegistry().addRegistry( which ); +  } +}; + + +CPPUNIT_NS_END + +#endif  // CPPUNIT_EXTENSIONS_AUTOREGISTERSUITE_H diff --git a/3rdParty/CppUnit/src/include/cppunit/extensions/ExceptionTestCaseDecorator.h b/3rdParty/CppUnit/src/include/cppunit/extensions/ExceptionTestCaseDecorator.h new file mode 100644 index 0000000..9c816ad --- /dev/null +++ b/3rdParty/CppUnit/src/include/cppunit/extensions/ExceptionTestCaseDecorator.h @@ -0,0 +1,104 @@ +#ifndef CPPUNIT_EXTENSIONS_EXCEPTIONTESTCASEDECORATOR_H +#define CPPUNIT_EXTENSIONS_EXCEPTIONTESTCASEDECORATOR_H + +#include <cppunit/Portability.h> +#include <cppunit/Exception.h> +#include <cppunit/extensions/TestCaseDecorator.h> + +CPPUNIT_NS_BEGIN + + +/*! \brief Expected exception test case decorator. + * + * A decorator used to assert that a specific test case should throw an + * exception of a given type. + * + * You should use this class only if you need to check the exception object + * state (that a specific cause is set for example). If you don't need to + * do that, you might consider using CPPUNIT_TEST_EXCEPTION() instead. + * + * Intended use is to subclass and override checkException(). Example: + * + * \code + * + * class NetworkErrorTestCaseDecorator :  + *           public ExceptionTestCaseDecorator<NetworkError> + * { + * public: + *   NetworkErrorTestCaseDecorator( NetworkError::Cause expectedCause ) + *       : m_expectedCause( expectedCause ) + *   { + *   } + * private: + *   void checkException( ExpectedExceptionType &e ) + *   { + *     CPPUNIT_ASSERT_EQUAL( m_expectedCause, e.getCause() ); + *   } + * + *   NetworkError::Cause m_expectedCause; + * }; + * \endcode + * + */  +template<class ExpectedException> +class ExceptionTestCaseDecorator : public TestCaseDecorator +{ +public: +  typedef ExpectedException ExpectedExceptionType; + +  /*! \brief Decorates the specified test. +   * \param test TestCase to decorate. Assumes ownership of the test. +   */ +  ExceptionTestCaseDecorator( TestCase *test ) +      : TestCaseDecorator( test ) +  { +  } + +  /*! \brief Checks that the expected exception is thrown by the decorated test. +   * is thrown. +   * +   * Calls the decorated test runTest() and checks that an exception of +   * type ExpectedException is thrown. Call checkException() passing the +   * exception that was caught so that some assertions can be made if +   * needed. +   */ +  void runTest() +  { +    try +    { +      TestCaseDecorator::runTest(); +    } +    catch ( ExpectedExceptionType &e ) +    { +      checkException( e ); +      return; +    } + +    // Moved outside the try{} statement to handle the case where the +    // expected exception type is Exception (expecting assertion failure). +#if CPPUNIT_USE_TYPEINFO_NAME +      throw Exception( Message( +                         "expected exception not thrown", +                         "Expected exception type: " +  +                           TypeInfoHelper::getClassName(  +                               typeid( ExpectedExceptionType ) ) ) ); +#else +      throw Exception( Message("expected exception not thrown") ); +#endif +  } + +private: +  /*! \brief Called when the exception is caught. +   * +   * Should be overriden to check the exception. +   */ +  virtual void checkException( ExpectedExceptionType &e ) +  { +  } +}; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_EXTENSIONS_EXCEPTIONTESTCASEDECORATOR_H + diff --git a/3rdParty/CppUnit/src/include/cppunit/extensions/HelperMacros.h b/3rdParty/CppUnit/src/include/cppunit/extensions/HelperMacros.h new file mode 100644 index 0000000..12431e4 --- /dev/null +++ b/3rdParty/CppUnit/src/include/cppunit/extensions/HelperMacros.h @@ -0,0 +1,541 @@ +// ////////////////////////////////////////////////////////////////////////// +// Header file HelperMacros.h +// (c)Copyright 2000, Baptiste Lepilleur. +// Created: 2001/04/15 +// ////////////////////////////////////////////////////////////////////////// +#ifndef CPPUNIT_EXTENSIONS_HELPERMACROS_H +#define CPPUNIT_EXTENSIONS_HELPERMACROS_H + +#include <cppunit/TestCaller.h> +#include <cppunit/TestSuite.h> +#include <cppunit/extensions/AutoRegisterSuite.h> +#include <cppunit/extensions/ExceptionTestCaseDecorator.h> +#include <cppunit/extensions/TestFixtureFactory.h> +#include <cppunit/extensions/TestNamer.h> +#include <cppunit/extensions/TestSuiteBuilderContext.h> +#include <memory> + + +/*! \addtogroup WritingTestFixture Writing test fixture + */ +/** @{ + */ + + +/** \file + * Macros intended to ease the definition of test suites. + * + * The macros + * CPPUNIT_TEST_SUITE(), CPPUNIT_TEST(), and CPPUNIT_TEST_SUITE_END() + * are designed to facilitate easy creation of a test suite. + * For example, + * + * \code + * #include <cppunit/extensions/HelperMacros.h> + * class MyTest : public CppUnit::TestFixture { + *   CPPUNIT_TEST_SUITE( MyTest ); + *   CPPUNIT_TEST( testEquality ); + *   CPPUNIT_TEST( testSetName ); + *   CPPUNIT_TEST_SUITE_END(); + * public: + *   void testEquality(); + *   void testSetName(); + * }; + * \endcode + *  + * The effect of these macros is to define two methods in the + * class MyTest.  The first method is an auxiliary function + * named registerTests that you will not need to call directly. + * The second function + * \code static CppUnit::TestSuite *suite()\endcode + * returns a pointer to the suite of tests defined by the CPPUNIT_TEST() + * macros.   + * + * Rather than invoking suite() directly, + * the macro CPPUNIT_TEST_SUITE_REGISTRATION() is + * used to create a static variable that automatically + * registers its test suite in a global registry. + * The registry yields a Test instance containing all the + * registered suites. + * \code + * CPPUNIT_TEST_SUITE_REGISTRATION( MyTest ); + * CppUnit::Test* tp = + *   CppUnit::TestFactoryRegistry::getRegistry().makeTest(); + * \endcode + *  + * The test suite macros can even be used with templated test classes. + * For example: + * + * \code + * template<typename CharType> + * class StringTest : public CppUnit::TestFixture { + *   CPPUNIT_TEST_SUITE( StringTest ); + *   CPPUNIT_TEST( testAppend ); + *   CPPUNIT_TEST_SUITE_END(); + * public:   + *   ... + * }; + * \endcode + * + * You need to add in an implementation file: + * + * \code + * CPPUNIT_TEST_SUITE_REGISTRATION( StringTest<char> ); + * CPPUNIT_TEST_SUITE_REGISTRATION( StringTest<wchar_t> ); + * \endcode + */ + + +/*! \brief Begin test suite + * + * This macro starts the declaration of a new test suite. + * Use CPPUNIT_TEST_SUB_SUITE() instead, if you wish to include the + * test suite of the parent class. + * + * \param ATestFixtureType Type of the test case class. This type \b MUST + *                         be derived from TestFixture. + * \see CPPUNIT_TEST_SUB_SUITE, CPPUNIT_TEST, CPPUNIT_TEST_SUITE_END,  + * \see CPPUNIT_TEST_SUITE_REGISTRATION, CPPUNIT_TEST_EXCEPTION, CPPUNIT_TEST_FAIL. + */ +#define CPPUNIT_TEST_SUITE( ATestFixtureType )                              \ +  public:                                                                   \ +    typedef ATestFixtureType TestFixtureType;                               \ +                                                                            \ +  private:                                                                  \ +    static const CPPUNIT_NS::TestNamer &getTestNamer__()                    \ +    {                                                                       \ +      static CPPUNIT_TESTNAMER_DECL( testNamer, ATestFixtureType );         \ +      return testNamer;                                                     \ +    }                                                                       \ +                                                                            \ +  public:                                                                   \ +    typedef CPPUNIT_NS::TestSuiteBuilderContext<TestFixtureType>            \ +                TestSuiteBuilderContextType;                                \ +                                                                            \ +    static void                                                             \ +    addTestsToSuite( CPPUNIT_NS::TestSuiteBuilderContextBase &baseContext ) \ +    {                                                                       \ +      TestSuiteBuilderContextType context( baseContext ) + + +/*! \brief Begin test suite (includes parent suite) + *  + * This macro may only be used in a class whose parent class + * defines a test suite using CPPUNIT_TEST_SUITE() or CPPUNIT_TEST_SUB_SUITE(). + * + * This macro begins the declaration of a test suite, in the same + * manner as CPPUNIT_TEST_SUITE().  In addition, the test suite of the + * parent is automatically inserted in the test suite being + * defined. + *  + * Here is an example: + * + * \code + * #include <cppunit/extensions/HelperMacros.h> + * class MySubTest : public MyTest { + *   CPPUNIT_TEST_SUB_SUITE( MySubTest, MyTest ); + *   CPPUNIT_TEST( testAdd ); + *   CPPUNIT_TEST( testSub ); + *   CPPUNIT_TEST_SUITE_END(); + * public: + *   void testAdd(); + *   void testSub(); + * }; + * \endcode + * + * \param ATestFixtureType Type of the test case class. This type \b MUST + *                         be derived from TestFixture. + * \param ASuperClass   Type of the parent class. + * \see CPPUNIT_TEST_SUITE. + */ +#define CPPUNIT_TEST_SUB_SUITE( ATestFixtureType, ASuperClass )  \ +  public:                                                        \ +    typedef ASuperClass ParentTestFixtureType;                   \ +  private:                                                       \ +    CPPUNIT_TEST_SUITE( ATestFixtureType );                      \ +      ParentTestFixtureType::addTestsToSuite( baseContext ) + + +/*! \brief End declaration of the test suite. + * + * After this macro, member access is set to "private". + * + * \see  CPPUNIT_TEST_SUITE. + * \see  CPPUNIT_TEST_SUITE_REGISTRATION. + */ +#define CPPUNIT_TEST_SUITE_END()                                               \ +    }                                                                          \ +                                                                               \ +    static CPPUNIT_NS::TestSuite *suite()                                      \ +    {                                                                          \ +      const CPPUNIT_NS::TestNamer &namer = getTestNamer__();                   \ +      std::auto_ptr<CPPUNIT_NS::TestSuite> suite(                              \ +             new CPPUNIT_NS::TestSuite( namer.getFixtureName() ));             \ +      CPPUNIT_NS::ConcretTestFixtureFactory<TestFixtureType> factory;          \ +      CPPUNIT_NS::TestSuiteBuilderContextBase context( *suite.get(),           \ +                                                       namer,                  \ +                                                       factory );              \ +      TestFixtureType::addTestsToSuite( context );                             \ +      return suite.release();                                                  \ +    }                                                                          \ +  private: /* dummy typedef so that the macro can still end with ';'*/         \ +    typedef int CppUnitDummyTypedefForSemiColonEnding__ + +/*! \brief End declaration of an abstract test suite. + * + * Use this macro to indicate that the %TestFixture is abstract. No + * static suite() method will be declared.  + * + * After this macro, member access is set to "private". + * + * Here is an example of usage: + * + * The abstract test fixture: + * \code + * #include <cppunit/extensions/HelperMacros.h> + * class AbstractDocument; + * class AbstractDocumentTest : public CppUnit::TestFixture { + *   CPPUNIT_TEST_SUITE( AbstractDocumentTest ); + *   CPPUNIT_TEST( testInsertText ); + *   CPPUNIT_TEST_SUITE_END_ABSTRACT(); + * public: + *   void testInsertText(); + *  + *   void setUp() + *   { + *     m_document = makeDocument(); + *   } + * + *   void tearDown() + *   { + *     delete m_document; + *   } + * protected: + *   virtual AbstractDocument *makeDocument() =0; + * + *   AbstractDocument *m_document; + * };\endcode + * + * The concret test fixture: + * \code + * class RichTextDocumentTest : public AbstractDocumentTest { + *   CPPUNIT_TEST_SUB_SUITE( RichTextDocumentTest, AbstractDocumentTest ); + *   CPPUNIT_TEST( testInsertFormatedText ); + *   CPPUNIT_TEST_SUITE_END(); + * public: + *   void testInsertFormatedText(); + * protected: + *   AbstractDocument *makeDocument() + *   { + *     return new RichTextDocument(); + *   } + * };\endcode + * + * \see  CPPUNIT_TEST_SUB_SUITE. + * \see  CPPUNIT_TEST_SUITE_REGISTRATION. + */ +#define CPPUNIT_TEST_SUITE_END_ABSTRACT()                                      \ +    }                                                                          \ +  private: /* dummy typedef so that the macro can still end with ';'*/         \ +    typedef int CppUnitDummyTypedefForSemiColonEnding__ + + +/*! \brief Add a test to the suite (for custom test macro). + * + * The specified test will be added to the test suite being declared. This macro + * is intended for \e advanced usage, to extend %CppUnit by creating new macro such + * as CPPUNIT_TEST_EXCEPTION()... + * + * Between macro CPPUNIT_TEST_SUITE() and CPPUNIT_TEST_SUITE_END(), you can assume + * that the following variables can be used: + * \code + * typedef TestSuiteBuilder<TestFixtureType> TestSuiteBuilderType; + * TestSuiteBuilderType &context; + * \endcode + * + * \c context can be used to name test case, create new test fixture instance, + * or add test case to the test fixture suite. + * + * Below is an example that show how to use this macro to create new macro to add + * test to the fixture suite. The macro below show how you would add a new type + * of test case which fails if the execution last more than a given time limit. + * It relies on an imaginary TimeOutTestCaller class which has an interface similar + * to TestCaller. + *  + * \code + * #define CPPUNITEX_TEST_TIMELIMIT( testMethod, timeLimit )            \ + *      CPPUNIT_TEST_SUITE_ADD_TEST( (new TimeOutTestCaller<TestFixtureType>(  \ + *                  namer.getTestNameFor( #testMethod ),                \ + *                  &TestFixtureType::testMethod,                   \ + *                  factory.makeFixture(),                              \ + *                  timeLimit ) ) ) + *    + * class PerformanceTest : CppUnit::TestFixture + * { + * public: + *   CPPUNIT_TEST_SUITE( PerformanceTest ); + *   CPPUNITEX_TEST_TIMELIMIT( testSortReverseOrder, 5.0 ); + *   CPPUNIT_TEST_SUITE_END(); + * + *   void testSortReverseOrder(); + * }; + * \endcode + * + * \param test Test to add to the suite. Must be a subclass of Test. The test name + *             should have been obtained using TestNamer::getTestNameFor(). + */ +#define CPPUNIT_TEST_SUITE_ADD_TEST( test ) \ +      context.addTest( test ) + +/*! \brief Add a method to the suite. + * \param testMethod Name of the method of the test case to add to the + *                   suite. The signature of the method must be of + *                   type: void testMethod(); + * \see  CPPUNIT_TEST_SUITE. + */ +#define CPPUNIT_TEST( testMethod )                        \ +    CPPUNIT_TEST_SUITE_ADD_TEST(                           \ +        ( new CPPUNIT_NS::TestCaller<TestFixtureType>(    \ +                  context.getTestNameFor( #testMethod),   \ +                  &TestFixtureType::testMethod,           \ +                  context.makeFixture() ) ) ) + +/*! \brief Add a test which fail if the specified exception is not caught. + * + * Example: + * \code + * #include <cppunit/extensions/HelperMacros.h> + * #include <vector> + * class MyTest : public CppUnit::TestFixture { + *   CPPUNIT_TEST_SUITE( MyTest ); + *   CPPUNIT_TEST_EXCEPTION( testVectorAtThrow, std::invalid_argument ); + *   CPPUNIT_TEST_SUITE_END(); + * public: + *   void testVectorAtThrow() + *   { + *     std::vector<int> v; + *     v.at( 1 );     // must throw exception std::invalid_argument + *   } + * }; + * \endcode + * + * \param testMethod Name of the method of the test case to add to the suite. + * \param ExceptionType Type of the exception that must be thrown by the test  + *                      method. + * \deprecated Use the assertion macro CPPUNIT_ASSERT_THROW instead. + */ +#define CPPUNIT_TEST_EXCEPTION( testMethod, ExceptionType )          \ +  CPPUNIT_TEST_SUITE_ADD_TEST(                                        \ +      (new CPPUNIT_NS::ExceptionTestCaseDecorator< ExceptionType >(  \ +          new CPPUNIT_NS::TestCaller< TestFixtureType >(             \ +                               context.getTestNameFor( #testMethod ),  \ +                               &TestFixtureType::testMethod,         \ +                               context.makeFixture() ) ) ) ) + +/*! \brief Adds a test case which is excepted to fail. + * + * The added test case expect an assertion to fail. You usually used that type + * of test case when testing custom assertion macros. + * + * \code + * CPPUNIT_TEST_FAIL( testAssertFalseFail ); + *  + * void testAssertFalseFail() + * { + *   CPPUNIT_ASSERT( false ); + * } + * \endcode + * \see CreatingNewAssertions. + * \deprecated Use the assertion macro CPPUNIT_ASSERT_ASSERTION_FAIL instead. + */ +#define CPPUNIT_TEST_FAIL( testMethod ) \ +              CPPUNIT_TEST_EXCEPTION( testMethod, CPPUNIT_NS::Exception ) + +/*! \brief Adds some custom test cases. + * + * Use this to add one or more test cases to the fixture suite. The specified + * method is called with a context parameter that can be used to name,  + * instantiate fixture, and add instantiated test case to the fixture suite. + * The specified method must have the following signature: + * \code + * static void aMethodName( TestSuiteBuilderContextType &context ); + * \endcode + * + * \c TestSuiteBuilderContextType is typedef to  + * TestSuiteBuilderContext<TestFixtureType> declared by CPPUNIT_TEST_SUITE(). + * + * Here is an example that add two custom tests: + * + * \code + * #include <cppunit/extensions/HelperMacros.h> + * + * class MyTest : public CppUnit::TestFixture { + *   CPPUNIT_TEST_SUITE( MyTest ); + *   CPPUNIT_TEST_SUITE_ADD_CUSTOM_TESTS( addTimeOutTests ); + *   CPPUNIT_TEST_SUITE_END(); + * public: + *   static void addTimeOutTests( TestSuiteBuilderContextType &context ) + *   { + *     context.addTest( new TimeOutTestCaller( context.getTestNameFor( "test1" ) ), + *                                             &MyTest::test1, + *                                             context.makeFixture(), + *                                             5.0 ); + *     context.addTest( new TimeOutTestCaller( context.getTestNameFor( "test2" ) ), + *                                             &MyTest::test2, + *                                             context.makeFixture(), + *                                             5.0 ); + *   } + * + *   void test1() + *   { + *     // Do some test that may never end... + *   } + * + *   void test2() + *   { + *     // Do some test that may never end... + *   } + * }; + * \endcode + * @param testAdderMethod Name of the method called to add the test cases. + */ +#define CPPUNIT_TEST_SUITE_ADD_CUSTOM_TESTS( testAdderMethod ) \ +      testAdderMethod( context ) + +/*! \brief Adds a property to the test suite builder context. + * \param APropertyKey   Key of the property to add. + * \param APropertyValue Value for the added property. + * Example: + * \code + * CPPUNIT_TEST_SUITE_PROPERTY("XmlFileName", "paraTest.xml"); \endcode + */ +#define CPPUNIT_TEST_SUITE_PROPERTY( APropertyKey, APropertyValue ) \ +    context.addProperty( std::string(APropertyKey),                 \ +                         std::string(APropertyValue) ) + +/** @} + */ + + +/*! Adds the specified fixture suite to the unnamed registry. + * \ingroup CreatingTestSuite + * + * This macro declares a static variable whose construction + * causes a test suite factory to be inserted in a global registry + * of such factories.  The registry is available by calling + * the static function CppUnit::TestFactoryRegistry::getRegistry(). + *  + * \param ATestFixtureType Type of the test case class. + * \warning This macro should be used only once per line of code (the line + *          number is used to name a hidden static variable). + * \see CPPUNIT_TEST_SUITE_NAMED_REGISTRATION + * \see CPPUNIT_REGISTRY_ADD_TO_DEFAULT + * \see CPPUNIT_REGISTRY_ADD + * \see CPPUNIT_TEST_SUITE, CppUnit::AutoRegisterSuite,  + *      CppUnit::TestFactoryRegistry. + */ +#define CPPUNIT_TEST_SUITE_REGISTRATION( ATestFixtureType )      \ +  static CPPUNIT_NS::AutoRegisterSuite< ATestFixtureType >       \ +             CPPUNIT_MAKE_UNIQUE_NAME(autoRegisterRegistry__ ) + + +/** Adds the specified fixture suite to the specified registry suite. + * \ingroup CreatingTestSuite + * + * This macro declares a static variable whose construction + * causes a test suite factory to be inserted in the global registry + * suite of the specified name. The registry is available by calling + * the static function CppUnit::TestFactoryRegistry::getRegistry(). + *  + * For the suite name, use a string returned by a static function rather + * than a hardcoded string. That way, you can know what are the name of + * named registry and you don't risk mistyping the registry name. + * + * \code + * // MySuites.h + * namespace MySuites { + *   std::string math() {  + *     return "Math"; + *   } + * } + * + * // ComplexNumberTest.cpp + * #include "MySuites.h" + *  + * CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ComplexNumberTest, MySuites::math() ); + * \endcode + * + * \param ATestFixtureType Type of the test case class. + * \param suiteName Name of the global registry suite the test suite is  + *                  registered into. + * \warning This macro should be used only once per line of code (the line + *          number is used to name a hidden static variable). + * \see CPPUNIT_TEST_SUITE_REGISTRATION + * \see CPPUNIT_REGISTRY_ADD_TO_DEFAULT + * \see CPPUNIT_REGISTRY_ADD + * \see CPPUNIT_TEST_SUITE, CppUnit::AutoRegisterSuite,  + *      CppUnit::TestFactoryRegistry.. + */ +#define CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ATestFixtureType, suiteName ) \ +  static CPPUNIT_NS::AutoRegisterSuite< ATestFixtureType >                   \ +             CPPUNIT_MAKE_UNIQUE_NAME(autoRegisterRegistry__ )(suiteName) + +/*! Adds that the specified registry suite to another registry suite. + * \ingroup CreatingTestSuite + * + * Use this macros to automatically create test registry suite hierarchy. For example, + * if you want to create the following hierarchy: + * - Math + *   - IntegerMath + *   - FloatMath + *     - FastFloat + *     - StandardFloat + *  + * You can do this automatically with: + * \code + * CPPUNIT_REGISTRY_ADD( "FastFloat", "FloatMath" ); + * CPPUNIT_REGISTRY_ADD( "IntegerMath", "Math" ); + * CPPUNIT_REGISTRY_ADD( "FloatMath", "Math" ); + * CPPUNIT_REGISTRY_ADD( "StandardFloat", "FloatMath" ); + * \endcode + * + * There is no specific order of declaration. Think of it as declaring links. + * + * You register the test in each suite using CPPUNIT_TEST_SUITE_NAMED_REGISTRATION. + * + * \param which Name of the registry suite to add to the registry suite named \a to. + * \param to Name of the registry suite \a which is added to. + * \see CPPUNIT_REGISTRY_ADD_TO_DEFAULT, CPPUNIT_TEST_SUITE_NAMED_REGISTRATION. + */ +#define CPPUNIT_REGISTRY_ADD( which, to )                                     \ +  static CPPUNIT_NS::AutoRegisterRegistry                                     \ +             CPPUNIT_MAKE_UNIQUE_NAME( autoRegisterRegistry__ )( which, to ) + +/*! Adds that the specified registry suite to the default registry suite. + * \ingroup CreatingTestSuite + * + * This macro is just like CPPUNIT_REGISTRY_ADD except the specified registry + * suite is added to the default suite (root suite). + * + * \param which Name of the registry suite to add to the default registry suite. + * \see CPPUNIT_REGISTRY_ADD. + */ +#define CPPUNIT_REGISTRY_ADD_TO_DEFAULT( which )                         \ +  static CPPUNIT_NS::AutoRegisterRegistry                                \ +             CPPUNIT_MAKE_UNIQUE_NAME( autoRegisterRegistry__ )( which ) + +// Backwards compatibility +// (Not tested!) + +#if CPPUNIT_ENABLE_CU_TEST_MACROS + +#define CU_TEST_SUITE(tc) CPPUNIT_TEST_SUITE(tc) +#define CU_TEST_SUB_SUITE(tc,sc) CPPUNIT_TEST_SUB_SUITE(tc,sc) +#define CU_TEST(tm) CPPUNIT_TEST(tm) +#define CU_TEST_SUITE_END() CPPUNIT_TEST_SUITE_END() +#define CU_TEST_SUITE_REGISTRATION(tc) CPPUNIT_TEST_SUITE_REGISTRATION(tc) + +#endif + + +#endif  // CPPUNIT_EXTENSIONS_HELPERMACROS_H diff --git a/3rdParty/CppUnit/src/include/cppunit/extensions/TestCaseDecorator.h b/3rdParty/CppUnit/src/include/cppunit/extensions/TestCaseDecorator.h new file mode 100644 index 0000000..3a15ba9 --- /dev/null +++ b/3rdParty/CppUnit/src/include/cppunit/extensions/TestCaseDecorator.h @@ -0,0 +1,40 @@ +#ifndef CPPUNIT_EXTENSIONS_TESTCASEDECORATOR_H +#define CPPUNIT_EXTENSIONS_TESTCASEDECORATOR_H + +#include <cppunit/Portability.h> +#include <cppunit/TestCase.h> + +CPPUNIT_NS_BEGIN + + +/*! \brief  Decorator for Test cases. + * + * TestCaseDecorator provides an alternate means to extend functionality + * of a test class without subclassing the test.  Instead, one can + * subclass the decorater and use it to wrap the test class. + * + * Does not assume ownership of the test it decorates + */  +class CPPUNIT_API TestCaseDecorator : public TestCase +{ +public: +  TestCaseDecorator( TestCase *test ); +  ~TestCaseDecorator(); + +  std::string getName() const; + +  void setUp(); + +  void tearDown(); + +  void runTest(); + +protected: +  TestCase *m_test; +}; + + +CPPUNIT_NS_END + +#endif + diff --git a/3rdParty/CppUnit/src/include/cppunit/extensions/TestFactory.h b/3rdParty/CppUnit/src/include/cppunit/extensions/TestFactory.h new file mode 100644 index 0000000..214d353 --- /dev/null +++ b/3rdParty/CppUnit/src/include/cppunit/extensions/TestFactory.h @@ -0,0 +1,27 @@ +#ifndef CPPUNIT_EXTENSIONS_TESTFACTORY_H +#define CPPUNIT_EXTENSIONS_TESTFACTORY_H + +#include <cppunit/Portability.h> + +CPPUNIT_NS_BEGIN + + +class Test; + +/*! \brief Abstract Test factory. + */ +class CPPUNIT_API TestFactory  +{ +public: +  virtual ~TestFactory() {} + +  /*! Makes a new test. +   * \return A new Test. +   */ +  virtual Test* makeTest() = 0; +}; + + +CPPUNIT_NS_END + +#endif  // CPPUNIT_EXTENSIONS_TESTFACTORY_H diff --git a/3rdParty/CppUnit/src/include/cppunit/extensions/TestFactoryRegistry.h b/3rdParty/CppUnit/src/include/cppunit/extensions/TestFactoryRegistry.h new file mode 100644 index 0000000..fc8723e --- /dev/null +++ b/3rdParty/CppUnit/src/include/cppunit/extensions/TestFactoryRegistry.h @@ -0,0 +1,182 @@ +#ifndef CPPUNIT_EXTENSIONS_TESTFACTORYREGISTRY_H +#define CPPUNIT_EXTENSIONS_TESTFACTORYREGISTRY_H + +#include <cppunit/Portability.h> + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( push ) +#pragma warning( disable: 4251)  // X needs to have dll-interface to be used by clients of class Z +#endif + +#include <cppunit/portability/CppUnitSet.h> +#include <cppunit/extensions/TestFactory.h> +#include <string> + +CPPUNIT_NS_BEGIN + + +class TestSuite; + +#if CPPUNIT_NEED_DLL_DECL +//  template class CPPUNIT_API std::set<TestFactory *>; +#endif + + +/*! \brief Registry for TestFactory. + * \ingroup CreatingTestSuite + * + * Notes that the registry \b DON'T assumes lifetime control for any registered tests + * anymore. + * + * The <em>default</em> registry is the registry returned by getRegistry() with the  + * default name parameter value. + * + * To register tests, use the macros: + * - CPPUNIT_TEST_SUITE_REGISTRATION(): to add tests in the default registry. + * - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(): to add tests in a named registry. + * + * Example 1: retreiving a suite that contains all the test registered with + * CPPUNIT_TEST_SUITE_REGISTRATION(). + * \code + * CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); + * CppUnit::TestSuite *suite = registry.makeTest(); + * \endcode + * + * Example 2: retreiving a suite that contains all the test registered with + * \link CPPUNIT_TEST_SUITE_NAMED_REGISTRATION() CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ..., "Math" )\endlink. + * \code + * CppUnit::TestFactoryRegistry &mathRegistry = CppUnit::TestFactoryRegistry::getRegistry( "Math" ); + * CppUnit::TestSuite *mathSuite = mathRegistry.makeTest(); + * \endcode + * + * Example 3: creating a test suite hierarchy composed of unnamed registration and + * named registration: + * - All Tests + *   - tests registered with CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ..., "Graph" ) + *   - tests registered with CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ..., "Math" ) + *   - tests registered with CPPUNIT_TEST_SUITE_REGISTRATION + * + * \code + * CppUnit::TestSuite *rootSuite = new CppUnit::TestSuite( "All tests" ); + * rootSuite->addTest( CppUnit::TestFactoryRegistry::getRegistry( "Graph" ).makeTest() ); + * rootSuite->addTest( CppUnit::TestFactoryRegistry::getRegistry( "Math" ).makeTest() ); + * CppUnit::TestFactoryRegistry::getRegistry().addTestToSuite( rootSuite ); + * \endcode + * + * The same result can be obtained with: + * \code + * CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); + * registry.addRegistry( "Graph" ); + * registry.addRegistry( "Math" ); + * CppUnit::TestSuite *suite = registry.makeTest(); + * \endcode + * + * Since a TestFactoryRegistry is a TestFactory, the named registries can be  + * registered in the unnamed registry, creating the hierarchy links. + * + * \see TestSuiteFactory, AutoRegisterSuite + * \see CPPUNIT_TEST_SUITE_REGISTRATION, CPPUNIT_TEST_SUITE_NAMED_REGISTRATION + */ +class CPPUNIT_API TestFactoryRegistry : public TestFactory +{ +public: +  /** Constructs the registry with the specified name. +   * \param name Name of the registry. It is the name of TestSuite returned by +   *             makeTest(). +   */ +  TestFactoryRegistry( std::string name ); + +  /// Destructor. +  virtual ~TestFactoryRegistry(); + +  /** Returns a new TestSuite that contains the registered test. +   * \return A new TestSuite which contains all the test added using  +   * registerFactory(TestFactory *). +   */ +  virtual Test *makeTest(); + +  /** Returns a named registry. +   * +   * If the \a name is left to its default value, then the registry that is returned is +   * the one used by CPPUNIT_TEST_SUITE_REGISTRATION(): the 'top' level registry. +   * +   * \param name Name of the registry to return. +   * \return Registry. If the registry does not exist, it is created with the +   *         specified name. +   */ +  static TestFactoryRegistry &getRegistry( const std::string &name = "All Tests" ); + +  /** Adds the registered tests to the specified suite. +   * \param suite Suite the tests are added to. +   */ +  void addTestToSuite( TestSuite *suite ); + +  /** Adds the specified TestFactory to the registry. +   * +   * \param factory Factory to register.  +   */ +  void registerFactory( TestFactory *factory ); + +  /*! Removes the specified TestFactory from the registry. +   *  +   * The specified factory is not destroyed. +   * \param factory Factory to remove from the registry. +   * \todo Address case when trying to remove a TestRegistryFactory. +   */ +  void unregisterFactory( TestFactory *factory ); + +  /*! Adds a registry to the registry. +   *  +   * Convenience method to help create test hierarchy. See TestFactoryRegistry detail +   * for examples of use. Calling this method is equivalent to: +   * \code +   * this->registerFactory( TestFactoryRegistry::getRegistry( name ) ); +   * \endcode +   * +   * \param name Name of the registry to add. +   */ +  void addRegistry( const std::string &name ); + +  /*! Tests if the registry is valid. +   * +   * This method should be used when unregistering test factory on static variable  +   * destruction to ensure that the registry has not been already destroyed (in  +   * that case there is no need to unregister the test factory). +   * +   * You should not concern yourself with this method unless you are writing a class +   * like AutoRegisterSuite. +   * +   * \return \c true if the specified registry has not been destroyed,  +   *         otherwise returns \c false. +   * \see AutoRegisterSuite. +   */ +  static bool isValid(); + +  /** Adds the specified TestFactory with a specific name (DEPRECATED). +   * \param name Name associated to the factory. +   * \param factory Factory to register.  +   * \deprecated Use registerFactory( TestFactory *) instead. +   */ +  void registerFactory( const std::string &name, +                        TestFactory *factory ); + +private: +  TestFactoryRegistry( const TestFactoryRegistry © ); +  void operator =( const TestFactoryRegistry © ); + +private: +  typedef CppUnitSet<TestFactory *, std::less<TestFactory*> > Factories; +  Factories m_factories; + +  std::string m_name; +}; + + +CPPUNIT_NS_END + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( pop ) +#endif + + +#endif  // CPPUNIT_EXTENSIONS_TESTFACTORYREGISTRY_H diff --git a/3rdParty/CppUnit/src/include/cppunit/extensions/TestFixtureFactory.h b/3rdParty/CppUnit/src/include/cppunit/extensions/TestFixtureFactory.h new file mode 100644 index 0000000..45354c6 --- /dev/null +++ b/3rdParty/CppUnit/src/include/cppunit/extensions/TestFixtureFactory.h @@ -0,0 +1,50 @@ +#ifndef CPPUNIT_EXTENSIONS_TESTFIXTUREFACTORY_H +#define CPPUNIT_EXTENSIONS_TESTFIXTUREFACTORY_H + +#include <cppunit/Portability.h> + + +CPPUNIT_NS_BEGIN + + +class TestFixture; + +/*! \brief Abstract TestFixture factory (Implementation). + * + * Implementation detail. Use by HelperMacros to handle TestFixture hierarchy. + */ +class TestFixtureFactory +{ +public: +  //! Creates a new TestFixture instance. +  virtual TestFixture *makeFixture() =0; + +  virtual ~TestFixtureFactory() {} +}; + + +/*! \brief Concret TestFixture factory (Implementation). + * + * Implementation detail. Use by HelperMacros to handle TestFixture hierarchy. + */ +template<class TestFixtureType> +class ConcretTestFixtureFactory : public CPPUNIT_NS::TestFixtureFactory +{ +  /*! \brief Returns a new TestFixture instance. +   * \return A new fixture instance. The fixture instance is returned by +   *         the TestFixtureFactory passed on construction. The actual type  +   *         is that of the fixture on which the static method suite()  +   *         was called. +   */ +  TestFixture *makeFixture() +  { +    return new TestFixtureType(); +  } +}; + + +CPPUNIT_NS_END + + +#endif // CPPUNIT_EXTENSIONS_TESTFIXTUREFACTORY_H + diff --git a/3rdParty/CppUnit/src/include/cppunit/extensions/TestNamer.h b/3rdParty/CppUnit/src/include/cppunit/extensions/TestNamer.h new file mode 100644 index 0000000..5a6471c --- /dev/null +++ b/3rdParty/CppUnit/src/include/cppunit/extensions/TestNamer.h @@ -0,0 +1,89 @@ +#ifndef CPPUNIT_EXTENSIONS_TESTNAMER_H +#define CPPUNIT_EXTENSIONS_TESTNAMER_H + +#include <cppunit/Portability.h> +#include <string> + +#if CPPUNIT_HAVE_RTTI +#  include <typeinfo> +#endif + + + +/*! \def CPPUNIT_TESTNAMER_DECL( variableName, FixtureType ) + * \brief Declares a TestNamer. + * + * Declares a TestNamer for the specified type, using RTTI if enabled, otherwise + * using macro string expansion. + * + * RTTI is used if CPPUNIT_USE_TYPEINFO_NAME is defined and not null. + * + * \code + * void someMethod()  + * { + *   CPPUNIT_TESTNAMER_DECL( namer, AFixtureType ); + *   std::string fixtureName = namer.getFixtureName(); + *   ... + * \endcode + * + * \relates TestNamer + * \see TestNamer + */ +#if CPPUNIT_USE_TYPEINFO_NAME +#  define CPPUNIT_TESTNAMER_DECL( variableName, FixtureType )       \ +              CPPUNIT_NS::TestNamer variableName( typeid(FixtureType) ) +#else +#  define CPPUNIT_TESTNAMER_DECL( variableName, FixtureType )       \ +              CPPUNIT_NS::TestNamer variableName( std::string(#FixtureType) ) +#endif + + + +CPPUNIT_NS_BEGIN + + +/*! \brief Names a test or a fixture suite. + * + * TestNamer is usually instantiated using CPPUNIT_TESTNAMER_DECL. + * + */ +class CPPUNIT_API TestNamer +{ +public: +#if CPPUNIT_HAVE_RTTI +  /*! \brief Constructs a namer using the fixture's type-info. +   * \param typeInfo Type-info of the fixture type. Use to name the fixture suite. +   */ +  TestNamer( const std::type_info &typeInfo ); +#endif + +  /*! \brief Constructs a namer using the specified fixture name. +   * \param fixtureName Name of the fixture suite. Usually extracted using a macro. +   */ +  TestNamer( const std::string &fixtureName ); + +  virtual ~TestNamer(); + +  /*! \brief Returns the name of the fixture. +   * \return Name of the fixture. +   */ +  virtual std::string getFixtureName() const; + +  /*! \brief Returns the name of the test for the specified method. +   * \param testMethodName Name of the method that implements a test. +   * \return A string that is the concatenation of the test fixture name  +   *         (returned by getFixtureName()) and\a testMethodName,  +   *         separated using '::'. This provides a fairly unique name for a given +   *         test. +   */ +  virtual std::string getTestNameFor( const std::string &testMethodName ) const; + +protected: +  std::string m_fixtureName; +}; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_EXTENSIONS_TESTNAMER_H + diff --git a/3rdParty/CppUnit/src/include/cppunit/extensions/TestSuiteBuilderContext.h b/3rdParty/CppUnit/src/include/cppunit/extensions/TestSuiteBuilderContext.h new file mode 100644 index 0000000..db26926 --- /dev/null +++ b/3rdParty/CppUnit/src/include/cppunit/extensions/TestSuiteBuilderContext.h @@ -0,0 +1,131 @@ +#ifndef CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H +#define CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H + +#include <cppunit/Portability.h> +#include <cppunit/portability/CppUnitMap.h> +#include <string> + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( push ) +#pragma warning( disable: 4251 )  // X needs to have dll-interface to be used by clients of class Z +#endif + + +CPPUNIT_NS_BEGIN + +class TestSuite; +class TestFixture; +class TestFixtureFactory; +class TestNamer; + +/*! \brief Context used when creating test suite in HelperMacros. + * + * Base class for all context used when creating test suite. The + * actual context type during test suite creation is TestSuiteBuilderContext. + * + * \sa CPPUNIT_TEST_SUITE, CPPUNIT_TEST_SUITE_ADD_TEST,  + *     CPPUNIT_TEST_SUITE_ADD_CUSTOM_TESTS. + */ +class CPPUNIT_API TestSuiteBuilderContextBase +{ +public: +  /*! \brief Constructs a new context. +   * +   * You should not use this. The context is created in  +   * CPPUNIT_TEST_SUITE(). +   */ +  TestSuiteBuilderContextBase( TestSuite &suite, +                               const TestNamer &namer, +                               TestFixtureFactory &factory ); + +  virtual ~TestSuiteBuilderContextBase(); + +  /*! \brief Adds a test to the fixture suite. +   * +   * \param test Test to add to the fixture suite. Must not be \c NULL. +   */ +  void addTest( Test *test ); + +  /*! \brief Returns the fixture name. +   * \return Fixture name. It is the name used to name the fixture +   *         suite. +   */ +  std::string getFixtureName() const; + +  /*! \brief Returns the name of the test for the specified method. +   * +   * \param testMethodName Name of the method that implements a test. +   * \return A string that is the concatenation of the test fixture name  +   *         (returned by getFixtureName()) and\a testMethodName,  +   *         separated using '::'. This provides a fairly unique name for a given +   *         test. +   */ +  std::string getTestNameFor( const std::string &testMethodName ) const; + +  /*! \brief Adds property pair. +   * \param key   PropertyKey string to add. +   * \param value PropertyValue string to add. +   */ +  void addProperty( const std::string &key,  +                    const std::string &value ); +   +  /*! \brief Returns property value assigned to param key. +   * \param key PropertyKey string. +   */ +  const std::string getStringProperty( const std::string &key ) const; + +protected: +  TestFixture *makeTestFixture() const; + +  // Notes: we use a vector here instead of a map to work-around the +  // shared std::map in dll bug in VC6. +  // See http://www.dinkumware.com/vc_fixes.html for detail. +  typedef std::pair<std::string,std::string> Property; +  typedef CppUnitVector<Property> Properties; + +  TestSuite &m_suite; +  const TestNamer &m_namer; +  TestFixtureFactory &m_factory; + +private: +  Properties m_properties; +}; + + +/*! \brief Type-sage context used when creating test suite in HelperMacros. + *  + * \sa TestSuiteBuilderContextBase. + */ +template<class Fixture> +class TestSuiteBuilderContext : public TestSuiteBuilderContextBase +{ +public: +  typedef Fixture FixtureType; + +  TestSuiteBuilderContext( TestSuiteBuilderContextBase &contextBase ) +      : TestSuiteBuilderContextBase( contextBase ) +  { +  } + +  /*! \brief Returns a new TestFixture instance. +   * \return A new fixture instance. The fixture instance is returned by +   *         the TestFixtureFactory passed on construction. The actual type  +   *         is that of the fixture on which the static method suite()  +   *         was called. +   */ +  FixtureType *makeFixture() const +  { +    return CPPUNIT_STATIC_CAST( FixtureType *,  +                                TestSuiteBuilderContextBase::makeTestFixture() ); +  } +}; + + +CPPUNIT_NS_END + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( pop ) +#endif + +#endif // CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H + diff --git a/3rdParty/CppUnit/src/include/cppunit/extensions/TestSuiteFactory.h b/3rdParty/CppUnit/src/include/cppunit/extensions/TestSuiteFactory.h new file mode 100644 index 0000000..260b483 --- /dev/null +++ b/3rdParty/CppUnit/src/include/cppunit/extensions/TestSuiteFactory.h @@ -0,0 +1,27 @@ +#ifndef CPPUNIT_EXTENSIONS_TESTSUITEFACTORY_H +#define CPPUNIT_EXTENSIONS_TESTSUITEFACTORY_H + +#include <cppunit/extensions/TestFactory.h> + +CPPUNIT_NS_BEGIN + + +  class Test; + +  /*! \brief TestFactory for TestFixture that implements a static suite() method. +   * \see AutoRegisterSuite. +   */ +  template<class TestCaseType> +  class TestSuiteFactory : public TestFactory +  { +  public: +    virtual Test *makeTest() +    { +      return TestCaseType::suite(); +    } +  }; + + +CPPUNIT_NS_END + +#endif  // CPPUNIT_EXTENSIONS_TESTSUITEFACTORY_H diff --git a/3rdParty/CppUnit/src/include/cppunit/extensions/TypeInfoHelper.h b/3rdParty/CppUnit/src/include/cppunit/extensions/TypeInfoHelper.h new file mode 100644 index 0000000..c0ecdbc --- /dev/null +++ b/3rdParty/CppUnit/src/include/cppunit/extensions/TypeInfoHelper.h @@ -0,0 +1,33 @@ +#ifndef CPPUNIT_TYPEINFOHELPER_H +#define CPPUNIT_TYPEINFOHELPER_H + +#include <cppunit/Portability.h> + +#if CPPUNIT_HAVE_RTTI + +#include <typeinfo> +#include <string> + +CPPUNIT_NS_BEGIN + + +  /**! \brief Helper to use type_info. +   */ +  class CPPUNIT_API TypeInfoHelper +  { +  public: +    /*! \brief Get the class name of the specified type_info. +     * \param info Info which the class name is extracted from. +     * \return The string returned by type_info::name() without +     *         the "class" prefix. If the name is not prefixed +     *         by "class", it is returned as this. +     */ +    static std::string getClassName( const std::type_info &info ); +  }; + + +CPPUNIT_NS_END + +#endif  // CPPUNIT_HAVE_RTTI + +#endif  // CPPUNIT_TYPEINFOHELPER_H  | 
 Swift