diff options
Diffstat (limited to 'cppunit/inc')
61 files changed, 5196 insertions, 0 deletions
diff --git a/cppunit/inc/cppunit/Asserter.h b/cppunit/inc/cppunit/Asserter.h new file mode 100644 index 000000000000..0ba94eb59d76 --- /dev/null +++ b/cppunit/inc/cppunit/Asserter.h @@ -0,0 +1,106 @@ +#ifndef CPPUNIT_ASSERTER_H +#define CPPUNIT_ASSERTER_H + +#include <cppunit/Portability.h> +#include <cppunit/SourceLine.h> +#include <string> +#include <rtl/ustring.hxx> + +namespace CppUnit +{ + +/*! \brief A set of functions to help writing assertion macros. + * \ingroup CreatingNewAssertions + * + * Here is an example of assertion, a simplified version of the + * actual assertion implemented in examples/cppunittest/XmlUniformiser.h: + * \code + * #include <cppunit/SourceLine.h> + * #include <cppunit/TestAssert.h> + * + * void + * checkXmlEqual( std::string expectedXml, + * std::string actualXml, + * CppUnit::SourceLine sourceLine ) + * { + * std::string expected = XmlUniformiser( expectedXml ).stripped(); + * std::string actual = XmlUniformiser( actualXml ).stripped(); + * + * if ( expected == actual ) + * return; + * + * ::CppUnit::Asserter::failNotEqual( expected, + * actual, + * sourceLine ); + * } + * + * /// Asserts that two XML strings are equivalent. + * #define CPPUNITTEST_ASSERT_XML_EQUAL( expected, actual ) \ + * checkXmlEqual( expected, actual, \ + * CPPUNIT_SOURCELINE() ) + * \endcode + */ +namespace Asserter +{ + + /*! Throws a Exception with the specified message and location. + */ + void CPPUNIT_API fail( std::string const& message, + SourceLine const& sourceLine = SourceLine() ); + + /*! Throws a Exception with the specified message and location. + * \param shouldFail if \c true then the exception is thrown. Otherwise + * nothing happen. + * \param message Message explaining the assertion failiure. + * \param sourceLine Location of the assertion. + */ + void CPPUNIT_API failIf( bool shouldFail, + std::string const& message, + SourceLine const& sourceLine = SourceLine() ); + + + // LLA: test, if it's possible to use a DEFINE twice ;-) + void CPPUNIT_API failIf( bool shouldFail, + rtl::OUString const& message, + SourceLine const& sourceLine = SourceLine() ); + + /*! Throws a NotEqualException with the specified message and location. + * \param expected Text describing the expected value. + * \param actual Text describing the actual value. + * \param additionalMessage Additional message. Usually used to report + * where the "difference" is located. + * \param sourceLine Location of the assertion. + */ + void CPPUNIT_API failNotEqual( std::string const& expected, + std::string const& actual, + SourceLine const& sourceLine = SourceLine(), + std::string const& additionalMessage ="" ); + + /*! Throws a NotEqualException with the specified message and location. + * \param shouldFail if \c true then the exception is thrown. Otherwise + * nothing happen. + * \param expected Text describing the expected value. + * \param actual Text describing the actual value. + * \param additionalMessage Additional message. Usually used to report + * where the "difference" is located. + * \param sourceLine Location of the assertion. + */ + void CPPUNIT_API failNotEqualIf( bool shouldFail, + std::string const& expected, + std::string const& actual, + SourceLine const& sourceLine = SourceLine(), + std::string const& additionalMessage ="" ); + + + /*! Throws an Exception with the specified message and location. + * \param message Message explaining the assertion failure. + * \param sourceLine Location of the assertion. + */ + void CPPUNIT_API failStub( std::string const& message, + SourceLine const& sourceLine = SourceLine() ); + +} // namespace Asserter +} // namespace CppUnit + + +#endif // CPPUNIT_ASSERTER_H diff --git a/cppunit/inc/cppunit/Exception.h b/cppunit/inc/cppunit/Exception.h new file mode 100644 index 000000000000..98839e0846fa --- /dev/null +++ b/cppunit/inc/cppunit/Exception.h @@ -0,0 +1,116 @@ +#ifndef CPPUNIT_EXCEPTION_H +#define CPPUNIT_EXCEPTION_H + +#include <cppunit/Portability.h> +#include <cppunit/SourceLine.h> +#include <exception> +#include <string> + +namespace CppUnit { + +/*! \brief Exceptions thrown by failed assertions. + * \ingroup BrowsingCollectedTestResult + * + * Exception is an exception that serves + * descriptive strings through its what() method + */ +class CPPUNIT_API Exception : public std::exception +{ +public: + + class Type + { + public: + Type( std::string const& _type ) : m_type ( _type ) {} + + bool operator ==( const Type &other ) const + { + return m_type == other.m_type; + } + private: + const std::string m_type; + }; + + + Exception( std::string const& message = "", + SourceLine const& sourceLine = SourceLine() ); + +#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED + Exception( std::string const& message, + long lineNumber, + std::string const& fileName ); +#endif + + Exception (const Exception& other); + + virtual ~Exception () throw(); + + Exception& operator= (const Exception& other); + + const char *what() const throw (); + + SourceLine sourceLine() const; + +#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED + long lineNumber() const; + std::string fileName() const; + + static const std::string UNKNOWNFILENAME; + static const long UNKNOWNLINENUMBER; +#endif + + virtual Exception *clone() const; + + virtual bool isInstanceOf( const Type &type ) const; + + static Type type(); + +private: + // VC++ does not recognize call to parent class when prefixed + // with a namespace. This is a workaround. + typedef std::exception SuperClass; + + std::string m_message; + SourceLine m_sourceLine; +}; + +// ----------------------------------------------------------------------------- + +class StubException : public Exception +{ +public: + StubException( std::string const& _message = "", + SourceLine const& _sourceLine = SourceLine() ) + :Exception(_message, _sourceLine) {} + + +#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED + StubException( std::string const& message, + long lineNumber, + std::string const& fileName ) + :Exception(message, lineNumber, fileName) {} +#endif +}; + +// ----------------------------------------------------------------------------- + +class SignalException : public Exception +{ +public: + SignalException( std::string const& _message = "", + SourceLine const& _sourceLine = SourceLine() ) + :Exception(_message, _sourceLine) {} + + +#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED + SignalException( std::string const& message, + long lineNumber, + std::string const& fileName ) + :Exception(message, lineNumber, fileName) {} +#endif +}; + +} // namespace CppUnit + +#endif // CPPUNIT_EXCEPTION_H + diff --git a/cppunit/inc/cppunit/NotEqualException.h b/cppunit/inc/cppunit/NotEqualException.h new file mode 100644 index 000000000000..18748fb82142 --- /dev/null +++ b/cppunit/inc/cppunit/NotEqualException.h @@ -0,0 +1,65 @@ +#ifndef NOTEQUALEXCEPTION_H +#define NOTEQUALEXCEPTION_H + +#include <cppunit/Exception.h> + + +namespace CppUnit { + +/*! \brief Exception thrown by failed equality assertions. + * \ingroup BrowsingCollectedTestResult + */ +class CPPUNIT_API NotEqualException : public Exception +{ +public: + /*! Constructs the exception. + * \param expected Text that represents the expected value. + * \param actual Text that represents the actual value. + * \param sourceLine Location of the assertion. + * \param additionalMessage Additionnal information provided to further qualify + * the inequality. + */ + NotEqualException( std::string const& expected, + std::string const& actual, + SourceLine const& sourceLine = SourceLine(), + std::string const& additionalMessage = "" ); + +#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED + NotEqualException( std::string const& expected, + std::string const& actual, + long lineNumber, + std::string const& fileName ); +#endif + + NotEqualException( const NotEqualException &other ); + + + virtual ~NotEqualException() throw(); + + std::string expectedValue() const; + + std::string actualValue() const; + + std::string additionalMessage() const; + + /*! Copy operator. + * @param other Object to copy. + * @return Reference on this object. + */ + NotEqualException &operator =( const NotEqualException &other ); + + Exception *clone() const; + + bool isInstanceOf( const Type &type ) const; + + static Type type(); + +private: + std::string m_expected; + std::string m_actual; + std::string m_additionalMessage; +}; + +} // namespace CppUnit + +#endif // NOTEQUALEXCEPTION_H diff --git a/cppunit/inc/cppunit/Portability.h b/cppunit/inc/cppunit/Portability.h new file mode 100644 index 000000000000..b81900e9a7df --- /dev/null +++ b/cppunit/inc/cppunit/Portability.h @@ -0,0 +1,85 @@ +#ifndef CPPUNIT_PORTABILITY_H +#define CPPUNIT_PORTABILITY_H + +/* include platform specific config */ +#if defined(__BORLANDC__) +# include <cppunit/portability/config-bcb5.h> +#elif defined (_MSC_VER) +# include <cppunit/portability/config-msvc6.h> +#else +# include <cppunit/portability/config-auto.h> +#endif + + +/* Options that the library user may switch on or off. + * If the user has not done so, we chose default values. + */ + + +/* Define to 1 if you wish to have the old-style macros + assert(), assertEqual(), assertDoublesEqual(), and assertLongsEqual() */ +#ifndef CPPUNIT_ENABLE_NAKED_ASSERT +#define CPPUNIT_ENABLE_NAKED_ASSERT 0 +#endif + +/* Define to 1 if you wish to have the old-style CU_TEST family + of macros. */ +#ifndef CPPUNIT_ENABLE_CU_TEST_MACROS +#define CPPUNIT_ENABLE_CU_TEST_MACROS 0 +#endif + +/* Define to 1 if the preprocessor expands (#foo) to "foo" (quotes incl.) + I don't think there is any C preprocess that does NOT support this! */ +#ifndef CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION +#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 */ + + +/* Define CPPUNIT_SSTREAM as a stream with a "std::string str()" + * method. + */ +#if CPPUNIT_HAVE_SSTREAM +# include <sstream> + namespace CppUnit { + class OStringStream : public std::ostringstream + { + }; + } +#else +#if CPPUNIT_HAVE_CLASS_STRSTREAM +# include <string> +# if CPPUNIT_HAVE_STRSTREAM +# include <strstream> +# else +# include <strstream.h> +# endif + + namespace CppUnit { + class OStringStream : public std::ostrstream + { + public: + std::string str() + { + (*this) << '\0'; + std::string msg(std::ostrstream::str()); + std::ostrstream::freeze(false); + return msg; + } + }; + } +#else +# error Cannot define CppUnit::OStringStream. +#endif +#endif + +#endif // CPPUNIT_PORTABILITY_H diff --git a/cppunit/inc/cppunit/SourceLine.h b/cppunit/inc/cppunit/SourceLine.h new file mode 100644 index 000000000000..48b87f236cf3 --- /dev/null +++ b/cppunit/inc/cppunit/SourceLine.h @@ -0,0 +1,60 @@ +#ifndef CPPUNIT_SOURCELINE_H +#define CPPUNIT_SOURCELINE_H + +#include <cppunit/Portability.h> +#include <string> + +/*! \brief Constructs a SourceLine object initialized with the location where the macro is expanded. + * \ingroup CreatingNewAssertions + * \relates CppUnit::SourceLine + * Used to write your own assertion macros. + * \see Asserter for example of usage. + */ +#define CPPUNIT_SOURCELINE() ::CppUnit::SourceLine( __FILE__, __LINE__ ) + + +namespace CppUnit +{ + +/*! \brief Represents a source line location. + * \ingroup CreatingNewAssertions + * \ingroup BrowsingCollectedTestResult + * + * Used to capture the failure location in assertion. + * + * Use the CPPUNIT_SOURCELINE() macro to construct that object. Typically used when + * writing an assertion macro in association with Asserter. + * + * \see Asserter. + */ +class CPPUNIT_API SourceLine +{ +public: + SourceLine(); + + SourceLine( const std::string &fileName, + int lineNumber ); + + /// Destructor. + virtual ~SourceLine(); + + bool isValid() const; + + int lineNumber() const; + + std::string fileName() const; + + bool operator ==( const SourceLine &other ) const; + bool operator !=( const SourceLine &other ) const; + +private: + std::string m_fileName; + int m_lineNumber; +}; + + +} // namespace CppUnit + + + +#endif // CPPUNIT_SOURCELINE_H diff --git a/cppunit/inc/cppunit/Test.h b/cppunit/inc/cppunit/Test.h new file mode 100644 index 000000000000..1e7beb39afe7 --- /dev/null +++ b/cppunit/inc/cppunit/Test.h @@ -0,0 +1,64 @@ +#ifndef CPPUNIT_TEST_H +#define CPPUNIT_TEST_H + +#include <cppunit/Portability.h> +#include <string> +#include <cppunit/autoregister/htestresult.h> + +namespace CppUnit { + +//# class TestResult; + +/*! \brief Base class for all test objects. + * \ingroup BrowsingCollectedTestResult + *l- + * All test objects should be a subclass of Test. Some test objects, + * TestCase for example, represent one individual test. Other test + * objects, such as TestSuite, are comprised of several tests. + * + * When a Test is run, the result is collected by a TestResult object. + * + * \see TestCase + * \see TestSuite + */ +class CPPUNIT_API Test +{ +public: + virtual ~Test () {}; + + /*! \brief Run the test, collecting results. + */ + virtual void run (hTestResult pResult) = 0; + + /*! \brief Return the number of test cases invoked by run(). + * + * The base unit of testing is the class TestCase. This + * method returns the number of TestCase objects invoked by + * the run() method. + */ + virtual int countTestCases () const = 0; + + /*! \brief Returns the test name. + * + * Each test has a name. This name may be used to find the + * test in a suite or registry of tests. + */ + virtual std::string getName () const = 0; + + /*! \brief Description of the test, for diagnostic output. + * + * The test description will typically include the test name, + * but may have additional description. For example, a test + * suite named <tt>complex_add</tt> may be described as + * <tt>suite complex_add</tt>. + */ + virtual std::string toString () const = 0; + + +}; + + +} // namespace CppUnit + +#endif // CPPUNIT_TEST_H + diff --git a/cppunit/inc/cppunit/TestAssert.h b/cppunit/inc/cppunit/TestAssert.h new file mode 100644 index 000000000000..d2f4c31ce190 --- /dev/null +++ b/cppunit/inc/cppunit/TestAssert.h @@ -0,0 +1,246 @@ +#ifndef CPPUNIT_TESTASSERT_H +#define CPPUNIT_TESTASSERT_H + +#include <cppunit/Portability.h> +#include <cppunit/Exception.h> +#include <cppunit/Asserter.h> + +#include <cppunit/checkboom.hxx> + +namespace CppUnit { + + + + /*! \brief Traits used by CPPUNIT_ASSERT_EQUAL(). + * + * Here is an example of specialization of that traits: + * + * \code + * template<> + * struct assertion_traits<std::string> // specialization for the std::string type + * { + * static bool equal( const std::string& x, const std::string& y ) + * { + * return x == y; + * } + * + * static std::string toString( const std::string& x ) + * { + * std::string text = '"' + x + '"'; // adds quote around the string to see whitespace + * OStringStream ost; + * ost << text; + * return ost.str(); + * } + * }; + * \endcode + */ + + +template <class T> +struct assertion_traits +{ + static bool equal( const T& x, const T& y ) + { + return x == y; + } + + static std::string toString( const T& x ) + { + OStringStream ost; + ost << x; + return ost.str(); + } +}; + +namespace TestAssert +{ +#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED + 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> + void assertEquals( const T& expected, + const T& actual, + long lineNumber, + std::string fileName ) + { + if ( !assertion_traits<T>::equal(expected,actual) ) // lazy toString conversion... + { + assertNotEqualImplementation( assertion_traits<T>::toString(expected), + assertion_traits<T>::toString(actual), + lineNumber, + fileName ); + } + } + + void CPPUNIT_API assertEquals( double expected, + double actual, + double delta, + long lineNumber, + std::string fileName ); + +#else // using SourceLine + + template <class T> + void assertEquals( const T& expected, + const T& actual, + SourceLine sourceLine, + const std::string &message ="" ) + { + if ( !assertion_traits<T>::equal(expected,actual) ) // lazy toString conversion... + { + Asserter::failNotEqual( assertion_traits<T>::toString(expected), + assertion_traits<T>::toString(actual), + sourceLine, + message ); + } + } + + void CPPUNIT_API assertDoubleEquals( double expected, + double actual, + double delta, + SourceLine sourceLine ); + +#endif +} + +/* A set of macros which allow us to get the line number + * and file name at the point of an error. + * Just goes to show that preprocessors do have some + * redeeming qualities. + */ +#if CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION +/** Assertions that a condition is \c true. + * \ingroup Assertions + */ + // LLA: due to the fact, that side effects are not wished, we create a local scope, + // assign the condition to a local variable and check this variable again and again. + +#define CPPUNIT_ASSERT(condition) \ + { bool __bLocalCondition = condition; \ + CheckBoom((__bLocalCondition), (#condition)); \ + (::CppUnit::Asserter::failIf( !(__bLocalCondition), \ + (#condition), \ + CPPUNIT_SOURCELINE() ) ); } +#else +#define CPPUNIT_ASSERT(condition) \ + { bool __bLocalCondition = condition; \ + CheckBoom((__bLocalCondition), ""); \ + (::CppUnit::Asserter::failIf( !(__bLocalCondition), \ + "", \ + CPPUNIT_SOURCELINE() ) ); } +#endif + +/** Assertion with a user specified message. + * \ingroup Assertions + * \param message Message reported in diagnostic if \a condition evaluates + * to \c false. + * \param condition If this condition evaluates to \c false then the + * test failed. + */ +#define CPPUNIT_ASSERT_MESSAGE(message,condition) \ + { bool __bLocalCondition = (condition); \ + CheckBoom((__bLocalCondition), (message)); \ + (::CppUnit::Asserter::failIf( !(__bLocalCondition), \ + (message), \ + CPPUNIT_SOURCELINE() ) ); } + +#define CPPUNIT_ASSERT_STUB() \ + CheckBoom((1 == 0), ("This is only a stub.")); \ + (::CppUnit::Asserter::failStub("This is only a stub.", \ + CPPUNIT_SOURCELINE() ) ) + + +/** Fails with the specified message. + * \ingroup Assertions + * \param message Message reported in diagnostic. + */ +#define CPPUNIT_FAIL( message ) \ + ( ::CppUnit::Asserter::fail( message, \ + CPPUNIT_SOURCELINE() ) ) + +#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED +/// Generalized macro for primitive value comparisons +#define CPPUNIT_ASSERT_EQUAL(expected,actual) \ + ( ::CppUnit::TestAssert::assertEquals( (expected), \ + (actual), \ + __LINE__, __FILE__ ) ) +#else +/** Asserts that two values are equals. + * \ingroup Assertions + * + * Equality and string representation can be defined with + * an appropriate CppUnit::assertion_traits class. + * + * A diagnostic is printed if actual and expected values disagree. + * + * Requirement for \a expected and \a actual parameters: + * - They are exactly of the same type + * - They are serializable into a std::strstream using operator <<. + * - They can be compared using operator ==. + * + * The last two requirements (serialization and comparison) can be + * removed by specializing the CppUnit::assertion_traits. + */ +#define CPPUNIT_ASSERT_EQUAL(expected,actual) \ + ( ::CppUnit::TestAssert::assertEquals( (expected), \ + (actual), \ + CPPUNIT_SOURCELINE() ) ) + +/** Asserts that two values are equals, provides additional messafe on failure. + * \ingroup Assertions + * + * Equality and string representation can be defined with + * an appropriate assertion_traits class. + * + * A diagnostic is printed if actual and expected values disagree. + * The message is printed in addition to the expected and actual value + * to provide additional information. + * + * Requirement for \a expected and \a actual parameters: + * - They are exactly of the same type + * - They are serializable into a std::strstream using operator <<. + * - They can be compared using operator ==. + * + * The last two requirements (serialization and comparison) can be + * removed by specializing the CppUnit::assertion_traits. + */ +#define CPPUNIT_ASSERT_EQUAL_MESSAGE(message,expected,actual) \ + ( ::CppUnit::TestAssert::assertEquals( (expected), \ + (actual), \ + CPPUNIT_SOURCELINE(), \ + (message) ) ) +#endif + +/*! \brief Macro for primitive value comparisons + * \ingroup Assertions + */ +#define CPPUNIT_ASSERT_DOUBLES_EQUAL(expected,actual,delta) \ + ( ::CppUnit::TestAssert::assertDoubleEquals( (expected), \ + (actual), \ + (delta), \ + CPPUNIT_SOURCELINE() ) ) + +// Backwards compatibility + +#if CPPUNIT_ENABLE_NAKED_ASSERT + +#undef assert +#define assert(c) CPPUNIT_ASSERT(c) +#define assertEqual(e,a) CPPUNIT_ASSERT_EQUAL(e,a) +#define assertDoublesEqual(e,a,d) CPPUNIT_ASSERT_DOUBLES_EQUAL(e,a,d) +#define assertLongsEqual(e,a) CPPUNIT_ASSERT_EQUAL(e,a) + +#endif + +} // namespace CppUnit + +#endif // CPPUNIT_TESTASSERT_H diff --git a/cppunit/inc/cppunit/TestCaller.h b/cppunit/inc/cppunit/TestCaller.h new file mode 100644 index 000000000000..77c2743ca66f --- /dev/null +++ b/cppunit/inc/cppunit/TestCaller.h @@ -0,0 +1,204 @@ +#ifndef CPPUNIT_TESTCALLER_H // -*- C++ -*- +#define CPPUNIT_TESTCALLER_H + +#include <cppunit/Exception.h> +#include <cppunit/TestCase.h> + + +#if CPPUNIT_USE_TYPEINFO_NAME +# include <cppunit/extensions/TypeInfoHelper.h> +#endif + + +namespace CppUnit { + +/*! \brief Marker class indicating that no exception is expected by TestCaller. + * This class is an implementation detail. You should never use this class directly. + */ +class CPPUNIT_API NoExceptionExpected +{ +private: + //! Prevent class instantiation. + NoExceptionExpected(); +}; + + +/*! \brief (Implementation) Traits used by TestCaller to expect an exception. + * + * This class is an implementation detail. You should never use this class directly. + */ +template<typename ExceptionType> +struct ExpectedExceptionTraits +{ + static void expectedException() + { +#if CPPUNIT_USE_TYPEINFO_NAME + std::string message( "Expected exception of type " ); + message += TypeInfoHelper::getClassName( typeid( ExceptionType ) ); + message += ", but got none"; +#else + std::string message( "Expected exception but got none" ); +#endif + throw Exception( message ); + } +}; + + +/*! \brief (Implementation) Traits specialization used by TestCaller to + * expect no exception. + * + * This class is an implementation detail. You should never use this class directly. + */ +template<> +struct ExpectedExceptionTraits<NoExceptionExpected> +{ + static void expectedException() + { + } +}; + + + +//*** FIXME: rework this when class Fixture is implemented. ***// + + +/*! \brief Generate a test case from a fixture method. + * \ingroup WritingTestFixture + * + * A test caller provides access to a test case method + * on a test fixture class. Test callers are useful when + * you want to run an individual test or add it to a + * suite. + * Test Callers invoke only one Test (i.e. test method) on one + * Fixture of a TestFixture. + * + * Here is an example: + * \code + * class MathTest : public CppUnit::TestFixture { + * ... + * public: + * void setUp(); + * void tearDown(); + * + * void testAdd(); + * void testSubtract(); + * }; + * + * CppUnit::Test *MathTest::suite() { + * CppUnit::TestSuite *suite = new CppUnit::TestSuite; + * + * suite->addTest( new CppUnit::TestCaller<MathTest>( "testAdd", testAdd ) ); + * return suite; + * } + * \endcode + * + * You can use a TestCaller to bind any test method on a TestFixture + * class, as long as it accepts void and returns void. + * + * \see TestCase + */ + +template <typename Fixture, + typename ExpectedException = NoExceptionExpected> +class TestCaller : public TestCase +{ + typedef void (Fixture::*TestMethod)(); + +public: + /*! + * Constructor for TestCaller. This constructor builds a new Fixture + * instance owned by the TestCaller. + * \param name name of this TestCaller + * \param test the method this TestCaller calls in runTest() + */ + TestCaller( std::string const& name, TestMethod test ) : + TestCase( name ), + m_ownFixture( true ), + m_fixture( new Fixture() ), + m_test( test ) + { + } + + /*! + * Constructor for TestCaller. + * This constructor does not create a new Fixture instance but accepts + * an existing one as parameter. The TestCaller will not own the + * Fixture object. + * \param name name of this TestCaller + * \param test the method this TestCaller calls in runTest() + * \param fixture the Fixture to invoke the test method on. + */ + TestCaller(std::string const& name, TestMethod test, Fixture& fixture) : + TestCase( name ), + m_ownFixture( false ), + m_fixture( &fixture ), + m_test( test ) + { + } + + /*! + * Constructor for TestCaller. + * This constructor does not create a new Fixture instance but accepts + * an existing one as parameter. The TestCaller will own the + * Fixture object and delete it in its destructor. + * \param name name of this TestCaller + * \param test the method this TestCaller calls in runTest() + * \param fixture the Fixture to invoke the test method on. + */ + TestCaller(std::string const& name, TestMethod test, Fixture* fixture) : + TestCase( name ), + m_ownFixture( true ), + m_fixture( fixture ), + m_test( test ) + { + } + + ~TestCaller() + { + if (m_ownFixture) + delete m_fixture; + } + +protected: + void runTest() + { + try { + (m_fixture->*m_test)(); + } + catch ( ExpectedException & ) { + return; + } + + ExpectedExceptionTraits<ExpectedException>::expectedException(); + } + + void setUp() + { + m_fixture->setUp (); + } + + void tearDown() + { + m_fixture->tearDown (); + } + + std::string toString() const + { + return "TestCaller " + getName(); + } + +private: + TestCaller( const TestCaller &other ); + TestCaller &operator =( const TestCaller &other ); + +private: + bool m_ownFixture; + Fixture *m_fixture; + TestMethod m_test; +}; + + + +} // namespace CppUnit + +#endif // CPPUNIT_TESTCALLER_H diff --git a/cppunit/inc/cppunit/TestCase.h b/cppunit/inc/cppunit/TestCase.h new file mode 100644 index 000000000000..0653c07d7f24 --- /dev/null +++ b/cppunit/inc/cppunit/TestCase.h @@ -0,0 +1,59 @@ +#ifndef CPPUNIT_TESTCASE_H +#define CPPUNIT_TESTCASE_H + +#include <cppunit/Portability.h> +#include <cppunit/Test.h> +#include <cppunit/TestFixture.h> +#include <string> +#include <cppunit/autoregister/htestresult.h> + +namespace CppUnit { + +//# class TestResult; + +/*! \brief A single test object. + * + * This class is used to implement a simple test case: define a subclass + * that overrides the runTest method. + * + * You don't usually need to use that class, but TestFixture and TestCaller instead. + * + * You are expected to subclass TestCase is you need to write a class similiar + * to TestCaller. + */ +class CPPUNIT_API TestCase : public Test, + public TestFixture +{ +public: + + TestCase( std::string const& Name ); + //! \internal + TestCase(); + ~TestCase(); + + virtual void run(hTestResult pResult); + virtual int countTestCases() const; + std::string getName() const; + std::string toString() const; + + //! FIXME: what is this for? + //# virtual TestResult *run(); + +protected: + //! FIXME: this should probably be pure virtual. + virtual void runTest(); + + //! Create TestResult for the run(void) method. + //# TestResult *defaultResult(); + +private: + TestCase( const TestCase &other ); + TestCase &operator=( const TestCase &other ); + +private: + const std::string m_name; +}; + +} // namespace CppUnit + +#endif // CPPUNIT_TESTCASE_H diff --git a/cppunit/inc/cppunit/TestFailure.h b/cppunit/inc/cppunit/TestFailure.h new file mode 100644 index 000000000000..d8648177d57c --- /dev/null +++ b/cppunit/inc/cppunit/TestFailure.h @@ -0,0 +1,71 @@ +#ifndef CPPUNIT_TESTFAILURE_H // -*- C++ -*- +#define CPPUNIT_TESTFAILURE_H + +#include <cppunit/Portability.h> +#include <string> + +namespace ErrorType +{ + enum num + { + ET_FAILURE = 1, + ET_ERROR = 2, + ET_SIGNAL = 4 + }; +} + +namespace CppUnit { + +class Exception; +class SourceLine; +class Test; + + +/*! \brief Record of a failed Test execution. + * \ingroup BrowsingCollectedTestResult + * + * A TestFailure collects a failed test together with + * the caught exception. + * + * TestFailure assumes lifetime control for any exception + * passed to it. + */ + +class CPPUNIT_API TestFailure +{ +public: + TestFailure( Test *failedTest, + Exception *thrownException, + ErrorType::num eError ); + + virtual ~TestFailure (); + + virtual Test *failedTest() const; + + virtual Exception *thrownException() const; + + virtual SourceLine sourceLine() const; + + virtual bool isError() const; + virtual ErrorType::num getErrorType() const; + + virtual std::string failedTestName() const; + + virtual std::string toString() const; + + virtual TestFailure *clone() const; + +protected: + Test *m_failedTest; + Exception *m_thrownException; + ErrorType::num m_eError; + +private: + TestFailure( const TestFailure &other ); + TestFailure &operator =( const TestFailure& other ); +}; + + +} // namespace CppUnit + +#endif // CPPUNIT_TESTFAILURE_H diff --git a/cppunit/inc/cppunit/TestFixture.h b/cppunit/inc/cppunit/TestFixture.h new file mode 100644 index 000000000000..edb8320f90c8 --- /dev/null +++ b/cppunit/inc/cppunit/TestFixture.h @@ -0,0 +1,93 @@ +#ifndef CPPUNIT_TESTFIXTURE_H // -*- C++ -*- +#define CPPUNIT_TESTFIXTURE_H + +#include <cppunit/Portability.h> + +namespace CppUnit { + + +/*! \brief Wraps a test case with setUp and tearDown methods. + * \ingroup WritingTestFixture + * + * A TestFixture is used to provide a common environment for a set + * of test cases. + * + * To define a test fixture, do the following: + * - implement a subclass of TestCase + * - the fixture is defined by instance variables + * - initialize the fixture state by overriding setUp + * (i.e. construct the instance variables of the fixture) + * - clean-up after a test by overriding tearDown. + * + * Each test runs in its own fixture so there + * can be no side effects among test runs. + * Here is an example: + * + * \code + * class MathTest : public CppUnit::TestFixture { + * protected: + * int m_value1, m_value2; + * + * public: + * MathTest() {} + * + * void setUp () { + * m_value1 = 2; + * m_value2 = 3; + * } + * } + * \endcode + * + * For each test implement a method which interacts + * with the fixture. Verify the expected results with assertions specified + * by calling CPPUNIT_ASSERT on the expression you want to test: + * + * \code + * public: + * void testAdd () { + * int result = m_value1 + m_value2; + * CPPUNIT_ASSERT( result == 5 ); + * } + * \endcode + * + * Once the methods are defined you can run them. To do this, use + * a TestCaller. + * + * \code + * CppUnit::Test *test = new CppUnit::TestCaller<MathTest>( "testAdd", + * &MathTest::testAdd ); + * test->run(); + * \endcode + * + * + * The tests to be run can be collected into a TestSuite. + * + * \code + * public: + * static CppUnit::TestSuite *MathTest::suite () { + * CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite; + * suiteOfTests->addTest(new CppUnit::TestCaller<MathTest>( + * "testAdd", &MathTest::testAdd)); + * suiteOfTests->addTest(new CppUnit::TestCaller<MathTest>( + * "testDivideByZero", &MathTest::testDivideByZero)); + * return suiteOfTests; + * } + * \endcode + * + */ +class CPPUNIT_API TestFixture +{ +public: + virtual ~TestFixture() {}; + + //! \brief Set up context before running a test. + virtual void setUp() {}; + + //! Clean up after the test run. + virtual void tearDown() {}; +}; + + +} + +#endif diff --git a/cppunit/inc/cppunit/TestSuite.h b/cppunit/inc/cppunit/TestSuite.h new file mode 100644 index 000000000000..1a97e94c42b7 --- /dev/null +++ b/cppunit/inc/cppunit/TestSuite.h @@ -0,0 +1,81 @@ +#ifndef CPPUNIT_TESTSUITE_H // -*- C++ -*- +#define CPPUNIT_TESTSUITE_H + +#include <cppunit/Portability.h> + +#if CPPUNIT_NEED_DLL_DECL +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z +#endif +#endif + +#include <cppunit/Test.h> +#include <vector> +#include <string> +#include <cppunit/autoregister/htestresult.h> + +namespace CppUnit { + +//# class TestResult; + +#if CPPUNIT_NEED_DLL_DECL + template class CPPUNIT_API std::vector<Test *>; +#endif + + +/*! \brief A Composite of Tests. + * \ingroup CreatingTestSuite + * + * It runs a collection of test cases. Here is an example. + * \code + * CppUnit::TestSuite *suite= new CppUnit::TestSuite(); + * suite->addTest(new CppUnit::TestCaller<MathTest> ( + * "testAdd", testAdd)); + * suite->addTest(new CppUnit::TestCaller<MathTest> ( + * "testDivideByZero", testDivideByZero)); + * \endcode + * Note that TestSuites assume lifetime + * control for any tests added to them. + * + * \see Test + * \see TestCaller + */ + + +class CPPUNIT_API TestSuite : public Test +{ +public: + TestSuite( std::string const& name = "" ); + ~TestSuite(); + + void run( hTestResult pResult ); + int countTestCases() const; + std::string getName() const; + std::string toString() const; + + void addTest( Test *test ); + const std::vector<Test *> &getTests() const; + + virtual void deleteContents(); + +private: + TestSuite( const TestSuite &other ); + TestSuite &operator =( const TestSuite &other ); + +private: + std::vector<Test *> m_tests; + const std::string m_name; +}; + + +} // namespace CppUnit + + +#if CPPUNIT_NEED_DLL_DECL +#ifdef _MSC_VER +#pragma warning( pop ) +#endif +#endif + +#endif // CPPUNIT_TESTSUITE_H diff --git a/cppunit/inc/cppunit/additionalfunc.hxx b/cppunit/inc/cppunit/additionalfunc.hxx new file mode 100644 index 000000000000..f34137936c6f --- /dev/null +++ b/cppunit/inc/cppunit/additionalfunc.hxx @@ -0,0 +1,65 @@ +#ifndef ADDITIONALFUNC_HXX +#define ADDITIONALFUNC_HXX + +#ifndef _registertestfunction_h +#include "cppunit/autoregister/registertestfunction.h" +#endif +#ifndef _SAL_TYPES_H_ +#include "sal/types.h" +#endif + +extern "C" void SAL_CALL RegisterAdditionalFunctions(FktRegFuncPtr _pFunc); + +#define NOADDITIONAL \ +void RegisterAdditionalFunctions(FktRegFuncPtr){} + +namespace { + +enum T2_OSType { + T2_OS_WNT32 = 1, + T2_OS_UNIX, + T2_OS_OS2 +}; + +inline T2_OSType getOSType() +{ +#if defined WNT + return T2_OS_WNT32; +#elif defined OS2 + return T2_OS_OS2; +#else + return T2_OS_UNIX; +#endif +} + +} + +#define TESTSHL2_UNO_BOOTSTRAP(file) \ +void RegisterAdditionalFunctions(FktRegFuncPtr _pFunc) \ +{ \ + com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory> xMS; \ + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > xComponentContext; \ + try { \ + if (strlen(#file) > 0) { \ + ::rtl::OUString iniFile(rtl::OUString::createFromAscii(#file)); \ + if (getOSType() == T2_OS_WNT32 || getOSType() == T2_OS_OS2) { \ + iniFile += ::rtl::OUString::createFromAscii(".ini"); \ + } else { \ + iniFile += ::rtl::OUString::createFromAscii("rc"); \ + } \ + xComponentContext = cppu::defaultBootstrap_InitialComponentContext(iniFile); \ + } else { \ + xComponentContext = cppu::defaultBootstrap_InitialComponentContext(); \ + } \ + xMS.set(xComponentContext->getServiceManager(), com::sun::star::uno::UNO_QUERY); \ + comphelper::setProcessServiceFactory(xMS); \ + } \ + catch (::com::sun::star::uno::Exception e ) { \ + rtl::OString aError; \ + aError = rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US); \ + printf("Error at UNO bootstrap time caught: %s\nMust quit.\n", aError.getStr()); \ + exit(1); \ + } \ +} + +#endif diff --git a/cppunit/inc/cppunit/autoregister/callbackfunc_fktptr.h b/cppunit/inc/cppunit/autoregister/callbackfunc_fktptr.h new file mode 100644 index 000000000000..1ba46c0de1d1 --- /dev/null +++ b/cppunit/inc/cppunit/autoregister/callbackfunc_fktptr.h @@ -0,0 +1,68 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: callbackfunc_fktptr.h,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:18:28 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _callbackfunc_fktptr_h +#define _callbackfunc_fktptr_h + +#include <sal/types.h> + +#ifdef __cplusplus +extern "C" { +#endif + +// these typedefs are used for the TestCase, to call the TestResult functions. +// The TestResult is only in the testshl tool, not in the test libraries. + +typedef void* hTest; +typedef void* hException; + +typedef sal_Int32 (* FktPtr_CallbackDispatch)(int x, ...); + +//# typedef void (* FktPtr_TestResult_startTest)(hTestResult, hTest ); +//# typedef void (* FktPtr_TestResult_addFailure)( hTestResult, hTest , hException pException ); +//# typedef void (* FktPtr_TestResult_addError)( hTestResult, hTest , hException pException ); +//# typedef void (* FktPtr_TestResult_endTest)( hTestResult, hTest ); +//# typedef bool (* FktPtr_TestResult_shouldStop)(hTestResult); +//# +//# // Additional functions +//# typedef void (* FktPtr_TestResult_addInfo)( hTestResult, hTest, const char* ); +//# typedef void (* FktPtr_TestResult_enterNode)( hTestResult, const char* ); +//# typedef void (* FktPtr_TestResult_leaveNode)( hTestResult, const char* ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cppunit/inc/cppunit/autoregister/callbackstructure.h b/cppunit/inc/cppunit/autoregister/callbackstructure.h new file mode 100644 index 000000000000..5106e2b18012 --- /dev/null +++ b/cppunit/inc/cppunit/autoregister/callbackstructure.h @@ -0,0 +1,94 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: callbackstructure.h,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:18:40 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _callbackstructure_h +#define _callbackstructure_h + +#include <sal/types.h> +#include <cppunit/autoregister/callbackfunc_fktptr.h> +#include <cppunit/autoregister/registerfunc.h> +#include <cppunit/autoregister/registertestfunction.h> +#include <cppunit/cmdlinebits.hxx> + +// this structure will filled by the testshl tool and hand to the testdll + +struct CallbackStructure +{ + // a version number, if we want to change/expand this struct + sal_Int32 nVersion; + sal_Int64 nMagic; + + FktRegFuncPtr aRegisterFunction; + + FktPtr_CallbackDispatch aCallbackDispatch; + + //# FktPtr_TestResult_startTest aStartTest; + //# FktPtr_TestResult_addFailure aAddFailure; + //# FktPtr_TestResult_addError aAddError; + //# FktPtr_TestResult_endTest aEndTest; + //# FktPtr_TestResult_shouldStop aShouldStop; + //# + //# FktPtr_TestResult_addInfo aAddInfo; + //# FktPtr_TestResult_enterNode aEnterNode; + //# FktPtr_TestResult_leaveNode aLeaveNode; + + const char* psForward; + CmdLineBits nBits; + + // void* pJobList; + + sal_Int64 nMagic2; + + CallbackStructure() + :nVersion(1), + nMagic(SAL_CONST_INT64(0x0123456789abcdef)), + aRegisterFunction(NULL), + aCallbackDispatch(NULL), + /* aStartTest(NULL), + aAddFailure(NULL), + aAddError(NULL), + aEndTest(NULL), + aShouldStop(NULL), + aAddInfo(NULL), + aEnterNode(NULL), + aLeaveNode(NULL), */ + psForward(NULL), + nBits(0), + /* pJobList(NULL), */ + nMagic2(0) + {} +}; + +#endif diff --git a/cppunit/inc/cppunit/autoregister/htestresult.h b/cppunit/inc/cppunit/autoregister/htestresult.h new file mode 100644 index 000000000000..46cfbc8b6808 --- /dev/null +++ b/cppunit/inc/cppunit/autoregister/htestresult.h @@ -0,0 +1,6 @@ +#ifndef _htestresult_h +#define _htestresult_h + +typedef void* hTestResult; + +#endif diff --git a/cppunit/inc/cppunit/autoregister/registerfunc.h b/cppunit/inc/cppunit/autoregister/registerfunc.h new file mode 100644 index 000000000000..c88c14fc9d75 --- /dev/null +++ b/cppunit/inc/cppunit/autoregister/registerfunc.h @@ -0,0 +1,55 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: registerfunc.h,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:18:16 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _registerfunc_h +#define _registerfunc_h + +#include <sal/types.h> +#include <cppunit/autoregister/htestresult.h> +#include <cppunit/autoregister/callbackfunc_fktptr.h> +#include <cppunit/autoregister/testfunc.h> + +struct CallbackStructure; + +// this function is used to register one function into a Container in the testshl tool. +extern "C" void SAL_CALL registerFunction(FktPtr aFunc, const char* aFuncName); + +// this function is the register function for auto registering + +extern "C" void SAL_CALL registerAllTestFunction(CallbackStructure* ); +typedef void (* FktRegAllPtr)(CallbackStructure*); + + +#endif diff --git a/cppunit/inc/cppunit/autoregister/registertestfunction.h b/cppunit/inc/cppunit/autoregister/registertestfunction.h new file mode 100644 index 000000000000..5ca6b1fcc825 --- /dev/null +++ b/cppunit/inc/cppunit/autoregister/registertestfunction.h @@ -0,0 +1,59 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: registertestfunction.h,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:18:04 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _registertestfunction_h +#define _registertestfunction_h + +#include <sal/types.h> +#include <cppunit/autoregister/testfunc.h> + +#ifdef __cplusplus +extern "C" { +#endif + +// function ptr, to register a function +typedef void (* FktRegFuncPtr)(FktPtr aFunc, const char* aFuncName); + +// this function is used in the testdll to register the given function +// into the testshl +extern "C" void SAL_CALL RegisterTestFunctions(FktRegFuncPtr aFunc); + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/cppunit/inc/cppunit/autoregister/testfunc.h b/cppunit/inc/cppunit/autoregister/testfunc.h new file mode 100644 index 000000000000..4eb0d6a3cac0 --- /dev/null +++ b/cppunit/inc/cppunit/autoregister/testfunc.h @@ -0,0 +1,52 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: testfunc.h,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:17:52 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _testfunc_h +#define _testfunc_h + +#include <cppunit/autoregister/htestresult.h> + +#ifdef __cplusplus +extern "C" { +#endif + +// typedef for a testfunction +typedef void (* FktPtr)(hTestResult); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cppunit/inc/cppunit/checkboom.hxx b/cppunit/inc/cppunit/checkboom.hxx new file mode 100644 index 000000000000..e175da2545ef --- /dev/null +++ b/cppunit/inc/cppunit/checkboom.hxx @@ -0,0 +1,45 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: checkboom.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:10:49 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef CHECKBOOM_HXX +#define CHECKBOOM_HXX + +#include <string> +#include <rtl/ustring.hxx> + +void CheckBoom(bool bCondition, std::string const& msg); +void CheckBoom(bool bCondition, rtl::OUString const& msg); + +#endif diff --git a/cppunit/inc/cppunit/cmdlinebits.hxx b/cppunit/inc/cppunit/cmdlinebits.hxx new file mode 100644 index 000000000000..058f6bfe3df5 --- /dev/null +++ b/cppunit/inc/cppunit/cmdlinebits.hxx @@ -0,0 +1,57 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: cmdlinebits.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:11:49 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef CMDLINEBITS_HXX +#define CMDLINEBITS_HXX + +#include <sal/types.h> + +typedef sal_uInt32 CmdLineBits; +const char* getForwardString(); + +#include <stdarg.h> + +enum T_Print_Params { + T_INFO = 1, + T_VERBOSE, + T_DEBUG, + T_ERROR +}; + +// void t_print(const char*); +void t_print(const char*, ...); +void t_print(T_Print_Params, const char*, ...); + +#endif diff --git a/cppunit/inc/cppunit/extensions/AutoRegisterSuite.h b/cppunit/inc/cppunit/extensions/AutoRegisterSuite.h new file mode 100644 index 000000000000..a2138ca8f90e --- /dev/null +++ b/cppunit/inc/cppunit/extensions/AutoRegisterSuite.h @@ -0,0 +1,53 @@ +#ifndef CPPUNIT_EXTENSIONS_AUTOREGISTERSUITE_H +#define CPPUNIT_EXTENSIONS_AUTOREGISTERSUITE_H + +#include <stdio.h> +#include <string> +#include <cppunit/extensions/TestSuiteFactory.h> +#include <cppunit/extensions/TestFactoryRegistry.h> + +namespace CppUnit { + + /** 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<typename TestCaseType> + class AutoRegisterSuite + { + public: + /** Auto-register the suite factory in the global registry. + */ + AutoRegisterSuite() + { + TestFactory *factory = new TestSuiteFactory<TestCaseType>(); + TestFactoryRegistry::getRegistry().registerFactory( factory ); + } + + /** Auto-register the suite factory in the specified registry. + * \param name Name of the registry. + */ + AutoRegisterSuite( const std::string &name ) + { + // printf("AutoRegisterSuite %s\n", name.c_str()); + TestFactory *factory = new TestSuiteFactory<TestCaseType>(); + TestFactoryRegistry::getRegistry( name ).registerFactory( factory ); + } + }; + +} // namespace CppUnit + + +#endif // CPPUNIT_EXTENSIONS_AUTOREGISTERSUITE_H diff --git a/cppunit/inc/cppunit/extensions/HelperMacros.h b/cppunit/inc/cppunit/extensions/HelperMacros.h new file mode 100644 index 000000000000..79eb63e80ab7 --- /dev/null +++ b/cppunit/inc/cppunit/extensions/HelperMacros.h @@ -0,0 +1,333 @@ +// ////////////////////////////////////////////////////////////////////////// +// 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/Portability.h> +#include <cppunit/extensions/AutoRegisterSuite.h> +#include <cppunit/extensions/TestSuiteBuilder.h> +#include <string> + +namespace CppUnit +{ + class TestFixture; + + /*! \brief Abstract TestFixture factory. + */ + class TestFixtureFactory + { + public: + //! Creates a new TestFixture instance. + virtual CppUnit::TestFixture *makeFixture() =0; + }; +} // namespace CppUnit + + +// The macro __CPPUNIT_SUITE_CTOR_ARGS expand to an expression used to construct +// the TestSuiteBuilder with macro CPPUNIT_TEST_SUITE. +// +// The name of the suite is obtained using RTTI if CPPUNIT_USE_TYPEINFO_NAME +// is defined, otherwise it is extracted from the macro parameter +// +// This macro is for cppunit internal and should not be use otherwise. +#if CPPUNIT_USE_TYPEINFO_NAME +# define __CPPUNIT_SUITE_CTOR_ARGS( ATestFixtureType ) +#else +# define __CPPUNIT_SUITE_CTOR_ARGS( ATestFixtureType ) (std::string(#ATestFixtureType)) +#endif + + +/*! \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 ) \ + private: \ + typedef ATestFixtureType __ThisTestFixtureType; \ + class ThisTestFixtureFactory : public CppUnit::TestFixtureFactory \ + { \ + virtual CppUnit::TestFixture *makeFixture() \ + { \ + return new ATestFixtureType(); \ + } \ + }; \ + public: \ + static CppUnit::TestSuite *suite() \ + { \ + CppUnit::TestSuiteBuilder<__ThisTestFixtureType> \ + builder __CPPUNIT_SUITE_CTOR_ARGS( ATestFixtureType ); \ + ThisTestFixtureFactory factory; \ + __ThisTestFixtureType::registerTests( builder.suite(), &factory ); \ + return builder.takeSuite(); \ + } \ + static void \ + registerTests( CppUnit::TestSuite *suite, \ + CppUnit::TestFixtureFactory *factory ) \ + { \ + CppUnit::TestSuiteBuilder<__ThisTestFixtureType> builder( suite ); + + +/*! \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 ) \ + private: \ + typedef ASuperClass __ThisSuperClassType; \ + CPPUNIT_TEST_SUITE( ATestFixtureType ); \ + __ThisSuperClassType::registerTests( suite, factory ) + + +/*! \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 ) \ + builder.addTestCaller( #testMethod, \ + &__ThisTestFixtureType::testMethod , \ + (__ThisTestFixtureType*)factory->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. + */ +#define CPPUNIT_TEST_EXCEPTION( testMethod, ExceptionType ) \ + builder.addTestCallerForException( #testMethod, \ + &__ThisTestFixtureType::testMethod , \ + (__ThisTestFixtureType*)factory->makeFixture(), \ + (ExceptionType *)NULL ); + +/*! \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. + */ +#define CPPUNIT_TEST_FAIL( testMethod ) \ + CPPUNIT_TEST_EXCEPTION( testMethod, CppUnit::Exception ) + +/*! \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() \ + builder.takeSuite(); \ + } \ + private: /* dummy typedef so that the macro can still end with ';'*/ \ + typedef ThisTestFixtureFactory __ThisTestFixtureFactory + +/** @} + */ + +#define __CPPUNIT_CONCATENATE_DIRECT( s1, s2 ) s1##s2 +#define __CPPUNIT_CONCATENATE( s1, s2 ) __CPPUNIT_CONCATENATE_DIRECT( s1, s2 ) + +/** Decorates the specified string with the line number to obtain a unique name; + * @param str String to decorate. + */ +#define __CPPUNIT_MAKE_UNIQUE_NAME( str ) __CPPUNIT_CONCATENATE( str, __LINE__ ) + + +/** 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_TEST_SUITE, CppUnit::AutoRegisterSuite, + * CppUnit::TestFactoryRegistry. + */ + +/* LLA: + #define CPPUNIT_TEST_SUITE_REGISTRATION( ATestFixtureType ) \ + static CppUnit::AutoRegisterSuite< ATestFixtureType > \ + __CPPUNIT_MAKE_UNIQUE_NAME(__autoRegisterSuite ) +*/ + +/** 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_TEST_SUITE, CppUnit::AutoRegisterSuite, + * CppUnit::TestFactoryRegistry.. + */ +#define CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ATestFixtureType, suiteName ) \ + static CppUnit::AutoRegisterSuite< ATestFixtureType > \ + __CPPUNIT_MAKE_UNIQUE_NAME(__autoRegisterSuite )( suiteName ) + + +#endif // CPPUNIT_EXTENSIONS_HELPERMACROS_H diff --git a/cppunit/inc/cppunit/extensions/TestFactory.h b/cppunit/inc/cppunit/extensions/TestFactory.h new file mode 100644 index 000000000000..48ad11c92c89 --- /dev/null +++ b/cppunit/inc/cppunit/extensions/TestFactory.h @@ -0,0 +1,25 @@ +#ifndef CPPUNIT_EXTENSIONS_TESTFACTORY_H +#define CPPUNIT_EXTENSIONS_TESTFACTORY_H + +#include <cppunit/Portability.h> + +namespace CppUnit { + +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; +}; + +} // namespace CppUnit + +#endif // CPPUNIT_EXTENSIONS_TESTFACTORY_H diff --git a/cppunit/inc/cppunit/extensions/TestFactoryRegistry.h b/cppunit/inc/cppunit/extensions/TestFactoryRegistry.h new file mode 100644 index 000000000000..430f76366c4d --- /dev/null +++ b/cppunit/inc/cppunit/extensions/TestFactoryRegistry.h @@ -0,0 +1,158 @@ +#ifndef CPPUNIT_EXTENSIONS_TESTFACTORYREGISTRY_H +#define CPPUNIT_EXTENSIONS_TESTFACTORYREGISTRY_H + +#include <cppunit/Portability.h> + +#if CPPUNIT_NEED_DLL_DECL +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z +#endif +#endif + +#include <cppunit/extensions/TestFactory.h> +#include <map> +#include <string> + +#include <cppunit/autoregister/htestresult.h> + +namespace CppUnit { + +class TestSuite; + +#if CPPUNIT_NEED_DLL_DECL + template class CPPUNIT_API std::map<std::string, TestFactory *>; +#endif + + +/*! \brief Registry for TestFactory. + * \ingroup CreatingTestSuite + * + * Notes that the registry assumes lifetime control for any registered test. + * + * To register tests, use the macros: + * - CPPUNIT_TEST_SUITE_REGISTRATION(): to add tests in the unnamed 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.registerFactory( CppUnit::TestFactoryRegistry::getRegistry( "Graph" ) ); + * registry.registerFactory( CppUnit::TestFactoryRegistry::getRegistry( "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 const& name = "All Tests" ); + + /// 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 unnamed the registry. + * TestSuite registered using CPPUNIT_TEST_SUITE_REGISTRATION() are registered + * in this registry. + * \return Registry which name is "All Tests". + */ + static TestFactoryRegistry &getRegistry(); + + /** Returns a named registry. + * TestSuite registered using CPPUNIT_TEST_SUITE_NAMED_REGISTRATION() are registered + * in the registry of the same name. + * \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 ); + static void testRegistries(hTestResult _pResult); + + /** Adds the registered tests to the specified suite. + * \param suite Suite the tests are added to. + */ + void addTestToSuite( TestSuite *suite ); + + /** 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. + */ +protected: + + void registerFactory( const std::string &name, + TestFactory *factory ); +public: + + /** Adds the specified TestFactory to the registry. + * + * \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; +}; + + +} // namespace CppUnit + + +#if CPPUNIT_NEED_DLL_DECL +#ifdef _MSC_VER +#pragma warning( pop ) +#endif +#endif + + +#endif // CPPUNIT_EXTENSIONS_TESTFACTORYREGISTRY_H diff --git a/cppunit/inc/cppunit/extensions/TestSuiteBuilder.h b/cppunit/inc/cppunit/extensions/TestSuiteBuilder.h new file mode 100644 index 000000000000..5ee305df0b35 --- /dev/null +++ b/cppunit/inc/cppunit/extensions/TestSuiteBuilder.h @@ -0,0 +1,106 @@ +#ifndef CPPUNIT_EXTENSIONS_TESTSUITEBUILDER_H +#define CPPUNIT_EXTENSIONS_TESTSUITEBUILDER_H + +#include <cppunit/Portability.h> +#include <memory> +#include <cppunit/TestSuite.h> +#include <cppunit/TestCaller.h> + +#if CPPUNIT_USE_TYPEINFO_NAME +# include <cppunit/extensions/TypeInfoHelper.h> +#endif + +namespace CppUnit { + + /*! \brief Helper to add tests to a TestSuite. + * \ingroup WritingTestFixture + * + * All tests added to the TestSuite are prefixed by TestSuite name. The resulting + * TestCase name has the following pattern: + * + * MyTestSuiteName.myTestName + */ + template<typename Fixture> + class TestSuiteBuilder + { + public: + typedef void (Fixture::*TestMethod)(); + +#if CPPUNIT_USE_TYPEINFO_NAME + TestSuiteBuilder() : + m_suite( new TestSuite( + TypeInfoHelper::getClassName( typeid(Fixture) ) ) ) + { + } +#endif + + TestSuiteBuilder( TestSuite *_suite ) : m_suite( _suite ) + { + } + + TestSuiteBuilder(std::string const& name) : m_suite( new TestSuite(name) ) + { + } + + TestSuite *suite() const + { + return m_suite.get(); + } + + TestSuite *takeSuite() + { + return m_suite.release(); + } + + void addTest( Test *test ) + { + m_suite->addTest( test ); + } + + void addTestCaller( std::string const& methodName, + TestMethod testMethod ) + { + Test *test = + new TestCaller<Fixture>( makeTestName( methodName ), + testMethod ); + addTest( test ); + } + + void addTestCaller( std::string const& methodName, + TestMethod testMethod, + Fixture *fixture ) + { + Test *test = + new TestCaller<Fixture>( makeTestName( methodName ), + testMethod, + fixture); + addTest( test ); + } + + template<typename ExceptionType> + void addTestCallerForException( std::string const& methodName, + TestMethod testMethod, + Fixture *fixture, + ExceptionType *dummyPointer ) + { + Test *test = new TestCaller<Fixture,ExceptionType>( + makeTestName( methodName ), + testMethod, + fixture); + addTest( test ); + } + + + std::string makeTestName( const std::string &methodName ) + { + // return m_suite->getName() + "." + methodName; + return methodName; + } + + private: + std::auto_ptr<TestSuite> m_suite; + }; + +} // namespace CppUnit + +#endif // CPPUNIT_EXTENSIONS_TESTSUITEBUILDER_H diff --git a/cppunit/inc/cppunit/extensions/TestSuiteFactory.h b/cppunit/inc/cppunit/extensions/TestSuiteFactory.h new file mode 100644 index 000000000000..567812d53d5a --- /dev/null +++ b/cppunit/inc/cppunit/extensions/TestSuiteFactory.h @@ -0,0 +1,25 @@ +#ifndef CPPUNIT_EXTENSIONS_TESTSUITEFACTORY_H +#define CPPUNIT_EXTENSIONS_TESTSUITEFACTORY_H + +#include <cppunit/extensions/TestFactory.h> + +namespace CppUnit { + + class Test; + + /*! \brief TestFactory for TestFixture that implements a static suite() method. + * \see AutoRegisterSuite. + */ + template<typename TestCaseType> + class TestSuiteFactory : public TestFactory + { + public: + virtual Test *makeTest() + { + return TestCaseType::suite(); + } + }; + +} // namespace CppUnit + +#endif // CPPUNIT_EXTENSIONS_TESTSUITEFACTORY_H diff --git a/cppunit/inc/cppunit/extensions/TypeInfoHelper.h b/cppunit/inc/cppunit/extensions/TypeInfoHelper.h new file mode 100644 index 000000000000..5199a705ed3b --- /dev/null +++ b/cppunit/inc/cppunit/extensions/TypeInfoHelper.h @@ -0,0 +1,31 @@ +#ifndef CPPUNIT_TYPEINFOHELPER_H +#define CPPUNIT_TYPEINFOHELPER_H + +#include <cppunit/Portability.h> + +#if CPPUNIT_USE_TYPEINFO_NAME + +#include <typeinfo> + + +namespace CppUnit { + + /** Helper to use type_info. + */ + class CPPUNIT_API TypeInfoHelper + { + public: + /** 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 ); + }; + +} // namespace CppUnit + +#endif + +#endif // CPPUNIT_TYPEINFOHELPER_H diff --git a/cppunit/inc/cppunit/externcallbackfunc.hxx b/cppunit/inc/cppunit/externcallbackfunc.hxx new file mode 100644 index 000000000000..58a919c052db --- /dev/null +++ b/cppunit/inc/cppunit/externcallbackfunc.hxx @@ -0,0 +1,63 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: externcallbackfunc.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:08:51 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef _externcallbackfunc_hxx +#define _externcallbackfunc_hxx + +#include <cppunit/autoregister/callbackfunc_fktptr.h> + +// these pointers have they origin in 'tresregister.cxx' +extern FktPtr_CallbackDispatch pCallbackFunc; + +//# extern FktPtr_TestResult_startTest pTestResult_StartTest; +//# extern FktPtr_TestResult_addFailure pTestResult_AddFailure; +//# extern FktPtr_TestResult_addError pTestResult_AddError; +//# extern FktPtr_TestResult_endTest pTestResult_EndTest; +//# extern FktPtr_TestResult_addInfo pTestResult_AddInfo; + +// these pointers have they origin in 'tresregister.cxx' +// extern FktPtr_TestResult_Starter pTestResult_Starter; + +//# extern FktPtr_TestResult_startTest pTestResult_StartTest; +//# extern FktPtr_TestResult_addFailure pTestResult_AddFailure; +//# extern FktPtr_TestResult_addError pTestResult_AddError; +//# extern FktPtr_TestResult_endTest pTestResult_EndTest; +//# extern FktPtr_TestResult_addInfo pTestResult_AddInfo; +//# +//# extern FktPtr_TestResult_enterNode pTestResult_EnterNode; +//# extern FktPtr_TestResult_leaveNode pTestResult_LeaveNode; +//# + +#endif diff --git a/cppunit/inc/cppunit/joblist.hxx b/cppunit/inc/cppunit/joblist.hxx new file mode 100644 index 000000000000..c0a699610401 --- /dev/null +++ b/cppunit/inc/cppunit/joblist.hxx @@ -0,0 +1,107 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: joblist.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:12:01 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef CPPUNIT_JOBLIST_HXX +#define CPPUNIT_JOBLIST_HXX + +#include <vector> +#include <string> +#include <hash_map> + +#ifndef _SAL_TYPES_H_ +#include "sal/types.h" +#endif + +// #include <cppunit/nocopy.hxx> + +/* + struct eqstr + { + bool operator()( std::string const & s1, std::string const& s2 ) const + { + return ( s1 == s2 ); + } + }; +*/ + +/* + struct hashstr + { + sal_uInt32 operator()( std::string const & str ) const + { + return str.hashCode(); + } + }; +*/ +typedef std::hash_map< std::string, int > HashMap; + +// typedef std::vector<std::string> StringList; + +#define JOB_UNKNOWN 0 +#define JOB_NOT_FOUND 1 +#define JOB_PASSED 2 +#define JOB_FAILED 3 +#define JOB_ACCESS 4 + +#define JOB_EXCLUDE_LIST 0x1000 +#define JOB_ONLY_LIST 0x1001 + +typedef sal_Int16 JobType; + +class JobList /* : NOCOPY */ +{ + HashMap m_aJobList; + char** ppsJobList; + + // returns true if the given List contains unxlngi or unxsols or wntmsci... + bool isInCurrentEnvironment(std::string const& _sString); + std::string trim(std::string const& _sStringToTrim); + +public: + JobList(); + ~JobList(); + + bool readfile(std::string const& _sFilename, JobType _nJobType); + const char** getList() const {return (const char**)ppsJobList;} + + int getJobListEntry(std::string const& _sIndexName); + void setJobListEntry(std::string const& _sIndexName, int _nValue); + + int size() {return m_aJobList.size();} + HashMap const& getHashMap() {return m_aJobList;} +}; + +#endif + diff --git a/cppunit/inc/cppunit/nocopy.hxx b/cppunit/inc/cppunit/nocopy.hxx new file mode 100644 index 000000000000..660bb1892e46 --- /dev/null +++ b/cppunit/inc/cppunit/nocopy.hxx @@ -0,0 +1,13 @@ +#ifndef NOCOPY_HXX +#define NOCOPY_HXX + +// prevent illegal copies +class NOCOPY +{ + NOCOPY(NOCOPY const&); + NOCOPY& operator=(NOCOPY const&); +public: + NOCOPY(){} +}; + +#endif diff --git a/cppunit/inc/cppunit/portability/config-auto.h b/cppunit/inc/cppunit/portability/config-auto.h new file mode 100644 index 000000000000..d2286f729981 --- /dev/null +++ b/cppunit/inc/cppunit/portability/config-auto.h @@ -0,0 +1,62 @@ +#ifndef _INCLUDE_CPPUNIT_CONFIG_AUTO_H +#define _INCLUDE_CPPUNIT_CONFIG_AUTO_H 1 + +/* include/cppunit/config-auto.h. Generated automatically at end of configure. */ +/* config/config.h. Generated automatically by configure. */ +/* config/config.h.in. Generated automatically from configure.in by autoheader. */ + +/* define if library uses std::string::compare(string,pos,n) */ +#ifndef CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST +#define CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST 1 +#endif + +/* define if the library defines strstream */ +#ifndef CPPUNIT_HAVE_CLASS_STRSTREAM +#define CPPUNIT_HAVE_CLASS_STRSTREAM 1 +#endif + +/* Define if you have the <cmath> header file. */ +#ifndef CPPUNIT_HAVE_CMATH +#define CPPUNIT_HAVE_CMATH 1 +#endif + +/* Define if you have the <dlfcn.h> header file. */ +#ifndef CPPUNIT_HAVE_DLFCN_H +#define CPPUNIT_HAVE_DLFCN_H 1 +#endif + +/* define to 1 if the compiler implements namespaces */ +#ifndef CPPUNIT_HAVE_NAMESPACES +#define CPPUNIT_HAVE_NAMESPACES 1 +#endif + +/* define if the compiler supports Run-Time Type Identification */ +#ifndef CPPUNIT_HAVE_RTTI +#define CPPUNIT_HAVE_RTTI 0 +#endif + +/* define if the compiler has stringstream */ +/* #undef CPPUNIT_HAVE_SSTREAM */ + +/* Define if you have the <strstream> header file. */ +#ifndef CPPUNIT_HAVE_STRSTREAM +#define CPPUNIT_HAVE_STRSTREAM 1 +#endif + +/* Name of package */ +#ifndef CPPUNIT_PACKAGE +#define CPPUNIT_PACKAGE "cppunit" +#endif + +/* Define to 1 to use type_info::name() for class names */ +#ifndef CPPUNIT_USE_TYPEINFO_NAME +#define CPPUNIT_USE_TYPEINFO_NAME CPPUNIT_HAVE_RTTI +#endif + +/* Version number of package */ +#ifndef CPPUNIT_VERSION +#define CPPUNIT_VERSION "1.8.0" +#endif + +/* _INCLUDE_CPPUNIT_CONFIG_AUTO_H */ +#endif diff --git a/cppunit/inc/cppunit/portability/config-bcb5.h b/cppunit/inc/cppunit/portability/config-bcb5.h new file mode 100644 index 000000000000..cecb393efd5d --- /dev/null +++ b/cppunit/inc/cppunit/portability/config-bcb5.h @@ -0,0 +1,48 @@ +#ifndef _INCLUDE_CPPUNIT_CONFIG_BCB5_H +#define _INCLUDE_CPPUNIT_CONFIG_BCB5_H 1 + +#define HAVE_CMATH 1 + +/* include/cppunit/config-bcb5.h. Manually adapted from + include/cppunit/config-auto.h */ + +/* define if library uses std::string::compare(string,pos,n) */ +#ifndef CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST +#define CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST 1 +#endif + +/* Define if you have the <dlfcn.h> header file. */ +#ifdef CPPUNIT_HAVE_DLFCN_H +#undef CPPUNIT_HAVE_DLFCN_H +#endif + +/* define to 1 if the compiler implements namespaces */ +#ifndef CPPUNIT_HAVE_NAMESPACES +#define CPPUNIT_HAVE_NAMESPACES 1 +#endif + +/* define if the compiler supports Run-Time Type Identification */ +#ifndef CPPUNIT_HAVE_RTTI +#define CPPUNIT_HAVE_RTTI 1 +#endif + +/* Define to 1 to use type_info::name() for class names */ +#ifndef CPPUNIT_USE_TYPEINFO_NAME +#define CPPUNIT_USE_TYPEINFO_NAME CPPUNIT_HAVE_RTTI +#endif + +#define CPPUNIT_HAVE_SSTREAM 1 + +/* Name of package */ +#ifndef CPPUNIT_PACKAGE +#define CPPUNIT_PACKAGE "cppunit" +#endif + +/* Version number of package */ +#ifndef CPPUNIT_VERSION +#define CPPUNIT_VERSION "1.5.5" +#endif + + +/* _INCLUDE_CPPUNIT_CONFIG_BCB5_H */ +#endif diff --git a/cppunit/inc/cppunit/portability/config-msvc6.h b/cppunit/inc/cppunit/portability/config-msvc6.h new file mode 100644 index 000000000000..9b4c57cfdbb9 --- /dev/null +++ b/cppunit/inc/cppunit/portability/config-msvc6.h @@ -0,0 +1,62 @@ +#ifndef _INCLUDE_CPPUNIT_CONFIG_MSVC6_H +#define _INCLUDE_CPPUNIT_CONFIG_MSVC6_H 1 + +#define HAVE_CMATH 1 + +/* include/cppunit/config-msvc6.h. Manually adapted from + include/cppunit/config-auto.h */ + +/* define if library uses std::string::compare(string,pos,n) */ +#ifdef CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST +#undef CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST +#endif + +/* Define if you have the <dlfcn.h> header file. */ +#ifdef CPPUNIT_HAVE_DLFCN_H +#undef CPPUNIT_HAVE_DLFCN_H +#endif + +/* define to 1 if the compiler implements namespaces */ +#ifndef CPPUNIT_HAVE_NAMESPACES +#define CPPUNIT_HAVE_NAMESPACES 1 +#endif + +#ifndef CPPUNIT_HAVE_RTTI +#define CPPUNIT_HAVE_RTTI 0 +#endif + +#ifndef CPPUNIT_USE_TYPEINFO_NAME +#define CPPUNIT_USE_TYPEINFO_NAME CPPUNIT_HAVE_RTTI +#endif + +#define CPPUNIT_HAVE_SSTREAM 1 + +/* Name of package */ +#ifndef CPPUNIT_PACKAGE +#define CPPUNIT_PACKAGE "cppunit" +#endif + +#undef CPPUNIT_API + +// define CPPUNIT_DLL_BUILD when building CppUnit dll. +#ifdef CPPUNIT_BUILD_DLL +#define CPPUNIT_API __declspec(dllexport) +#endif + +// define CPPUNIT_DLL when linking to CppUnit dll. +#ifdef CPPUNIT_DLL +#define CPPUNIT_API __declspec(dllimport) +#endif + +#ifdef CPPUNIT_API +#undef CPPUNIT_NEED_DLL_DECL +#define CPPUNIT_NEED_DLL_DECL 1 +#endif + +#if _MSC_VER > 1000 // VC++ +#pragma warning( disable : 4786 ) // disable warning debug symbol > 255... +#endif // _MSC_VER > 1000 + + +/* _INCLUDE_CPPUNIT_CONFIG_MSVC6_H */ +#endif diff --git a/cppunit/inc/cppunit/result/SynchronizedObject.h b/cppunit/inc/cppunit/result/SynchronizedObject.h new file mode 100644 index 000000000000..83ac098886a9 --- /dev/null +++ b/cppunit/inc/cppunit/result/SynchronizedObject.h @@ -0,0 +1,82 @@ +#ifndef CPPUNIT_SYNCHRONIZEDOBJECT_H +#define CPPUNIT_SYNCHRONIZEDOBJECT_H + +#include <cppunit/Portability.h> +#include <cppunit/nocopy.hxx> + +namespace CppUnit +{ + +/*! \brief Base class for synchronized object. + * + * Synchronized object are object which members are used concurrently by mutiple + * threads. + * + * This class define the class SynchronizationObject which must be subclassed + * to implement an actual lock. + * + * Each instance of this class holds a pointer on a lock object. + * + * See src/msvc6/MfcSynchronizedObject.h for an example. + */ +class CPPUNIT_API SynchronizedObject +{ +public: + /*! \brief Abstract synchronization object (mutex) + */ + class SynchronizationObject + { + public: + SynchronizationObject() {} + virtual ~SynchronizationObject() {} + + virtual void lock() {} + virtual void unlock() {} + }; + + /*! Constructs a SynchronizedObject object. + */ + SynchronizedObject( SynchronizationObject *syncObject =0 ); + + /// Destructor. + virtual ~SynchronizedObject(); + +protected: + /*! \brief Locks a synchronization object in the current scope. + */ + class ExclusiveZone : NOCOPY + { + SynchronizationObject *m_syncObject; + + public: + ExclusiveZone( SynchronizationObject *syncObject ) + : m_syncObject( syncObject ) + { + m_syncObject->lock(); + } + + ~ExclusiveZone() + { + m_syncObject->unlock (); + } + }; + + virtual void setSynchronizationObject( SynchronizationObject *syncObject ); + +protected: + SynchronizationObject *m_syncObject; + +private: + /// Prevents the use of the copy constructor. + SynchronizedObject( const SynchronizedObject © ); + + /// Prevents the use of the copy operator. + void operator =( const SynchronizedObject © ); +}; + + + +} // namespace CppUnit + + +#endif // CPPUNIT_SYNCHRONIZEDOBJECT_H diff --git a/cppunit/inc/cppunit/result/TestListener.h b/cppunit/inc/cppunit/result/TestListener.h new file mode 100644 index 000000000000..0814f21b7e2f --- /dev/null +++ b/cppunit/inc/cppunit/result/TestListener.h @@ -0,0 +1,62 @@ +#ifndef CPPUNIT_TESTLISTENER_H // -*- C++ -*- +#define CPPUNIT_TESTLISTENER_H + +#include <cppunit/Portability.h> + + +namespace CppUnit { + +class Exception; +class Test; +class TestFailure; + + +/*! \brief Listener for test progress and result. + * \ingroup TrackingTestExecution + * + * Implementing the Observer pattern a TestListener may be registered + * to a TestResult to obtain information on the testing progress. Use + * specialized sub classes of TestListener for text output + * (TextTestProgressListener). Do not use the Listener for the test + * result output, use a subclass of Outputter instead. + * + * The test framework distinguishes between failures and errors. + * A failure is anticipated and checked for with assertions. Errors are + * unanticipated problems signified by exceptions that are not generated + * by the framework. + * + * \see TestResult + */ +class CPPUNIT_API TestListener +{ +public: + virtual ~TestListener() {} + + /// Called when just before a TestCase is run. + virtual void startTest( Test *test ) =0 ; + + /*! Called when a failure occurs while running a test. + * \see TestFailure. + * \warning \a failure is a temporary object that is destroyed after the + * method call. Use TestFailure::clone() to create a duplicate. + */ + virtual void addFailure( const TestFailure &failure ) =0; + + /// Called just after a TestCase was run (even if a failure occured). + virtual void endTest( Test *test ) =0; + + // additional info + virtual void addInfo(Test *test, const char*) =0; + + // info in which node we are + // helper functions to create tree structures + // old: virtual void enterNode( const char* ) =0; + // old: virtual void leaveNode( const char* ) =0; +}; + + +} // namespace CppUnit + +#endif // CPPUNIT_TESTLISTENER_H + + diff --git a/cppunit/inc/cppunit/result/TestResult.h b/cppunit/inc/cppunit/result/TestResult.h new file mode 100644 index 000000000000..9c8895a26ff3 --- /dev/null +++ b/cppunit/inc/cppunit/result/TestResult.h @@ -0,0 +1,123 @@ +#ifndef CPPUNIT_TESTRESULT_H +#define CPPUNIT_TESTRESULT_H + +#include <cppunit/Portability.h> + +#if CPPUNIT_NEED_DLL_DECL +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z +#endif +#endif + +#include <cppunit/result/SynchronizedObject.h> +#include <vector> +#include <string> +#include <deque> +//!io #include <iostream> + +#include "cppunit/result/optionhelper.hxx" +#include "cppunit/TestFailure.h" + +class Outputter; +namespace CppUnit { + +class Exception; +class Test; +// class TestFailure; +class TestListener; + +#if CPPUNIT_NEED_DLL_DECL + template class CPPUNIT_API std::deque<TestListener *>; +#endif + +/*! \brief Manages TestListener. + * \ingroup TrackingTestExecution + * + * A single instance of this class is used when running the test. It is usually + * created by the test runner (TestRunner). + * + * This class shouldn't have to be inherited from. Use a TestListener + * or one of its subclasses to be informed of the ongoing tests. + * Use a Outputter to receive a test summary once it has finished + * + * TestResult supplies a template method 'setSynchronizationObject()' + * so that subclasses can provide mutual exclusion in the face of multiple + * threads. This can be useful when tests execute in one thread and + * they fill a subclass of TestResult which effects change in another + * thread. To have mutual exclusion, override setSynchronizationObject() + * and make sure that you create an instance of ExclusiveZone at the + * beginning of each method. + * + * \see Test, TestListener, TestResultCollector, Outputter. + */ +class CPPUNIT_API TestResult : protected SynchronizedObject +{ +protected: + OptionHelper m_aOptionHelper; + +public: + TestResult( GetOpt & _aOptions, SynchronizationObject *syncObject = 0 ); + virtual ~TestResult(); + + virtual void addListener( TestListener *listener ); + virtual void removeListener( TestListener *listener ); + + virtual void reset(); + virtual void stop(); + + virtual bool shouldStop() const; + + virtual void startTest( Test *test ); + virtual void addError( Test *test, Exception *e, ErrorType::num eType=ErrorType::ET_ERROR); + virtual void addFailure( Test *test, Exception *e ); + virtual void endTest( Test *test ); + + // LLA: additionals + virtual void addInfo(Test *test, const char *sInfo); + + virtual void enterNode(const char* Node); + virtual void leaveNode(const char* Node); + virtual std::string getNodeName(); + + // if true, execution is allowed. + virtual bool isAllowedToExecute(std::string const & sName); + bool isOnlyShowJobs() {return m_aOptionHelper.isOnlyShowJobs();} + bool isOptionWhereAmI(); + + virtual void print(Outputter &); + void setExitValue(int _nValue) {m_nExitValue = _nValue;} + int getExitValue() {return m_nExitValue;} + +protected: + void addFailure( const TestFailure &failure ); + +protected: + typedef std::deque<TestListener *> TestListeners; + TestListeners m_listeners; + bool m_stop; + + // this vector is used to expand the test name with a current node name + std::vector<std::string> m_aCurrentNodeNames; + + //# std::vector<std::string> m_aNodes; + +private: + TestResult( const TestResult &other ); + TestResult &operator =( const TestResult &other ); + int m_nExitValue; +}; + + +} // namespace CppUnit + + +#if CPPUNIT_NEED_DLL_DECL +#ifdef _MSC_VER +#pragma warning( pop ) +#endif +#endif + +#endif // CPPUNIT_TESTRESULT_H + + diff --git a/cppunit/inc/cppunit/result/TestResultCollector.h b/cppunit/inc/cppunit/result/TestResultCollector.h new file mode 100644 index 000000000000..79d9707b9d92 --- /dev/null +++ b/cppunit/inc/cppunit/result/TestResultCollector.h @@ -0,0 +1,165 @@ +#ifndef CPPUNIT_TESTRESULTCOLLECTOR_H +#define CPPUNIT_TESTRESULTCOLLECTOR_H + +#include <cppunit/Portability.h> + +#if CPPUNIT_NEED_DLL_DECL +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z +#endif +#endif + +#include <cppunit/result/TestResult.h> +#include <cppunit/result/TestSucessListener.h> +#include <deque> +#include <vector> + +namespace CppUnit +{ + + +#if CPPUNIT_NEED_DLL_DECL + template class CPPUNIT_API std::deque<TestFailure *>; + template class CPPUNIT_API std::deque<Test *>; +#endif + + +/*! \brief Collects test result. + * \ingroup WritingTestResult + * \ingroup BrowsingCollectedTestResult + * + * A TestResultCollector is a TestListener which collects the results of executing + * a test case. It is an instance of the Collecting Parameter pattern. + * + * The test framework distinguishes between failures and errors. + * A failure is anticipated and checked for with assertions. Errors are + * unanticipated problems signified by exceptions that are not generated + * by the framework. + * \see TestListener, TestFailure. + */ + +class OneStringContainer +{ + std::string m_sName; +protected: + OneStringContainer() {} +public: + OneStringContainer(std::string const& _sName) + :m_sName(_sName){} + std::string getString() const {return m_sName;} + virtual ~OneStringContainer(){} +}; + +// ----------------------------------------------------------------------------- +class TestEnvelope : public OneStringContainer +{ + Test* m_pTest; +public: + TestEnvelope():m_pTest(NULL){} + + TestEnvelope(Test* _pTest, std::string const& _sName) + : OneStringContainer(_sName), + m_pTest(_pTest) + {} + + Test* getTest() {return m_pTest;} + virtual ~TestEnvelope(){} + +}; + +// ----------------------------------------------------------------------------- +class TestInfo : public TestEnvelope +{ +public: + TestInfo(Test* _pTest, std::string const& _sName) + :TestEnvelope(_pTest, _sName) + {} +}; + +// ----------------------------------------------------------------------------- +class TestFailureEnvelope : public OneStringContainer +{ + TestFailure* m_pTestFailure; +public: + TestFailureEnvelope():m_pTestFailure(NULL){} + + TestFailureEnvelope(TestFailure* _pTestFailure, std::string const& _sName) + :OneStringContainer(_sName), + m_pTestFailure(_pTestFailure) + {} + + TestFailure* getTestFailure() {return m_pTestFailure;} + virtual ~TestFailureEnvelope(){} + +}; +// ----------------------------------------------------------------------------- + +class CPPUNIT_API TestResultCollector : public TestSucessListener +{ + TestResult* m_pResult; +public: + typedef std::deque<TestFailureEnvelope *> TestFailures; + typedef std::deque<TestEnvelope *> Tests; + typedef std::vector<TestInfo *> TestInfos; + + + /*! Constructs a TestResultCollector object. + */ + TestResultCollector( TestResult *_pResult, SynchronizationObject *syncObject = 0 ); + + /// Destructor. + virtual ~TestResultCollector(); + + void startTest( Test *test ); + void endTest( Test *test ); + + void addFailure( const TestFailure &failure ); + + virtual void reset(); + + virtual int runTests() const; + virtual int testErrors() const; + virtual int testFailures() const; + virtual int testFailuresTotal() const; + + virtual const TestFailures& failures() const; + virtual const Tests &tests() const; + virtual std::string getInfo(Test*); + + virtual void addInfo(Test *test, const char *sInfo); + + // virtual void enterNode(const char* Node); + // virtual void leaveNode(const char* Node); + +protected: + Tests m_tests; + TestFailures m_failures; + TestInfos m_aInfos; + + int m_testErrors; + + // this vector is used to expand the test name with a current node name + // std::vector<std::string> m_aCurrentNodeNames; + // std::string getNodeName(); +private: + /// Prevents the use of the copy constructor. + TestResultCollector( const TestResultCollector © ); + + /// Prevents the use of the copy operator. + void operator =( const TestResultCollector © ); +}; + + + +} // namespace CppUnit + + +#if CPPUNIT_NEED_DLL_DECL +#ifdef _MSC_VER +#pragma warning( pop ) +#endif +#endif + + +#endif // CPPUNIT_TESTRESULTCOLLECTOR_H diff --git a/cppunit/inc/cppunit/result/TestSucessListener.h b/cppunit/inc/cppunit/result/TestSucessListener.h new file mode 100644 index 000000000000..15794b65f511 --- /dev/null +++ b/cppunit/inc/cppunit/result/TestSucessListener.h @@ -0,0 +1,40 @@ +#ifndef CPPUNIT_TESTSUCESSLISTENER_H +#define CPPUNIT_TESTSUCESSLISTENER_H + +#include <cppunit/result/SynchronizedObject.h> +#include <cppunit/result/TestListener.h> + + +namespace CppUnit +{ + +/*! \brief TestListener that checks if any test case failed. + * \ingroup TrackingTestExecution + */ +class CPPUNIT_API TestSucessListener : public TestListener, + public SynchronizedObject +{ +public: + /*! Constructs a TestSucessListener object. + */ + TestSucessListener( SynchronizationObject *syncObject = 0 ); + + /// Destructor. + virtual ~TestSucessListener(); + + virtual void reset(); + + void addFailure( const TestFailure &failure ); + + /// Returns whether the entire test was successful or not. + virtual bool wasSuccessful() const; + +private: + bool m_sucess; +}; + + +} // namespace CppUnit + + +#endif // CPPUNIT_TESTSUCESSLISTENER_H diff --git a/cppunit/inc/cppunit/result/TextTestResult.h b/cppunit/inc/cppunit/result/TextTestResult.h new file mode 100644 index 000000000000..02eb3344b708 --- /dev/null +++ b/cppunit/inc/cppunit/result/TextTestResult.h @@ -0,0 +1,62 @@ +#ifndef CPPUNIT_TEXTTESTRESULT_H +#define CPPUNIT_TEXTTESTRESULT_H + +#include <cppunit/result/TestResult.h> +#include <cppunit/result/TestResultCollector.h> +#include <ostream> + +class GetOpt; +namespace CppUnit { + +class SourceLine; +class Exception; +class Test; + +/*! \brief Holds printable test result (DEPRECATED). + * \ingroup TrackingTestExecution + * + * deprecated Use class TextTestProgressListener and TextOutputter instead. + */ +class CPPUNIT_API TextTestResult : public TestResult +/* public TestResultCollector*/ +{ + TestResultCollector m_aResulter; +public: + TextTestResult(GetOpt& _aOptions); + + virtual void addFailure( const TestFailure &failure ); + virtual void startTest( Test *test ); + virtual void endTest( Test *test ); + + virtual void print( std::ostream &stream ); +protected: + + virtual void printFailures( std::ostream &stream ); + virtual void printHeader( std::ostream &stream ); + + virtual void printFailure( TestFailure *failure, + int failureNumber, + std::ostream &stream ); + virtual void printFailureListMark( int failureNumber, + std::ostream &stream ); + virtual void printFailureTestName( TestFailure *failure, + std::ostream &stream ); + virtual void printFailureType( TestFailure *failure, + std::ostream &stream ); + virtual void printFailureLocation( SourceLine sourceLine, + std::ostream &stream ); + virtual void printFailureDetail( Exception *thrownException, + std::ostream &stream ); + virtual void printFailureWarning( std::ostream &stream ); + virtual void printStatistics( std::ostream &stream ); +}; + +/** insertion operator for easy output */ +std::ostream &operator <<( std::ostream &stream, + TextTestResult &result ); + +} // namespace CppUnit + +#endif // CPPUNIT_TEXTTESTRESULT_H + + diff --git a/cppunit/inc/cppunit/result/callbackfunc.h b/cppunit/inc/cppunit/result/callbackfunc.h new file mode 100644 index 000000000000..8ff1c7a957f4 --- /dev/null +++ b/cppunit/inc/cppunit/result/callbackfunc.h @@ -0,0 +1,25 @@ +#ifndef _callbackfunc_h +#define _callbackfunc_h + +#ifdef __cplusplus +extern "C" { +#endif + + // this is the entry point from the DLL back to the executable. + sal_Int32 CallbackDispatch(int x, ...); + +//# void TestResult_startTest(hTestResult _pResult, hTest _pTest); +//# void TestResult_addFailure( hTestResult _pResult, hTest _pTest, hException _pException ); +//# void TestResult_addError( hTestResult _pResult, hTest _pTest, hException _pException ); +//# void TestResult_endTest( hTestResult _pResult, hTest _pTest ); +//# bool TestResult_shouldStop(hTestResult _pResult); +//# void TestResult_addInfo( hTestResult _pResult, hTest _pTest, const char* _sInfo ); +//# +//# void TestResult_enterNode( hTestResult _pResult, const char* _sInfo ); +//# void TestResult_leaveNode( hTestResult _pResult, const char* _sInfo ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cppunit/inc/cppunit/result/emacsTestResult.hxx b/cppunit/inc/cppunit/result/emacsTestResult.hxx new file mode 100644 index 000000000000..4c7c09a18113 --- /dev/null +++ b/cppunit/inc/cppunit/result/emacsTestResult.hxx @@ -0,0 +1,87 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: emacsTestResult.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:15:24 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef cppunit_emacstestresult_h +#define cppunit_emacstestresult_h + +#include <cppunit/result/TestResult.h> +#include <cppunit/result/TestResultCollector.h> +#include <ostream> +#include "testshl/getopt.hxx" + +class Outputter; +namespace CppUnit { + +class SourceLine; +class Exception; +class Test; + +/*! \brief Holds printable test result (DEPRECATED). + * \ingroup TrackingTestExecution + * + * deprecated Use class TextTestProgressListener and TextOutputter instead. + */ + class CPPUNIT_API emacsTestResult : public TestResult + +/* ,public TestResultCollector*/ + { + GetOpt & m_aOptions; + // OptionHelper m_aOptionHelper; + TestResultCollector m_aResulter; + + public: + emacsTestResult(GetOpt & _aOptions); + + // virtual void addFailure( const TestFailure &failure ); + // virtual void startTest( Test *test ); + // virtual void endTest( Test *test ); + + virtual void print( Outputter &stream ); + + protected: + virtual void printHeader( Outputter &stream ); + // virtual void printTestLine( Outputter &stream, Test* pTest, std::string const& _sNodeName, std::string const& _sInfo); + virtual void printFailureLine( Outputter &stream, TestFailure* pFailure, std::string const& _sNodeName ); + }; + +/** insertion operator for easy output */ +// std::ostream &operator <<( std::ostream &stream, +// emacsTestResult &result ); + +} // namespace CppUnit + +#endif // CPPUNIT_testshlTESTRESULT_H + + diff --git a/cppunit/inc/cppunit/result/log.hxx b/cppunit/inc/cppunit/result/log.hxx new file mode 100644 index 000000000000..8d4d7108f01e --- /dev/null +++ b/cppunit/inc/cppunit/result/log.hxx @@ -0,0 +1,126 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: log.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:13:49 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ +#ifndef __QADEV_REGSCAN_LOG_HXX__ +#define __QADEV_REGSCAN_LOG_HXX__ + +#include <time.h> + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + +#ifndef _RTL_STRBUF_HXX_ +#include <rtl/strbuf.hxx> +#endif + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifndef _OSL_THREAD_H_ +#include <osl/thread.h> +#endif + +#ifndef _OSL_FILE_HXX_ +#include <osl/file.hxx> +#endif + +#include <cppunit/nocopy.hxx> + +//!io #include <iostream> +#include <vector> + +// using namespace std; + + +/** + * Log derives the interface of the ::osl::File class ( is-a relation ). + * Its members (has-a relation) are the (full qualified)name of the log + * and an OStringBuffer which represents the content of the logfile. + * It provides the functionality of easy-to-use open and write logs + */ +//: Log +class Log : NOCOPY { + + ::osl::File* m_logfile; // fileobject + rtl::OUString m_logurl; // url of log + rtl::OStringBuffer m_buf; // content of log + + Log(); + +public: + + //> c'tor + /** + * constructors argument is a full qualified UNC path + * @param OUString logfile ( full qualified UNC path ) + */ + Log( const rtl::OUString& logURL ) + : m_logfile( new ::osl::File( logURL )) + , m_logurl(logURL) + {} ///< c'tor + + //> d'tor + virtual ~Log() + { + m_logfile->close(); + delete( m_logfile ); + } ///< d'tor + + //> inline methods + // returns a reference to name instance + inline rtl::OUString getLogURL() { return m_logurl; } + inline rtl::OString getName() { return rtl::OUStringToOString( + m_logurl, RTL_TEXTENCODING_ASCII_US ); } + ///< inline methods + + // open logfile for overwrite (default) or append + ::osl::FileBase::RC open( sal_Bool append = sal_False ); + ::osl::FileBase::RC close() { return m_logfile->close(); } + + + // write methods without (default) or with echo on display + ::osl::FileBase::RC write( const sal_Char* buf, sal_Bool v = sal_False ); + ::osl::FileBase::RC write( const rtl::OString& buf, + sal_Bool v = sal_False ); + //! ::osl::FileBase::RC write( rtl::OStringBuffer& buf, + //! sal_Bool v = sal_False ); + ::osl::FileBase::RC write( const rtl::OUString& buf, + rtl_TextEncoding enc = RTL_TEXTENCODING_ASCII_US, + sal_Bool v = sal_False ); + +}; ///:~ Log + +#endif diff --git a/cppunit/inc/cppunit/result/optionhelper.hxx b/cppunit/inc/cppunit/result/optionhelper.hxx new file mode 100644 index 000000000000..0ffb50ff7afc --- /dev/null +++ b/cppunit/inc/cppunit/result/optionhelper.hxx @@ -0,0 +1,103 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: optionhelper.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:13:38 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef optionhelper_hxx +#define optionhelper_hxx + +#include <string> + +#include <sal/types.h> + +#include "cppunit/nocopy.hxx" +#include "testshl/getopt.hxx" +#include "cppunit/joblist.hxx" + +// ----------------------------------------------------------------------------- + +typedef std::vector<rtl::OString> OStringList; + +//!? Better: OptionHelper +class OptionHelper : NOCOPY +{ + GetOpt & m_aOption; + JobList m_aJobOnlyList; + JobList m_aJobExcludeList; + OStringList m_aJobFilter; + + std::string m_sProjectId; + std::string m_sBuildId; + + std::string getProjectId() const; + std::string getBuildId() const; + std::string createDateTag(std::string const& _sProjectId, std::string const& _sBuildId); + + void handleJobs(); +public: + OptionHelper(GetOpt & _aOption) + :m_aOption(_aOption) + { + if (m_aOption.hasOpt("-projectid")) + m_sProjectId = m_aOption.getOpt("-projectid"); + + if (m_aOption.hasOpt("-buildid")) + m_sBuildId = m_aOption.getOpt("-buildid"); + + handleJobs(); + } + + static std::string integerToAscii(sal_Int32 nValue); + static std::string twoDigits(std::string const& _sValue); + + std::string createDateTag(); + bool showErrors(); + bool showTests(); + + JobList getJobOnlyList() {return m_aJobOnlyList;} + JobList getJobExcludeList() {return m_aJobExcludeList;} + + bool isAllowedToExecute(std::string const& _sNode, std::string const& _sName); + + bool isOnlyShowJobs() {return m_aOption.hasOpt("-onlyshowjobs") == sal_True ? true : false;} + GetOpt& getOptions() {return m_aOption;} + bool isVerbose() {return m_aOption.hasOpt("-verbose") == sal_True ? true : false;} + bool isOptionWhereAmI() {return m_aOption.hasOpt("-whereami") == sal_True ? true : false;} +}; + +// ----------------------------------------------------------------------------- + + +#endif + + diff --git a/cppunit/inc/cppunit/result/outputter.hxx b/cppunit/inc/cppunit/result/outputter.hxx new file mode 100644 index 000000000000..c4c828c68ad8 --- /dev/null +++ b/cppunit/inc/cppunit/result/outputter.hxx @@ -0,0 +1,90 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: outputter.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:15:12 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +// + +#ifndef outputter_hxx +#define outputter_hxx + +#include <string> +#include <ostream> +#include <memory> +#include "testshl/log.hxx" +#include <sal/types.h> +#include "cppunit/nocopy.hxx" + +// #include <fstream> + +class Outputter : NOCOPY +{ + std::auto_ptr<Log> m_pLog; + std::ostream* m_pStream; + + void writeToAll(const sal_Char* _pStr); +public: + class endl + { + char c; + public: + endl():c('\0'){} + }; +public: + Outputter(Log * _pLog ) + :m_pLog(_pLog), + m_pStream(NULL) {} + + Outputter(std::ostream& _aStream) + :m_pLog(NULL), + m_pStream(&_aStream) {} + + ~Outputter(); + + void write(const sal_Char*); + void write(std::string const&); + void write(sal_Int32); + // void write(double); +}; + +Outputter& operator <<( Outputter &stream, const sal_Char* ); +Outputter& operator <<( Outputter &stream, std::string const& ); +Outputter& operator <<( Outputter &stream, sal_Int32 ); +// Outputter& operator <<( Outputter &stream, double ); + +Outputter& operator <<( Outputter &stream, Outputter::endl const&); + +// Outputter& operator <<( Outputter &stream, const char* ); + +#endif + diff --git a/cppunit/inc/cppunit/result/testshlTestResult.h b/cppunit/inc/cppunit/result/testshlTestResult.h new file mode 100644 index 000000000000..0eb629610bc4 --- /dev/null +++ b/cppunit/inc/cppunit/result/testshlTestResult.h @@ -0,0 +1,72 @@ +#ifndef cppunit_testshltestresult_h +#define cppunit_testshltestresult_h + +#include <map> +#include <cppunit/result/TestResult.h> +#include <cppunit/result/TestResultCollector.h> +#include <ostream> +#include "testshl/getopt.hxx" + +class Outputter; + +namespace CppUnit { + +class SourceLine; +class Exception; +class Test; + +struct ltstr +{ + bool operator()(const CppUnit::Test* p1, const CppUnit::Test* p2) const + { + return p1 < p2; + } +}; +typedef std::map<CppUnit::Test*, bool, ltstr> TestPtrList; + + +/*! \brief Holds printable test result (DEPRECATED). + * \ingroup TrackingTestExecution + * + * deprecated Use class TextTestProgressListener and TextOutputter instead. + */ + class CPPUNIT_API testshlTestResult : public TestResult + +/* ,public TestResultCollector*/ + { + GetOpt & m_aOptions; + // OptionHelper m_aOptionHelper; + TestResultCollector m_aResulter; + + public: + testshlTestResult(GetOpt & _aOptions); + virtual ~testshlTestResult(); + + // virtual void addFailure( const TestFailure &failure ); + // virtual void startTest( Test *test ); + // virtual void endTest( Test *test ); + + virtual void print( Outputter &stream ); + + protected: + virtual void printHeader( Outputter &stream ); + + void printLines(Outputter &stream, HashMap & _aJobList); + void printFailedTests(Outputter &stream, TestPtrList &aFailedTests); + void printTestLines(Outputter &stream, TestPtrList &aFailedTests); + void printUnknownLines(Outputter &stream, HashMap & _aJobList); + + virtual void printTestLine( Outputter &stream, Test* pTest, std::string const& _sNodeName, std::string const& _sInfo); + virtual void printFailureLine( Outputter &stream, TestFailure* pFailure, std::string const& _sNodeName ); + virtual void printUnknownLine( Outputter &stream, std::string const& _sTestName); + }; + +/** insertion operator for easy output */ + Outputter &operator <<( Outputter &stream, + testshlTestResult &result ); + +} // namespace CppUnit + +#endif // CPPUNIT_testshlTESTRESULT_H + + diff --git a/cppunit/inc/cppunit/signaltest.h b/cppunit/inc/cppunit/signaltest.h new file mode 100644 index 000000000000..225790bc4ccc --- /dev/null +++ b/cppunit/inc/cppunit/signaltest.h @@ -0,0 +1,70 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: signaltest.h,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:12:38 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef SIGNALTEST_H +#define SIGNALTEST_H + +#include <string> +#include "cppunit/Test.h" +#include <cppunit/autoregister/htestresult.h> + +namespace CppUnit +{ + +class CPPUNIT_API SignalTest : public Test +{ +public: + + SignalTest( std::string const& Name ); + + ~SignalTest(); + + virtual void run(hTestResult pResult); + virtual int countTestCases() const; + std::string getName() const; + std::string toString() const; + +private: + SignalTest( const SignalTest &other ); + SignalTest &operator=( const SignalTest &other ); + +private: + const std::string m_sName; +}; + +} // namespace CppUnit + + +#endif diff --git a/cppunit/inc/cppunit/simpleheader.hxx b/cppunit/inc/cppunit/simpleheader.hxx new file mode 100644 index 000000000000..811d2c6fce4d --- /dev/null +++ b/cppunit/inc/cppunit/simpleheader.hxx @@ -0,0 +1,50 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: simpleheader.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:12:49 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef CPPUNIT_SIMPLEHEADER_HXX +#define CPPUNIT_SIMPLEHEADER_HXX + +// This file contains only the cppunit header files, for simplification. + +#include <cppunit/TestFixture.h> +#include <cppunit/TestCaller.h> +#include <cppunit/TestSuite.h> +#include <cppunit/TestAssert.h> +#include <cppunit/autoregister/registertestfunction.h> +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/additionalfunc.hxx> +#include <cppunit/cmdlinebits.hxx> + +#endif diff --git a/cppunit/inc/cppunit/stringhelper.hxx b/cppunit/inc/cppunit/stringhelper.hxx new file mode 100644 index 000000000000..bb43de094a95 --- /dev/null +++ b/cppunit/inc/cppunit/stringhelper.hxx @@ -0,0 +1,17 @@ +#ifndef STRINGHELPER_HXX +#define STRINGHELPER_HXX + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + +#ifndef _RTL_STRING_HXX_ +#include <rtl/string.hxx> +#endif + +inline void operator <<= (rtl::OString& _rAsciiString, const rtl::OUString& _rUnicodeString) +{ + _rAsciiString = rtl::OUStringToOString(_rUnicodeString,RTL_TEXTENCODING_ASCII_US); +} + +#endif diff --git a/cppunit/inc/cppunit/taghelper.hxx b/cppunit/inc/cppunit/taghelper.hxx new file mode 100644 index 000000000000..e13b1ee67eb0 --- /dev/null +++ b/cppunit/inc/cppunit/taghelper.hxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: taghelper.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:09:01 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef TAGHELPER_HXX +#define TAGHELPER_HXX + +#include <map> +#include <sal/types.h> +#include <cppunit/nocopy.hxx> + +/* Tags are a general mechanism of extensible data arrays for parameter + * specification and property inquiry. In practice, tags are used in arrays, + * or chain of arrays. + * + */ + +typedef sal_IntPtr Tag; +typedef sal_IntPtr TagData; + +//# struct TagItem +//# { +//# Tag ti_Tag; /* identifies the type of data */ +//# TagData ti_Data; /* type-specific data */ +//# }; + +/* constants for Tag.ti_Tag, control tag values */ +#define TAG_DONE (Tag(0L)) /* terminates array of TagItems. ti_Data unused */ +#define TAG_END (Tag(0L)) /* synonym for TAG_DONE */ +#define TAG_IGNORE (Tag(1L)) /* ignore this item, not end of array */ +#define TAG_MORE (Tag(2L)) /* ti_Data is pointer to another array of TagItems + * note that this tag terminates the current array + */ +#define TAG_SKIP (Tag(3L)) /* skip this and the next ti_Data items */ + +/* differentiates user tags from control tags */ +#define TAG_USER (Tag(1L<<31)) + +// ----------------------------------------------------------------------------- +class TagHelper /* : NOCOPY */ +{ + typedef std::map<Tag, TagData> TagItems; + TagItems m_aTagItems; + +public: + TagHelper(){} + void insert(Tag _nTag, TagData _nData) + { + m_aTagItems[_nTag] = _nData; + } + // const TagItems& get() const { return m_aTagItems; } + + TagData GetTagData(Tag _aTagValue, TagData _aDefaultValue = 0 /* NULL */) const + { + TagItems::const_iterator it = m_aTagItems.find(_aTagValue); + if (it != m_aTagItems.end()) + return (*it).second; + else + return _aDefaultValue; + } +}; + +#endif + + diff --git a/cppunit/inc/cppunit/tagvalues.hxx b/cppunit/inc/cppunit/tagvalues.hxx new file mode 100644 index 000000000000..d73d132eb335 --- /dev/null +++ b/cppunit/inc/cppunit/tagvalues.hxx @@ -0,0 +1,86 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tagvalues.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:09:11 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef TAGVALUES_H +#define TAGVALUES_H + +#include <cppunit/taghelper.hxx> + +#define TAG_TYPE (Tag(TAG_USER | (0x01L))) + +#define TAG_RESULT (TAG_USER | 0x100) + +#define RESULT_START (Tag(TAG_RESULT | (0x02L))) +#define TAG_RESULT_PTR (Tag(TAG_RESULT | (0x03L))) +#define TAG_TEST_PTR (Tag(TAG_RESULT | (0x04L))) + +#define RESULT_END (Tag(TAG_RESULT | (0x05L))) + +#define RESULT_ADD_FAILURE (Tag(TAG_RESULT | (0x06L))) +#define RESULT_ADD_ERROR (Tag(TAG_RESULT | (0x07L))) + +#define TAG_EXCEPTION (Tag(TAG_RESULT | (0x08L))) + +#define RESULT_ADD_INFO (Tag(TAG_RESULT | (0x09L))) +#define TAG_INFO (Tag(TAG_RESULT | (0x0aL))) + +#define RESULT_ENTER_NODE (Tag(TAG_RESULT | (0x0bL))) +#define RESULT_LEAVE_NODE (Tag(TAG_RESULT | (0x0cL))) +#define TAG_NODENAME (Tag(TAG_RESULT | (0x0dL))) + +#define RESULT_SHOULD_STOP (Tag(TAG_RESULT | (0x0eL))) + + +#define TAG_SIGNAL (TAG_USER | 0x200) +// #define SIGNAL_CHECK (Tag(TAG_SIGNAL | (0x01L))) +// #define INIT_SIGNAL_HANDLING (Tag(TAG_SIGNAL | (0x04L))) +// #define RELEASE_SIGNAL_HANDLING (Tag(TAG_SIGNAL | (0x05L))) + +#define SIGNAL_START_TEST (Tag(TAG_SIGNAL | (0x06L))) +#define SIGNAL_END_TEST (Tag(TAG_SIGNAL | (0x07L))) + +#define TAG_EXECUTION (TAG_USER | 0x400) +#define EXECUTION_CHECK (Tag(TAG_EXECUTION | (0x01))) +#define INIT_TEST (Tag(TAG_EXECUTION | (0x02))) +#define RELEASE_TEST (Tag(TAG_EXECUTION | (0x03))) +// #define EXECUTION_PUSH_NAME (Tag(TAG_EXECUTION | (0x04))) +// #define EXECUTION_POP_NAME (Tag(TAG_EXECUTION | (0x05))) + +#define DO_NOT_EXECUTE 666 +#define GO_EXECUTE 1 + +typedef sal_Int32 ReturnValue; + +#endif diff --git a/cppunit/inc/makefile.mk b/cppunit/inc/makefile.mk new file mode 100644 index 000000000000..00e214404531 --- /dev/null +++ b/cppunit/inc/makefile.mk @@ -0,0 +1,56 @@ +#************************************************************************* +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: lla $ $Date: 2008-02-27 16:08:21 $ +# +# The Contents of this file are made available subject to +# the terms of GNU Lesser General Public License Version 2.1. +# +# +# GNU Lesser General Public License Version 2.1 +# ============================================= +# Copyright 2005 by Sun Microsystems, Inc. +# 901 San Antonio Road, Palo Alto, CA 94303, USA +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1, as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# +#************************************************************************* +PRJ=.. +# PRJINC=.. + +PRJNAME=cppunit +TARGET=inc + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# --- Files -------------------------------------------------------- +# --- Targets ------------------------------------------------------- + +.INCLUDE : target.mk + +.IF "$(ENABLE_PCH)"!="" +ALLTAR : \ + $(SLO)$/precompiled.pch \ + $(SLO)$/precompiled_ex.pch + +.ENDIF # "$(ENABLE_PCH)"!="" + diff --git a/cppunit/inc/testshl/autoregisterhelper.hxx b/cppunit/inc/testshl/autoregisterhelper.hxx new file mode 100644 index 000000000000..88653ba0b85d --- /dev/null +++ b/cppunit/inc/testshl/autoregisterhelper.hxx @@ -0,0 +1,67 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: autoregisterhelper.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:19:14 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef AUTOREGISTER_HXX +#define AUTOREGISTER_HXX + +#include <vector> +#include <rtl/ustring.hxx> + +#include <cppunit/autoregister/testfunc.h> + +#include "dynamicregister.hxx" +#include "getopt.hxx" + +typedef std::vector<FktPtr> FunctionList; + +// ----------------------------------------------------------------------------- +class JobList; +class AutomaticRegisterHelper : public DynamicLibraryHelper +{ + FunctionList m_aFunctionList; + bool m_bLoadLibraryOK; + +public: + AutomaticRegisterHelper(rtl::OUString const& _sDLLName, GetOpt & _aOptions/* , JobList * _pJobList = NULL */ ); + + // FunctionList getFunctions(){return m_aFunctionList;} + void CallAll(hTestResult _hResult) const; + + /// @return true, if the given DLLName library could load and initialised. + bool isOkToStartTests() const {return m_bLoadLibraryOK;} +}; + +#endif + diff --git a/cppunit/inc/testshl/dynamicregister.hxx b/cppunit/inc/testshl/dynamicregister.hxx new file mode 100644 index 000000000000..a8bbdccf2488 --- /dev/null +++ b/cppunit/inc/testshl/dynamicregister.hxx @@ -0,0 +1,63 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dynamicregister.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:20:22 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef DYNAMICREGISTER_HXX +#define DYNAMICREGISTER_HXX + +#include <rtl/ustring.hxx> + +#ifndef _OSL_MODULE_HXX_ +#include <osl/module.hxx> +#endif + +#include "getopt.hxx" +#include "cppunit/nocopy.hxx" + +// ------------------------------------------------- + +class DynamicLibraryHelper : NOCOPY +{ +protected: + osl::Module* m_pModule; + rtl::OUString m_suDLLName; + GetOpt & m_aOptions; + +public: + DynamicLibraryHelper(rtl::OUString const& _sDLLName, GetOpt & _aOptions); + virtual ~DynamicLibraryHelper(); +}; + +#endif + diff --git a/cppunit/inc/testshl/filehelper.hxx b/cppunit/inc/testshl/filehelper.hxx new file mode 100644 index 000000000000..539ba7f0cdb0 --- /dev/null +++ b/cppunit/inc/testshl/filehelper.hxx @@ -0,0 +1,55 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: filehelper.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:19:56 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef FILEHELPER_HXX +#define FILEHELPER_HXX + +#include <string> +#include <rtl/ustring.hxx> +#include <rtl/string.hxx> +#include <cppunit/cmdlinebits.hxx> +#include "getopt.hxx" + +namespace FileHelper +{ + + std::string getTempPath(); + rtl::OUString convertPath( rtl::OUString const& _suSysPath ); + rtl::OUString convertPath( rtl::OString const& sysPth ); + CmdLineBits createFlags( GetOpt & _aOptions ); + +} +#endif + diff --git a/cppunit/inc/testshl/getopt.hxx b/cppunit/inc/testshl/getopt.hxx new file mode 100644 index 000000000000..2a757b0b13f0 --- /dev/null +++ b/cppunit/inc/testshl/getopt.hxx @@ -0,0 +1,350 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: getopt.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:20:09 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +/************************************************************************* +#* class GetOpt +#* +#* +#* Implementation getopt.cxx +#* +#* Description: class to reflect the commandline options. In addition +#* it provides functinality to get options from an inifile +#* ( getIniOptions()), evaluate, test and get options +#* ( hasOpt(), getOpt() ) and display an usage screen +#* formated in dependance of the given optionset, as well +#* as display a status about activ options +#* +#* +#* further descriptions: +#* +#* the constructor is called with two parameters: +#* char* argv[] and char* optionSet[], +#* the commandline and the available set of options. +#* Valid optionstrings have to start with a minus '-', otherwise it will +#* be ignored. Optionstrings consist of one or two arguments divided by a +#* comma separator, where the second (optional) argument is a short +#* description of the option, called hint. It will be automatically +#* formated and displayed in the usage screen if available. +#* The first argument of the optionstring can consist of two sections, +#* the name and the optional necessity and format. +#* The name of the option will be the starting minus followed by a string +#* like "-src". +#* One section options will be treated as flag (see '-v' option in example). +#* The second section consist of '=' or ':' which defines the necessity, +#* in combination with a character 's' for string or 'n' for numeric and +#* an optional '@' standing for 'vector of'. +#* '=' means this option needs an argument, ':' means can take an argument +#* followed by 's' is, as mentioned above, a single string paramenter, +#* followed by a 's' in combination with '@' means this argument consists +#* of one string or a vector of strings separated by commas +#* +#* an example for an optionset: +#* +#* static char* optionSet[] = { +#* "-src=s, release or version of sources", +#* "-ini=s, ini file with additional options", +#* "-db=s, path of type description database", +#* "-inPth=s, source path of component descriptions", +#* "-outPth=s, destination path for testcases", +#* "-logPth=s, destination path for logging", +#* "-mdl=s@, name(s) of module(s) to generate", +#* "-v, enable verbose screen messages", +#* "-dbg, enable debug messages", +#* "-h:s, display help or help on option", +#* "-help:s, see -h", +#* NULL +#* }; +#* +#* As seen a GetOpt class object will be created via: +#* GetOpt myOptions( argv, optionSet ); +#* +*************************************************************************/ +#ifndef __QADEV_REGSCAN_GETOPT_HXX__ +#define __QADEV_REGSCAN_GETOPT_HXX__ + +#ifndef _OSL_FILE_HXX_ +#include <osl/file.hxx> +#endif + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifndef _RTL_STRBUF_HXX_ +#include <rtl/strbuf.hxx> +#endif + + +#ifndef _RTL_STRING_HXX_ +#include <rtl/string.hxx> +#endif + +// #ifndef __QADEV_REGSCAN_UTIL_HXX__ +// #include "inc/util.hxx" +// #endif + + +#ifdef SOLARIS +#include <sys/time.h> +#endif + +#include <iostream> +#include <hash_map> +// #include "rsexception.hxx" + +// using namespace std; + +struct gstr { + sal_Bool operator()( const rtl::OString& oStr1, + const rtl::OString& oStr2 ) const { + return( oStr1 == oStr2 ); + } +}; + +struct ghstr +{ + sal_uInt32 operator()( const rtl::OString& str ) const { + return str.hashCode(); + } +}; + +struct frmt { + sal_uInt32 fCol; + sal_uInt32 sCol; + sal_uInt32 len; +}; + +typedef std::hash_map< rtl::OString, std::vector< rtl::OString >, ghstr, gstr > + optHashMap; + +typedef frmt sFormat; +typedef sal_uInt16 optType; + +#define OT_INVALID 0x0000 +#define OT_BOOL 0x0001 +#define OT_STRING 0x0002 +#define OT_NUMBER 0x0004 +#define OT_SINGLE 0x0010 +#define OT_MULTI 0x0020 +#define OT_OPTIONAL 0x0100 + +//: Option +class OptDsc { + + rtl::OString m_name; + rtl::OString m_hint; + rtl::OString m_legend; + optType m_type; + + /** + * analysis of optionstring and creation of option description class + * @param const rtl::OString& opt = optionstring to analyse + * @return void + */ + void createOptDsc( const rtl::OString& opt ); + + /** + * splitting of an optionstring and creation of a tokenvector + * in dependance of a charset + * + * @param const rtl::OString& opt = optionstring to split + * @param const rtl::OString& cSet = delimiter charset + * @param vector< rtl::OString >& optLine = tokenvector to fill + * + * @return void + */ + void split( const rtl::OString& opt, const rtl::OString& charSet, + std::vector< rtl::OString >& optLine ); + + /** + * private default c'tor, copy c'tor and assignment operator + * to get compiler errors on dumb effords + */ + OptDsc(); + OptDsc( OptDsc& ); + OptDsc& operator = ( OptDsc& ); + +public: + + //> c'tor + OptDsc( const rtl::OString& opt ) + : m_name(), + m_hint(), + m_legend(), + m_type( 0 ) { + + createOptDsc( opt ); + } ///< c'tor + + //> d'tor + ~OptDsc(){} + + /** + * returns the name of this option + * @return rtl::OString& + */ + inline rtl::OString& getName() { return m_name; } + /** + * returns the hint of this option + * @return rtl::OString& + */ + inline rtl::OString& getHint() { return m_hint; } + /** + * returns the legend of this option + * @return rtl::OString& + */ + inline rtl::OString& getLegend() { return m_legend; } + + /** + * returns the type of this option + * @return optType + */ + inline optType getType() { return m_type; } + + + inline sal_Bool isFlag() { + return( ( m_type &~ 0xfffe ) == OT_BOOL ) ? sal_True : sal_False; + } + inline sal_Bool isString() { + return( ( m_type &~ 0xfffd ) == OT_STRING ) ? sal_True : sal_False; + } + inline sal_Bool isNumber() { + return( ( m_type &~ 0xfffb ) == OT_NUMBER ) ? sal_True : sal_False; + } + inline sal_Bool isSingle() { + return( ( m_type &~ 0xffef ) == OT_SINGLE ) ? sal_True : sal_False; + } + inline sal_Bool isMulti() { + return( ( m_type &~ 0xffdf ) == OT_MULTI ) ? sal_True : sal_False; + } + inline sal_Bool isOptional() { + return( ( m_type &~ 0xfeff ) == OT_OPTIONAL ) ? sal_True : sal_False; + } + +}; ///:~ Option + +class Exception +{ + rtl::OString m_sAsciiMessage; +public: + Exception(); + virtual ~Exception(){} + + Exception(char const* sAsciiMessage); + Exception(rtl::OString const& sAsciiMessage); + + virtual rtl::OUString message() const; + virtual char const* what() const; +}; + +class ValueNotFoundException : public Exception +{ +public: + ValueNotFoundException(); + ValueNotFoundException(char const* sExit); +}; + +//: GetOpt +class GetOpt { + + rtl::OString m_prgname; + rtl::OString m_vardelim; + std::vector< rtl::OString > m_cmdline; + std::vector< rtl::OString > m_param; + std::vector< rtl::OString > m_varvec; + std::vector< OptDsc* > m_optionset; + optHashMap m_opthash; + + //> private methods + void initialize( char* cmdLine[], char const * optSet[] ); + void createCmdLineOptions(); + sal_uInt32 getMaxNameLength(); + sal_uInt32 getMaxLegendLength(); + const rtl::OString optDsc2Str( OptDsc* optDsc , sFormat frm ); + void tokenize( const rtl::OString& opt, const rtl::OString& charSet, + std::vector< rtl::OString >& optLine, sal_Bool strip = sal_True ); + ///< private methods + + GetOpt(); + GetOpt( GetOpt& ); + GetOpt& operator = ( GetOpt& ); + +public: + + //> c'tor + GetOpt( char* cmdLine[], char const * optSet[], rtl::OString varDelim = + rtl::OString( "$" ) ) + : m_vardelim( varDelim ) { + + initialize( cmdLine, optSet ); + createCmdLineOptions(); + } ///< c'tor + + //> d'tor + ~GetOpt(); + ///< d'tor + + //> inline methods + inline std::vector< rtl::OString >* getCmdLine() { return &m_cmdline; } + inline optHashMap* getOptions() { return ( &m_opthash ); } + inline rtl::OString& getName() { return m_prgname; } + inline rtl::OString& getFirstParam() { return *(m_param.begin()); } + inline std::vector< rtl::OString >& getParams() { return m_param; } + rtl::OString& getOpt( const rtl::OString& opt ); + void rmvOpt( rtl::OString& opt ) { + m_opthash.erase( opt ); + } + inline std::vector< rtl::OString >& getOptVec( const rtl::OString& opt ) { + return m_opthash[ opt ]; + } + ///< inline methods + + + sal_Bool exist( rtl::OString& opt ); + sal_Bool hasParam( std::vector< rtl::OString >::iterator iter ); + sal_Bool hasVars( void ); + sal_Bool evaluateOpt( std::vector< rtl::OString >::iterator iter ); + OptDsc* getOptDsc( rtl::OString& opt ); + sal_Bool hasOpt( const rtl::OString& opt ) const; + ::osl::FileBase::RC getIniOptions( rtl::OString iniPth ); + void createOpt( rtl::OString& optdsc ); + void str2Opt( rtl::OString iOpts ); + void addOpt( rtl::OString& opt, sal_Bool evaluate = sal_True ); + void replVars( void ); + void showUsage( void ); + void printStatus( void ); + +}; ///:~ GetOpt +#endif diff --git a/cppunit/inc/testshl/log.hxx b/cppunit/inc/testshl/log.hxx new file mode 100644 index 000000000000..a732406745d9 --- /dev/null +++ b/cppunit/inc/testshl/log.hxx @@ -0,0 +1,136 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: log.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:18:51 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************* + + Source Code Control System - Header + + $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/cppunit/inc/testshl/log.hxx,v 1.1 2008-02-27 16:18:51 lla Exp $ + + Source Code Control System - Update + +*************************************************************************/ +#ifndef __QADEV_REGSCAN_LOG_HXX__ +#define __QADEV_REGSCAN_LOG_HXX__ + +#include <time.h> + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + +#ifndef _RTL_STRBUF_HXX_ +#include <rtl/strbuf.hxx> +#endif + +#ifndef _SAL_TYPES_H_ +#include <sal/types.h> +#endif + +#ifndef _OSL_THREAD_H_ +#include <osl/thread.h> +#endif + +#ifndef _OSL_FILE_HXX_ +#include <osl/file.hxx> +#endif + +//!io #include <iostream> +#include <vector> + +// using namespace std; + + +/** + * Log derives the interface of the ::osl::File class ( is-a relation ). + * Its members (has-a relation) are the (full qualified)name of the log + * and an OStringBuffer which represents the content of the logfile. + * It provides the functionality of easy-to-use open and write logs + */ +//: Log +class Log { + + ::osl::File* m_logfile; // fileobject + rtl::OUString m_logurl; // url of log + rtl::OStringBuffer m_buf; // content of log + + Log(); + +public: + + //> c'tor + /** + * constructors argument is a full qualified UNC path + * @param OUString logfile ( full qualified UNC path ) + */ + Log( const rtl::OUString& logURL ) + : m_logfile( new ::osl::File( logURL )) + , m_logurl(logURL) + {} ///< c'tor + + //> d'tor + virtual ~Log() { + m_logfile->close(); + delete( m_logfile ); + } ///< d'tor + + //> inline methods + // returns a reference to name instance + inline rtl::OUString getLogURL() { return m_logurl; } + inline rtl::OString getName() { return rtl::OUStringToOString( + m_logurl, RTL_TEXTENCODING_ASCII_US ); } + ///< inline methods + + // open logfile for overwrite (default) or append + ::osl::FileBase::RC open( sal_Bool append = sal_False ); + ::osl::FileBase::RC close() { return m_logfile->close(); } + + + // write methods without (default) or with echo on display + ::osl::FileBase::RC write( const sal_Char* buf, sal_Bool v = sal_False ); + ::osl::FileBase::RC write( const rtl::OString& buf, + sal_Bool v = sal_False ); + // ::osl::FileBase::RC write( rtl::OStringBuffer const& buf, + // sal_Bool v = sal_False ); + ::osl::FileBase::RC write( const rtl::OUString& buf, + rtl_TextEncoding enc = RTL_TEXTENCODING_ASCII_US, + sal_Bool v = sal_False ); + +}; ///:~ Log + +Log &operator <<( Log &_aLog, const sal_Char * _sValue ); +Log &operator <<( Log &_aLog, rtl::OString const& _sValue ); +Log &operator <<( Log &_aLog, rtl::OUString const& _sValue ); +// Log &operator <<( Log &_aLog, rtl::OStringBuffer const& _sValue ); + +#endif diff --git a/cppunit/inc/testshl/tresstatewrapper.h b/cppunit/inc/testshl/tresstatewrapper.h new file mode 100644 index 000000000000..b408bcb71717 --- /dev/null +++ b/cppunit/inc/testshl/tresstatewrapper.h @@ -0,0 +1,71 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tresstatewrapper.h,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:19:45 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef TESTSTATEWRAPPER_H +#define TESTSTATEWRAPPER_H + +#ifdef _RTL_TRES_H_ +#error "This is old code, please remove the include of rtl/tres.h" +#endif + +#include <sal/types.h> +#include "cppunit/autoregister/registertestfunction.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// typedef void* hTestResult; +typedef hTestResult rtlTestResult; + +// ----------------------------------------------------------------------------- +void c_rtl_tres_state_start(hTestResult _aResult, const sal_Char* _pName); +void c_rtl_tres_state_end(hTestResult _aResult, const sal_Char* _pName); + +// ----------------------------------------------------------------------------- +// the old test state function, which here convert all values for using with the +// new testshl tool + +sal_Bool SAL_CALL c_rtl_tres_state( + hTestResult pResult, + sal_Bool bSuccess, + char const * pTestMsg, + char const * pFuncName); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/cppunit/inc/testshl/tresstatewrapper.hxx b/cppunit/inc/testshl/tresstatewrapper.hxx new file mode 100644 index 000000000000..61a9f6d95b8d --- /dev/null +++ b/cppunit/inc/testshl/tresstatewrapper.hxx @@ -0,0 +1,65 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tresstatewrapper.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:20:33 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef teststatewrapper_hxx +#define teststatewrapper_hxx + +#include <cppunit/nocopy.hxx> +#include <sal/types.h> + +#include <cppunit/simpleheader.hxx> +#include <cppunit/autoregister/callbackfunc_fktptr.h> + +// This is a hack, because it's possible that the testshl directory doesn't exist. +#ifdef LOAD_TRESSTATEWRAPPER_LOCAL +#include "tresstatewrapper.h" +#else +#include <testshl/tresstatewrapper.h> +#endif + +// ----------------------------------------------------------------------------- +// helper class to mark the start off old test code +// the name is need in the test result generator +class rtl_tres_state_start : NOCOPY +{ + const sal_Char* m_pName; + hTestResult m_aResult; +public: + rtl_tres_state_start(hTestResult _aResult, const sal_Char* _pName); + ~rtl_tres_state_start(); +}; + +#endif + diff --git a/cppunit/inc/testshl/versionhelper.hxx b/cppunit/inc/testshl/versionhelper.hxx new file mode 100644 index 000000000000..ce6516397f1d --- /dev/null +++ b/cppunit/inc/testshl/versionhelper.hxx @@ -0,0 +1,92 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: versionhelper.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:19:03 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef AUTOREGISTER_HXX +#define AUTOREGISTER_HXX + +#include <stdio.h> +#include <vector> +#include <ostream> +#include <iostream> + +#include <rtl/ustring.hxx> +#include <rtl/string.hxx> + +#include "dynamicregister.hxx" + +// ----------------------------------------------------------------------------- +// ---------------------------------- Version ---------------------------------- +// ----------------------------------------------------------------------------- +// extern "C" const struct VersionInfo *GetVersionInfo(); + +// this is a Hack, but at the moment, no change to handle this behaviour better. +struct VersionInfo +{ + const char* pTime; + const char* pDate; + const char* pUpd; + const char* pMinor; + const char* pBuild; + const char* pInpath; +}; +typedef const struct VersionInfo* (*FktGetVersionInfoPtr)(); + +// ----------------------------------------------------------------------------- +class VersionHelper : public DynamicLibraryHelper +{ + const VersionInfo *m_pInfo; + +public: + VersionHelper(rtl::OUString const& _sDLLName, GetOpt & _aOptions); +// void print(std::ostream& _aStream); + void printall(FILE*); + + rtl::OString getTime() const; + rtl::OString getDate() const; + rtl::OString getUpd() const; + rtl::OString getMinor() const; + rtl::OString getBuild() const; + rtl::OString getInpath() const; + + bool isOk() const; +}; + +/** insertion operator for easy output */ +// std::ostream &operator <<( std::ostream &stream, +// VersionHelper &version ); + + +#endif + diff --git a/cppunit/inc/testshl/winstuff.hxx b/cppunit/inc/testshl/winstuff.hxx new file mode 100644 index 000000000000..26dd5f9af344 --- /dev/null +++ b/cppunit/inc/testshl/winstuff.hxx @@ -0,0 +1,48 @@ +/************************************************************************* + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: winstuff.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: lla $ $Date: 2008-02-27 16:19:26 $ + * + * The Contents of this file are made available subject to + * the terms of GNU Lesser General Public License Version 2.1. + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2005 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + ************************************************************************/ + +#ifndef WINSTUFF_HXX +#define WINSTUFF_HXX + +#include <sal/types.h> + +// Isolated into own compilation unit, to avoid interference with +// windows headers +void WinDebugBreak(); +void WinSleep( sal_uInt32 sec ); +sal_uInt32 WinGetCurrentProcessId(); +void WinTerminateApp( sal_uInt32 dwPID, sal_uInt32 dwTimeout ); + +#endif |