diff --git a/CMakeLists.txt b/CMakeLists.txt index caa2d90e5..ebe52ee9f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -300,4 +300,8 @@ IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) OPTION(INSTALL_EXTRA_LIBS "Set when you want extra libraries installed" OFF) ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5) +OPTION(BUILD_UNIT_TESTS "Build Unit Tests" OFF) +IF (BUILD_UNIT_TESTS) + SUBDIRS(UnitTests) +ENDIF() diff --git a/UnitTests/BulletUnitTests/CMakeLists.txt b/UnitTests/BulletUnitTests/CMakeLists.txt new file mode 100644 index 000000000..6b3dc519b --- /dev/null +++ b/UnitTests/BulletUnitTests/CMakeLists.txt @@ -0,0 +1,17 @@ + +INCLUDE_DIRECTORIES( + ${BULLET_PHYSICS_SOURCE_DIR}/src + ${BULLET_PHYSICS_SOURCE_DIR}/UnitTests/cppunit/include + + + ${VECTOR_MATH_INCLUDE} +) + +LINK_LIBRARIES( + cppunit BulletMultiThreaded BulletDynamics BulletCollision LinearMath +) + +ADD_EXECUTABLE(AppBulletUnitTests + Main.cpp + TestBulletOnly.h +) \ No newline at end of file diff --git a/UnitTests/BulletUnitTests/Main.cpp b/UnitTests/BulletUnitTests/Main.cpp new file mode 100644 index 000000000..8d835a3aa --- /dev/null +++ b/UnitTests/BulletUnitTests/Main.cpp @@ -0,0 +1,38 @@ +#include +#include +#include +#include +#include +#include + +#include "TestBulletOnly.h" + +CPPUNIT_TEST_SUITE_REGISTRATION( TestBulletOnly ); + +int main(int argc, char* argv[]) +{ + // Create the event manager and test controller + CPPUNIT_NS::TestResult controller; + + // Add a listener that colllects test result + CPPUNIT_NS::TestResultCollector result; + controller.addListener( &result ); + + // Add a listener that print dots as test run. + CPPUNIT_NS::BriefTestProgressListener progress; + controller.addListener( &progress ); + + // Add the top suite to the test runner + CPPUNIT_NS::TestRunner runner; + runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() ); + runner.run( controller ); + + // Print test in a compiler compatible format. + CPPUNIT_NS::CompilerOutputter outputter( &result, CPPUNIT_NS::stdCOut() ); + outputter.write(); + + getchar(); + + return result.wasSuccessful() ? 0 : 1; +} + diff --git a/UnitTests/BulletUnitTests/TestBulletOnly.h b/UnitTests/BulletUnitTests/TestBulletOnly.h new file mode 100644 index 000000000..ae723a0c2 --- /dev/null +++ b/UnitTests/BulletUnitTests/TestBulletOnly.h @@ -0,0 +1,122 @@ +#ifndef TESTBULLETONLY_HAS_BEEN_INCLUDED +#define TESTBULLETONLY_HAS_BEEN_INCLUDED + +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" + +#include "btBulletDynamicsCommon.h" +#include "BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h" + +// --------------------------------------------------------------------------- + +class TestBulletOnly : public CppUnit::TestFixture +{ +public: + + void setUp() + { + // empty + } + + void tearDown() + { + // empty + } + + btRigidBody::btRigidBodyConstructionInfo buildConstructionInfo( btScalar mass, btScalar friction, btScalar restitution, btScalar linearDamping, + btScalar angularDamping, btDefaultMotionState & state, btCollisionShape * shape ) + { + btVector3 inertia; + shape->calculateLocalInertia( mass, inertia ); + btRigidBody::btRigidBodyConstructionInfo info( mass, &state, shape, inertia ); + + info.m_friction = friction; + info.m_restitution = restitution; + info.m_linearDamping = linearDamping; + info.m_angularDamping = angularDamping; + + return info; + } + + void testKinematicVelocity0() + { + // Setup the world -- + + btCollisionConfiguration * mCollisionConfig; + btCollisionDispatcher * mCollisionDispatch; + btBroadphaseInterface * mBroadphase; + btConstraintSolver * mConstraintSolver; + btDiscreteDynamicsWorld * mWorld; + + mCollisionConfig = new btDefaultCollisionConfiguration; + mCollisionDispatch = new btCollisionDispatcher( mCollisionConfig ); + mBroadphase = new btDbvtBroadphase(); + mConstraintSolver = new btSequentialImpulseConstraintSolver(); + mWorld = new btDiscreteDynamicsWorld( mCollisionDispatch, mBroadphase, mConstraintSolver, mCollisionConfig ); + + mWorld->setGravity( btVector3( 0, -9.81, 0 )); + + // -- . + + // Set up the rigid body -- + + btCollisionShape * bodyShape = new btBoxShape( btVector3( 1, 1, 1 ) ); + + btTransform bodyInitial; + btDefaultMotionState mMotionState; + + bodyInitial.setIdentity(); + bodyInitial.setOrigin( btVector3( 0, 0, 0 ) ); + + btRigidBody mRigidBody( buildConstructionInfo( 1, 0.5, 0.5, 0, 0, mMotionState, bodyShape ) ); + + mWorld->addRigidBody( &mRigidBody ); + + mRigidBody.setMassProps( 1, btVector3( 1, 1, 1 ) ); + mRigidBody.updateInertiaTensor(); + mRigidBody.setCollisionFlags( btCollisionObject::CF_KINEMATIC_OBJECT ); + + // -- . + + // Interpolate the velocity -- + + //btVector3 velocity( 1., 2., 3. ), spin( 0.1, 0.2, 0.3 ); + btVector3 velocity( 1., 2., 3. ), spin( 0.1, 0.2, .3 ); + btTransform interpolated; + + // TODO: This is inaccurate for small spins. + btTransformUtil::integrateTransform( mRigidBody.getCenterOfMassTransform(), velocity, spin, 1.0f/60.f, interpolated ); + + mRigidBody.setInterpolationWorldTransform( interpolated ); + + // -- . + + mWorld->stepSimulation( 1.f/60.f, 60, 1.0f/60.f ); + + btScalar a = 0.f; + + btScalar f = 1.f/a; + CPPUNIT_ASSERT_DOUBLES_EQUAL( mRigidBody.getLinearVelocity().length2(), velocity.length2(), 1e-8 ); +#ifdef BT_USE_DOUBLE_PRECISION + CPPUNIT_ASSERT_DOUBLES_EQUAL( mRigidBody.getAngularVelocity().length2(), spin.length2(), 1e-4 ); +#else + CPPUNIT_ASSERT_DOUBLES_EQUAL( mRigidBody.getAngularVelocity().length2(), spin.length2(), 5e-3 ); +#endif //CPPUNIT_ASSERT_DOUBLES_EQUAL + + delete mWorld; + delete mConstraintSolver; + delete mBroadphase; + delete mCollisionDispatch; + delete mCollisionConfig; + delete bodyShape; + } + + CPPUNIT_TEST_SUITE(TestBulletOnly); + CPPUNIT_TEST(testKinematicVelocity0); + CPPUNIT_TEST_SUITE_END(); + +private: + +}; + +#endif diff --git a/UnitTests/CMakeLists.txt b/UnitTests/CMakeLists.txt new file mode 100644 index 000000000..275633b6b --- /dev/null +++ b/UnitTests/CMakeLists.txt @@ -0,0 +1,2 @@ + +SUBDIRS( cppunit BulletUnitTests) diff --git a/UnitTests/cppunit/AUTHORS b/UnitTests/cppunit/AUTHORS new file mode 100644 index 000000000..b600073ca --- /dev/null +++ b/UnitTests/cppunit/AUTHORS @@ -0,0 +1,6 @@ +Michael Feathers +Jerome Lacoste +E. Sommerlade +Baptiste Lepilleur +Bastiaan Bakker +Steve Robbins diff --git a/UnitTests/cppunit/BUGS b/UnitTests/cppunit/BUGS new file mode 100644 index 000000000..64fb00f92 --- /dev/null +++ b/UnitTests/cppunit/BUGS @@ -0,0 +1,6 @@ + KNOWN BUGS + ---------- + +The handling of html and man pages in doc/Makefile.am is +flawed. It will not pass "make distcheck". + diff --git a/UnitTests/cppunit/CMakeLists.txt b/UnitTests/cppunit/CMakeLists.txt new file mode 100644 index 000000000..1468214e5 --- /dev/null +++ b/UnitTests/cppunit/CMakeLists.txt @@ -0,0 +1,74 @@ +INCLUDE_DIRECTORIES( + include +) + +ADD_LIBRARY(cppunit + +#core + src/cppunit/AdditionalMessage.cpp + src/cppunit/Asserter.cpp + src/cppunit/Exception.cpp + src/cppunit/Message.cpp + src/cppunit/SourceLine.cpp + src/cppunit/SynchronizedObject.cpp + src/cppunit/Test.cpp + src/cppunit/TestAssert.cpp + src/cppunit/TestCase.cpp + src/cppunit/TestComposite.cpp + src/cppunit/TestFailure.cpp + src/cppunit/TestLeaf.cpp + src/cppunit/TestPath.cpp + src/cppunit/TestResult.cpp + src/cppunit/TestRunner.cpp + src/cppunit/TestSuite.cpp + +#extension + src/cppunit/RepeatedTest.cpp + src/cppunit/TestCaseDecorator.cpp + src/cppunit/TestDecorator.cpp + src/cppunit/TestSetUp.cpp + +#helper + src/cppunit/TestFactoryRegistry.cpp + src/cppunit/TestNamer.cpp + src/cppunit/TestSuiteBuilderContext.cpp + src/cppunit/TypeInfoHelper.cpp + +#listener + src/cppunit/BriefTestProgressListener.cpp + src/cppunit/TestResultCollector.cpp + src/cppunit/TestSuccessListener.cpp + src/cppunit/TextTestProgressListener.cpp + src/cppunit/TextTestResult.cpp + +#output + src/cppunit/CompilerOutputter.cpp + src/cppunit/TextOutputter.cpp + src/cppunit/XmlOutputter.cpp + src/cppunit/XmlOutputterHook.cpp + +#plugin + src/cppunit/BeOsDynamicLibraryManager.cpp + src/cppunit/DynamicLibraryManager.cpp + src/cppunit/DynamicLibraryManagerException.cpp + src/cppunit/PlugInManager.cpp + src/cppunit/PlugInParameters.cpp + src/cppunit/ShlDynamicLibraryManager.cpp + src/cppunit/TestPlugInDefaultImpl.cpp + src/cppunit/UnixDynamicLibraryManager.cpp + src/cppunit/Win32DynamicLibraryManager.cpp + +#protector + src/cppunit/DefaultProtector.cpp + src/cppunit/Protector.cpp + src/cppunit/ProtectorChain.cpp + +#textui + src/cppunit/TextTestRunner.cpp + +#tools + src/cppunit/StringTools.cpp + src/cppunit/XmlDocument.cpp + src/cppunit/XmlElement.cpp + +) \ No newline at end of file diff --git a/UnitTests/cppunit/ChangeLog b/UnitTests/cppunit/ChangeLog new file mode 100644 index 000000000..210aae345 --- /dev/null +++ b/UnitTests/cppunit/ChangeLog @@ -0,0 +1,3749 @@ +2010-July-23 Erwin Coumans + * add cmake build support, removed other build systems + +2009-11-24 Baptiste Lepilleur + * src/cppunit/TestResult.cpp: flush stdout & stderr in destructor + to avoid message loss in case of crash (bug #2832029). + + * include/cppunit/plugin/TestPlugIn.h: + * include/cppunit/plugin/TestPlugInDefaultImpl.h: added missing dllexport + for CppUnitTestPlugIn. + + * include/cppunit/portability/config-msvc6.h: + * include/cppunit/portability/Portability.h: Added macro + CPPUNIT_UNIQUE_COUNTER on MSVS 7.0+ using __COUNTER__ to + fix bug #2031696. + + * examples/examples2008.sln: Fixed compilation issue in debug + configuration with VS2008 (due to incorrect configuration + being picked up). + + * src/msvc6/testpluginrunner/TestPlugInRunnerDlg.cpp: fixed + memory leak in getCommandLineArguments() (bug #1721408). + + * config/ax_cxx_gcc_abi_demangle.m4: + * src/cppunit/TypeInfoHelper.cpp: Fixed demangling of symbols on gcc 4.3 + (bug #2796543). + +2009-11-23 Baptiste Lepilleur + + * src/DllPlugInTester/Makefile.am: + * examples/cppunittest/Makefile.am: + * examples/money/Makefile.am: + * examples/simple/Makefile.am: + * examples/hierarchy/Makefile.am: Applied patch #2807259 + contributed by Jan Echternach. LIBADD_DL contains a list of libraries + like "-ldl". Thus, it should be in LDADD instead of LDFLAGS in case + one of the libraries depends on a path set in LDFLAGS. + +2008-12-16 Andy Dent + * src/msvc6/testrunner/MsDevCallerListCtrl.cpp: + * INSTALL-VS.Net2008.txt: Added updated project and instructions for + building under Visual Studio.Net 2008 and fixed compilation issue. + +2008-10-12 Baptiste Lepilleur + + * doc/cookbook.dox: fixed typos. + +2008-02-21 Steve M. Robbins + * examples/cppunittest/OrthodoxTest.h: + * examples/cppunittest/XMLOutputterTest.cpp: + * examples/hierarchy/main.cpp: + * include/cppunit/extensions/ExceptionTestCaseDecorator.h: + * src/cppunit/BriefTestProgressListener.cpp: + * src/cppunit/TestFactoryRegistry.cpp: + * src/cppunit/TestPlugInDefaultImpl.cpp: + * src/cppunit/TestSuccessListener.cpp: + * src/cppunit/TextProgressListener.cpp: + * src/cppunit/XmlOutputterHook.cpp: + * src/DllPlugInTester/CommandLineParserTest.cpp: + * src/DllPlugInTester/DllPlugInTesterTest.cpp: Changes to suppress + warnings of gcc -Wall -W -ansi, mainly from patch [1898225]. + +2008-02-20 Steve M. Robbins + + * examples/money/MoneyTest.h (TestFixture): Change deprecated + CPPUNIT_TEST_EXCEPTION to simple CPPUNIT_TEST. + * examples/money/MoneyTest.cpp (testAddThrow): Wrap throwing + expression "money += money123FF" inside CPPUNIT_ASSERT_THROW(). + + * Changes to build without warnings using gcc -Wall -W -ansi. + Applied patch [1898225] to remove name of unused argument and use + no-arg version of main(). Tested on both GCC 4.2.3 and a + prerelease of GCC 4.3.0. + * examples/cppunittest/assertion_traitsTest.cpp (test_toString): + Change template parameter of + CPPUNIT_NS::assertion_traits::toString() to const char*, + avoiding a deprecated conversion from string literal to char*. + * src/DllPlugInTester/CommandLineParserTest.cpp (parse): move + semicolon of empty loop body to its own line, avoiding a warning + in GCC 4.3. + +2008-02-20 Steve M. Robbins + + * configure.in: Update CPPUNIT_MICRO_VERSION for release 1.12.1. + +2008-02-07 Steve M. Robbins + + * src/qttestrunner/MostRecentTests.h: + * src/qttestrunner/TestRunnerModel.h: Change from to + replacment ; avoids use of compatibility headers. + +2007-03-04 Steve M. Robbins + + * include/cppunit/portability/FloatingPoint.h (floatingPointIsFinite): Change + return type to int, following the convention of isfinite(), finite(), etc. + +2007-02-25 Baptiste Lepilleur + + * doc/cookbook.dox: changed suite() to return a TestSuite instead + of a Test to avoid introducing unnecessary complexity. + +2007-02-24 Steve M. Robbins + + * include/cppunit/portability/FloatingPoint.h: Include Portability.h. + +2007-02-24 Baptiste Lepilleur + + * src/cppunit/TestAssert.cpp (assertDoubleEquals): Moved finite & NaN + tests to include/cppunit/portability/FloatingPoint.h. Changed + implementation assertDoubleEquals to explicitly test for NaN + in case of non-finite values to force equality failure in the + presence of NaN. Previous implementation failed on Microsoft + Visual Studio 6 (on this platform: NaN == NaN). + * examples/cppunittest/TestAssertTest.cpp: Add more unit tests to + test the portable floating-point primitive. Added missing + include . + + * include/cppunit/portability/Makefile.am: + * include/cppunit/portability/FloatingPoint.h: Added file. Extracted + isfinite() from TestAssert.cpp. + + * include/cppunit/config-evc4: + * include/cppunit/config-msvc6: Added support for _finite(). + +2007-01-30 Steve M. Robbins + + * examples/cppunittest/assertion_traitsTest.h: + * examples/cppunittest/assertion_traitsTest.cpp: New. Test + assertion_traits<>. + + * examples/cppunittest/Makefile.am: Add + assertion_traitsTest.{h,cpp}. + + * examples/cppunittest/TestAssertTest.h: + * examples/cppunittest/TestAssertTest.cpp: Add + testAssertDoubleEqualsPrecision() to test precision of failure + message. + +2007-01-27 Steve M. Robbins + + * examples/cppunittest/TestAssertTest.cpp: + * examples/cppunittest/TestAssertTest.h: Remove declaration of + unimplemented functions testAssertDoubleNotEquals1 and + testAssertDoubleNotEquals2. Factor new method + testAssertDoubleNonFinite out of existing testAssertDoubleEquals. + + * src/cppunit/Win32DynamicLibraryManager.cpp (doLoadLibrary): + Unconditionally use ANSI version of LoadLibrary() and other + functions with string arguments. + +2007-01-26 Steve M. Robbins + + * config/ax_cxx_have_isfinite.m4: New. Autoconf macro that tests + for finite() in C++ mode. + * configure.in: Check for isfinite() and finite(). + + * examples/cppunittest/TestAssertTest.cpp (testAssertDoubleEquals): + * src/cppunit/TestAssert.cpp (assertDoubleEquals): Account for + non-finite values. + +2007-01-11 Steve M. Robbins + + * examples/cppunittest/MockFunctor.h: + * examples/cppunittest/MockProtector.h: + * examples/cppunittest/XmlOutputterTest.cpp: + * examples/cppunittest/XmlUniformiser.cpp: + * src/DllPlugInTester/CommandLineParser.cpp: + * src/cppunit/DynamicLibraryManagerException.cpp: + * src/cppunit/TestCaseDecorator.cpp: + * src/cppunit/TextTestRunner.cpp: + * src/cppunit/XmlDocument.cpp: Arrange field initializers in + correct order. + + * include/cppunit/plugin/TestPlugIn.h (struct CppUnitTestPlugIn): + * include/cppunit/extensions/TestFixtureFactory.h (class TestFixtureFactory): + * include/cppunit/XmlOutputterHook.h (XmlOutputterHook): Add + virtual destructor to virtual class. + + * examples/cppunittest/TestAssertTest.cpp: Put a C++ statement in + the first argument of CPPUNIT_ASSERT_THROW() and + CPPUNIT_ASSERT_NO_THROW(). + + * examples/hierarchy/main.cpp (main): Return value now reflects + whether tests passed. + * examples/hierarchy/Makefile.am (XFAIL_TESTS): New. Mark hierachy + test program as an expected failure. + + * Makefile.am (dist-hook): Don't fail if $(distdir)/lib already + exists. + + * config/bb_enable_doxygen.m4 (BB_ENABLE_DOXYGEN): Add quotes + around function name, BB_ENABLE_DOXYGEN. + +2006-10-26 Baptiste Lepilleur + * include/cppunit/TestResult.h: + * include/cppunit/ui/Config.h: fixed compilation issues with QtTestRunner. + +2006-06-29 Baptiste Lepilleur + * Makefile.am: + * lib/.keepme: added dummy file to prevent lib/ removal by some + unzip clients. Fixed bug #1527877 . + + * src/msvc6/TesRunner/TestRunner.rc: + * src/msvc6/testpluginrunner/TestPlugInRunner.rc: Fixed bug #1528212 + (some resources wrongly tagged as French). + +2006-06-29 Baptiste Lepilleur + * include/cppunit/ui/text/TextTestRunner.h + * src/cppunit/TextTestRunner.cpp: applied patch #1210013 to remove + hidden virtual function warning. + + * autogen.sh: applied patch #1449380 contributed by Sander Temme + to allow running autogen on Mac OS X. + + * doc/header.html: updated to handle new tabs css required for + html doc generated with doxygen 1.4.7. + + * src/msvc6/testrunner/MsDevCallerListCtrl.cpp: applied correction + provided to fix bug #1498175 (double click on failure does not + goto failure). + +2006-03-04 Baptiste Lepilleur + * contrib/xml-xsl/report.xsl: reported correction posted on the wiki. + + * removed debian/ directory. An up to date patch can be found at: + packages.debian.org. + + * cppunit.spec.in: applied patch #1242905 partially (%post and %postun). + + * cppunit.pc.in: + * configure.in: + * Makefile.am: integrated patch from Robert Leight to generate pkg-config. + +2006-02-04 Baptiste Lepilleur + * include/cppunit/TestListener.h: + * src/qttestrunner/TestRunnerModel.cpp: removed compilation warning. + +2006-02-01 Baptiste Lepilleur + * examples/qt: integrated Ernst patch from qt examples. + +2005-12-12 Baptiste Lepilleur + * src/qttestrunner: integrated Ernst patch for QtTestRunner and Qt 3.x. + Enhanced qmake project files to handle multiple build configuration + +2005-11-27 Baptiste Lepilleur + * doc/cookbook.dox: fixed type (patch #1334567) + +2005-11-06 Baptiste Lepilleur + * include/cppunit/config/SourcePrefix.h: disable warning #4996 + (sprintf is deprecated) for visual studio 2005. + + * include/cppunit/TestAssert.h: use sprintf_s instead of sprintf for + visual studio 2005. + + * examples/ClockerPlugIn/ClockerPlugIn.cpp + * examples/DumperPlugIn/DumperPlugIn.cpp: use SourcePrefix.h. Fixed + wrong macro usage to implement DllMain. + + * examples/msvc6/HostApp/ExamplesTestCase.h + * examples/msvc6/HostApp/ExamplesTestCase.cpp + * examples/simple/ExamplesTestCase.h + * examples/simple/ExamplesTestCase.cpp: removed divideByZero test case + as it cause some crash on some platforms. + + +2005-10-27 Baptiste Lepilleur + * include/cppunit/TestAssert.h: added missing #include + +2005-07-30 Baptiste Lepilleur + * include/cppunit/config/SourcePrefix.h: added, prefix added at begining of sources + to remove warning. Removed most warning when compiling with VC++ 6sp6. + + * examples/money/Money.h: + * examples/money/MoneyTest.cpp: added assert equal usage. + +2005-07-30 Baptiste Lepilleur + + * include/cppunit/config/config-msvc6.h: auto-detect if RTTI are enabled + the _CPPRTTI macro (defined by the compiler when enabling RTTI). + + * include/cppunit/config/config-msvc6.h: added missing macro definition + CPPUNIT_HAVE_CPP_CAST. + + * src/cppunit/TestResultCollector.cpp: fixed memory leak in destructor. + +2005-07-15 Baptiste Lepilleur + + * config/bb_enable_doxygen.m4: Rolled back Brad Hards patch as it break + generation of doc/Makefile.am. + + * cppunit.spec.in: Applied patch #1232555 from Patrice Dumas. This file is + use for RPM packaging. + + * development snapshot release 1.11.0. + +2005-07-09 Baptiste Lepilleur + + * doc/Money.dox: + * include/cppunit/TestSuite.h: + * include/cppunit/XmlOutputterHook.h: applied Brad Hards patch + that correct miscellaneous doc generation issues (unescaped <>, \...). + + * include/cppunit/plugin/TestPlugIn.h: + * include/cppunit/CompilerOutputter.h: + * doc/CppUnit-win.dox: removed a few documentation generation warnings. + + * config/bb_enable_doxygen.m4: applied Brad Hards patch to remove warning + when running ./autogen.sh or aclocal. + + * doc/money.dox: fixed bad usage of CPPUNIT_ASSERT_EQUALS. + +2005-07-05 Baptiste Lepilleur + + * Examples/simple/Makefile.am: do not install 'simple' programm + (patch #1230784). + +2005-07-05 Baptiste Lepilleur + + * include/cppunit/TestResultCollector.h + * src/cppunit/TestResultCollector.cpp: fixed memory leak + occuring when calling reset(). + + * src/cppunit/DllMain.cpp: added work-around for mingw compilation + for BLENDFUNCTION macro issue when including windows.h. + + * src/qttestrunner/TestRunnerDlgImpl.cpp: fixed display of multiline + messages. + + * include/cppunit/Portability.h: better integration of compiler output + for gcc on Mac OS X with Xcode (contributed by Claus Broch). + +2005-06-14 Baptiste Lepilleur + * src/msvc6/testrunner/ProgressBar.cpp: applied patch from bug #1165875, + (use system color for border instead of hard-coded color). + + * src/cppunit/Makefile.am: + * configure.in: MinGW, cygwin: enable build of shared library when using + libtool. patch #1194394 contributed by Stéphane Fillod. + + * cppunit.m4: applied patch #1076398 contributed by Henner Sudek. Fix + version number comparison in AM_PATH_CPPUNIT. + + * contrib/xml-xsl/cppunit2junit.txt + * contrib/xml-xsl/cppunit2junit.xsl + * contrib/readme.txt: XSLT for compatibility with Ant junit xml formatter. + Patch #1112053 contributed by Norbert Barbosa. + +2005-02-23 Baptiste Lepilleur + + * examples/hierarchy/BoardGameTest.h: + * examples/hierarchy/ChessTest.h: fixed compilation issue, prefixed access + to class member with 'this' (inheriting from template parameter + dependent class). + +2004-11-19 Baptiste Lepilleur + + * include/cppunit/Message.h + * include/cppunit/SourceLine.h: + * src/cppunit/Message.cpp: + * src/cppunit/SourceLine.cpp: provided thread-safe copy constructor on + platform that do not provide thread-safe copy constructor for std::string. + +2004-11-08 Baptiste Lepilleur + + * include/cppunit/TestAssert.h: fixed portability bug pointed out by + Neil Ferguson. + +2004-11-06 Baptiste Lepilleur + + * include/cppunit/TestAssert.h: integrated Neil Ferguson patch for high + precision conversion to string for double number. Modified the patch + to works even if DBL_DIG C99 macro is not defined. + + * include/cppunit/Portability.h: fixed EVC++ 4 detection. + + * src/cppunit/Win32DynamicLibraryManager.cpp: integrated patch #1024428, + MinGW compilation under Windows XP. + +2004-11-05 Baptiste Lepilleur + + * include/cppunit/TestAssert.h: + * src/cppunit/TestAssert.cpp: integrated Neil Ferguson patch for missing + _MESSAGE assertion variants. Also enhanced the failure message of a + few assertions. + +2004-09-10 Baptiste Lepilleur + + * src/msvc6/DSPlugIn/StdAfx.h: add #error to prevent compilation on VC 7. + + * src/msvc6/testrunner/MsDevCallerListCtrl.cpp: + * src/msvc6/testrunner/MsDevCallerListCtrl.h: integrated go to source line + features on double click contributed by Max Quatember and + Andreas Pfaffenbichler. + +2004-08-01 Baptiste Lepilleur + + * include/cppunit/XmlOutputter.h: + * include/cppunit/tools/XmlDocument.h: + * src/cppunit/XmlDocument.cpp: + * src/cppunit/XmlOutputter.cpp: integrated patch #997006 from Akos Maroy. + This patch makes the 'standalone' attribute in XML header optional. + +2004-06-25 Baptiste Lepilleur + + * include/cppunit/Portability.h: moved OStringStream alias definition to + portability/Stream.h. User need to define EVC4 to indicate that + config-evc4.h should be used. (how to we detect this automatically ?). + Notes that this means it might be needed to add #include to some + headers since its no longer included by Portability.h. + + * include/cppunit/portability/Stream.h: define alias OStringStream, stdCOut(), + and OFileStream. If CPPUNIT_NO_STREAM is defined (evc4 config), then provides + our own implementation (based on sprintf and fwrite). + + * include/cppunit/config/config-evc4.h: config file for embedded visual c++ 4. + Still need to detect for this platform in Portability.h (currently relying on + EVC4 being defined...) + + * *.[cpp/h]: most source files have been impacted with the following change: + #include -> #include + std::ostream -> CPPUNIT_NS::OStream + std::ofstream -> CPPUNIT_NS::OFileStream + std::cout -> CPPUNIT_NS::stdCOut() + std::endl -> "\n" + Also, code using std::cin as been defined out if CPPUNIT_NO_STREAM was defined. + The exact list of impact files can be obtain in CVS using tags: + TG_CPPUNIT_NO_STREAM_BEFORE & TG_CPPUNIT_NO_STREAM_AFTER. + +2004-06-19 Baptiste Lepilleur + + * cppunit.m4: patch #946302, AM_PATH_CPPUNIT doesn't report result + if CppUnit is missing. + + +2004-06-18 Baptiste Lepilleur + + * Release 10.0.2 + + * include/cppunit/extension/TestSuiteBuilderContext.h: + * src/cppunit/TestSuiteBuilderContext.cpp: fixed bug #921843. This bug + was caused by a known STL bug in VC++ 6. + See http://www.dinkumware.com/vc_fixes.html issue with shared + std::map in dll. As a work-around the map has been replaced by a vector. + + * src/DllPlugInTester/*.cpp: bug #941625, string literal using char * + instead of const char *. Patch contributed by Curt Arnold has been + applied. + + * src/msvc6/testrunner/TestRunnerDlg.h: + * src/msvc6/testrunner/TestRunnerDlg.cpp: + * src/msvc6/testpluginrunner/TestPlugIn.cpp: + * src/msvc6/testpluginrunner/TestPlugInRunnerApp.cpp: + * src/msvc6/testpluginrunner/TestPlugInRunnerModel.cpp: + * src/msvc6/testpluginrunner/TestPlugInRunnerModel.h: bug #952912, + memory leaks when loading/reloading plug-ins. + +2004-06-17 Baptiste Lepilleur + + * include/cppunit/Portability.h: + * include/cppunit/plugin/TestPlugIn.h: fixed report compilation issue + with mingw & cygwin. WIN32 is now always defined if _WIN32 is defined. + Bug #945737 & #930338. + + * doc/Makefile.am: fixed bug #940650 => cp -dpR, removed option -p since + there is no link to preserve anyway (does not exist on SunOs). + + * src/cppunit/TestPath.cpp: bug #938753, array bound read in + splitPathString() with substr if an empty string is passed. + + * src/*/*.dsp: bug #933154, post build fail in directory with spaces. + + +2004-06-16 Baptiste Lepilleur + + * release 1.10.0 + + * install-UNIX.txt: added some notes concerning Sun CC 5.5 & AIX. + + * examples/*/*.dsp: fixed project settings (rtti not enabled). + +2004-03-13 Baptiste Lepilleur + + * release 1.9.14 + +2004-03-13 Baptiste Lepilleur + + * cppunit-config.in: bug #903363, missing -ldl from the output of + cppunit-config --libs. Fixed thanks Eric Blossom patch. + + * examples/qt/Main.cpp: + * examples/qt/ExampleTestCase.h: fixed bug #789672: QT example should + use CPPUNIT_NS macro. + + * src/cppunit/UnixDynamicLibraryManager.cpp: applied patch #816563 + from Gareth Sylvester. Adding RTLD_GLOBAL allows test plug-ins + to provide symbols to shared objects they load themselves. + + * examples/cppunittest/TestAssertTest.h: + * examples/cppunittest/TestAssertTest.cpp: + * examples/cppunittest/XmlUniformiserTest.h: + * examples/cppunittest/XmlUniformiserTest.cpp: + * include/cppunit/TestAssert.h: add the exception assertion macros + from cppunit 2: CPPUNIT_ASSERT_THROW, CPPUNIT_ASSERT_NO_THROW, + CPPUNIT_ASSERT_ASSERTION_FAIL, CPPUNIT_ASSERT_ASSERTION_PASS. + Updated unit test to use and test the new macros. + + * include/cppunit/extensions/HelperMacros.h: deprecated the + test case factory that check for exception (CPPUNIT_TEST_FAIL & + CPPUNIT_TEST_EXCEPTION). + + +2004-02-20 Baptiste Lepilleur + + * release 1.9.12 + +2004-02-18 Baptiste Lepilleur + + * configure.in: + * makefile.am: + * config/ax_cxx_gcc_abi_demangle.m4: + * src/cppunit/TypeInfoHelper.cpp: added patch from + Neil Ferguson to use gcc c++ abi to demangle typeinfo + name when available. + +2003-05-15 Baptiste Lepilleur + + * include/cppunit/plugin/testplugin.h: fixed bug #767358, wrong + preprocessor symbol for SHL_LOADER. + +2003-05-15 Baptiste Lepilleur + + * include/cppunit/config/config-msvc6.h: changed the compiler outputter + default format (CPPUNIT_COMPILER_LOCATION_FORMAT) for Visual Studio 7.0. + Assertion now appears in the task list. + +2003-05-07 Baptiste Lepilleur + + * include/cppunit/extensions/Makefile.am: removed TestSuiteBuilder.h + + * Makefile.am + * configure.in + * config/ac_dll.m4 + * examples/cppunittest/Makefile.am + * examples/hierarchy/Makefile.am + * examples/money/Makefile.am + * examples/simple/Makefile.am + * include/cppunit/config/SelectDllLoader.h + * include/cppunit/plugin/TestPlugIn.h + * include/cppunit/tools/Algorithm.h + * src/DllPlugInTester/Makefile.am + * src/cppunit/Makefile.am + * src/cppunit/TestDecorator.cpp + * src/cppunit/ShlDynamicLibraryManager.cpp + * src/cppunit/UnixDynamicLibraryManager.cpp + * src/cppunit/Win32DynamicLibraryManager.cpp: applied patch from + Abdessattar Sassi to add support + for plug-in to hp-ux (patch #721546). + + * INSTALL-unix: added build instruction for HP-UX. + +2003-04-06 Baptiste Lepilleur + + * include/cppunit/extensions/TestSuiteBuilder.h: removed (unused) + +2003-03-31 Baptiste Lepilleur + + * src/cppunit/DynamicLibraryManager.cpp: fixed compilation issue on Mingw + (bug #711583) + +2003-03-20 Baptiste Lepilleur + + * include/cppunit/extensions/TestNamer.h: + * src/cppunit/TestNamer.cpp: Fixed bug #704684, TestNamer has non-virtual + destructor. + +2003-03-15 Baptiste Lepilleur + + * src/msvc6/testrunner/DynamicWindow/cdxCDynamicWndEx.cpp: + * examples/msvc6/CppUnitTestApp/CppUnitTestApp.cpp: + * examples/msvc6/HostApp/HostApp.cpp: + * src/msvc6/testpluginrunner/TestPlugInRunnerApp.cpp: fixed compatibility + issues with vc7 MFC. + + * include/cppunit/tools/Algorithm.h: + * examples/cppunittest/XmlOutputterTest.cpp: + * examples/cppunittest/XmlUniformiser.*: + * src/cppunit/CompilerOutputter.cpp: + * src/cppunit/ProtectorChain.cpp: + * src/cppunit/StringTools.cpp: + * src/cppunit/TestPath.cpp: + * src/cppunit/TypeInfoHelper.cpp: + * src/cppunit/XmlElement.cpp: + * src/cppunit/XmlOutputter.cpp: + * src/DllPlugInTester/CommandLineParser.h: + * src/msvc6/testrunner/TestRunnerDlg.cpp: switched to using unsigned index in loop to + avoid signed/unsigned warning in vc7. + + * include/cppunit/extension/ExceptionTestCaseDecorator.h: removed dll export + on template (caused link error on vc7). + +2003-03-11 Baptiste Lepilleur + * config/bb_enable_doxygen.m4: + * doc/Makefile.am: applied Luke Dunstan's fix for bug #700730 (spaces not + allowed in doxygen path) + + * src/cppunit/XmlElement.cpp: + * src/examples/cppunittest/XmlUniformser.cpp: fixed bug #676505 (no space + between attributes of XmlElement). + + * include/cppunit/tools/Algorithm.h: + * src/cppunit/TestResult.cpp: + * src/msvc6/testrunner/TestRunnerModel.cpp: added removeFromSequence + algorithm in Algorithm.h to fix STLPort compatibility issue + (std::remove use the one of cstdio instead of algorithm). Bug #694971. + + * src/examples/cppunittest/TrackedTestCase.cpp: + * src/examples/cppunittest/CppUnitTestMain.cpp: + * src/examples/money/Money.h: partially applied patch #699794. Fixed + compilation issues with Borland C++ 6. + +2003-01-23 Baptiste Lepilleur + + * include/cppunit/extensions/TestNamer.h: fixed bug #662666 (missing include + for typeinfo). + +2002-12-12 Baptiste Lepilleur + + * src/cppunit/TestResult.cpp: TestFailure are no longer passed as temporary, + but explicitely instantiated on the stack. Work around AIX compiler bug. + +2002-12-03 Baptiste Lepilleur + + * include/cppunit/TextTestResult.h: added missing dll export for + operator << (bug #610119). + +2002-12-02 Baptiste Lepilleur + + * include/cppunit/plugin/DynamicLibraryManagerException.h: added constructor + to fix compilation issues on recents version of gcc and sun CC (bug #619059) + + * include/cppunit/input/XmlInputHelper.h: added. + + * src/cppunit/XmlOuputter.cpp: use iterator instead of const_iterator. + + * src/src/msvc6/testrunner/DynamicWindow/cdxCDynamicWnd.cpp: added call to + IsUp() in cdxCDynamicWnd::DoOnGetMinMaxInfo() before calling + GetBorderSize() which caused an assertion. Bug #643612. + +2002-09-10 Baptiste Lepilleur + + * include/cppunit/extensions/TestSuiteBuilderContext.h: + * src/cppunit/TestSuiteBuilderContext.cpp: added addProperty() and + getStringProperty(). Added macros CPPUNIT_TEST_SUITE_PROPERTY. + + * src/msvc6/testrunner/TestRunnerDlg.cpp: integrated Tim Threlkeld's + bug fix #610162: browse button was disabled if history was empty. + + * src/msvc6/testrunner/DynamicWindow/cdxCSizeIconCtrl.cpp: integrated + Tim Threlkeld's bug fix #610191: common control were not initialized. + + * include/cppunit/extensions/ExceptionTestCaseDecorator.h: bug #603172, + missing Message construction. + + * src/cppunit/DefaultProtector.cpp: bug #603172. Fixed missing ';'. + + * src/cppunit/TestCase.cpp: bug #603671. Removed unguarded typeinfo + include. + + * examples/cppunittests/*Suite.h: bug #603666. Added missing Portability.h + include. + +2002-09-01 Baptiste Lepilleur + + * include/cppunit/ui/text/TextTestRunner.h: fixed header guards. + +2002-08-29 Baptiste Lepilleur + + * include/cppunit/TestResult.h: + * src/cppunit/TestResult.cpp: fixed shouldStop() bug. + +2002-08-29 Baptiste Lepilleur + + * include/cppunit/CompilerOutputter.h: + * include/cppunit/Exception.h: + * include/cppunit/Protector.h: + * include/cppunit/TestListener.h: + * include/cppunit/TestPath.h: + * include/cppunit/TestResult.h: + * include/cppunit/TestRunner.h: + * include/cppunit/XmlOutputter.h: + * include/cppunit/plugin/DynamicLibraryManager.h: + * include/cppunit/plugin/PlugInManager.h: + * include/cppunit/plugin/PlugInParameters.h: + * include/cppunit/TestPlugIn.h: + * src/cppunit/DefaultProtector.h: + * src/cppunit/ProtectorChain.h: + * src/cppunit/ProtectorContext.h: + * src/cppunit/TestCase.cpp: + * src/cppunit/TestResult.cpp: fixed a dew documentation bugs. + + * include/cppunit/TestResult.h: + * src/cppunit/TestResult.cpp: moved documentation to header. + +2002-08-29 Baptiste Lepilleur + + * include/cppunit/Asserter.h: + * include/cppunit/Message.h: + * include/cppunit/extensions/TestNamer.h: + * include/cppunit/extensions/TestSuiteBuilder.h: + * include/cppunit/tools/XmlDocument.h: + * include/cppunit/tools/XmlElement.h: Fixed a few documentation bugs. + +2002-08-28 Baptiste Lepilleur + + * include/cppunit/Portability.h: added CPPUNIT_STATIC_CAST. + + * include/cppunit/extensions/TestFixtureFactory.h: extracted from + HelperMacros.h. Added template class ConcretTestFixtureFactory. + + * include/cppunit/extensions/TestSuiteBuilderContext.h: + * src/cppunit/TestSuiteBuilderContext.cpp: added. Context used + to add test case to the fixture suite. Prevent future + compatibility break for custom test API. + + * include/cppunit/extensions/HelperMacros.h: mostly rewritten. No + longer use TestSuiteBuilder. Added support for abstract test fixture + through macro CPPUNIT_TEST_SUITE_END_ABSTRACT. Made custom test API + easier to use. + + * examples/cppunittest/HelperMacrosTest.h: + * examples/cppunittest/HelperMacrosTest.cpp: updated against + HelperMacros.h changes. + +2002-08-27 Baptiste Lepilleur + + * CodingGuideLines.txt: updated for OS/390 C++ limitation. + + * examples/cppunittests/MockFunctor.h: added. Mock Functor to help + testing. + + * examples/cppunittests/MockProtector.h: qdded. Mock Protector to help + testing. + + * examples/cppunittests/TestResultTest.h + * examples/cppunittests/TestResultTest.cpp: added tests for + pushProtector(), popProtector() and protect(). + + * include/cppunit/TestAssert.h: removed default message value from + assertEquals(). Caused compilation error on OS/390. + + * include/cppunit/plugin/PlugInParameters.h: + * src/cppunit/PlugInParameters.cpp: renamed commandLine() to + getCommandLine(). + + * src/msvc6/testrunner/TestRunnerDlg.h: + * src/msvc6/testrunner/TestRunnerDlg.cpp: bug fix, disabled Browse + button while running tests. + +2002-08-22 Steve M. Robbins + + * cppunit.m4: Doc fix: MINIMUM-VERSION is not optional when using + this macro. + +2002-08-04 Baptiste Lepilleur + + * src/cppunit/XmlDocument.cpp: fixed compatility bug with C++ builder. + + * include/cppunit/plugin/Parameters.h: renamed PlugInParameters.h. + + * src/cppunit/PlugInParameter.cpp: added. Implementation of class + PlugInParameters. + + * examples/DumperPlugIn/DumperPlugIn.cpp: + * examples/ClockerPlugIn/ClockerPlugIn.cpp: + * src/DllPlugInTester/CommandLineParser.h: + * src/DllPlugInTester/CommandLineParser.cpp: + * include/cppunit/plugin/TestPlugInDefaultImpl.h: + * src/cppunit/TestPlugInDefaultImpl.cpp: + * include/cppunit/plugin/PlugInManager.h: + * src/cppunit/PlugInManager.cpp: updated against PlugInParameter + change. + +2002-08-03 Baptiste Lepilleur + + * include/cppunit/XmlOutputterHook.h: integrated Stephan Stapel + documentation update. + +2002-08-03 Baptiste Lepilleur + + * include/cppunit/Exception.h: + * src/cppunit/Exception.h: added setMessage(). + + * include/cppunit/Protector.h: + * src/cppunit/Protector.cpp: added class ProtectorGuard. Change the + reportXXX() method to support Exception passing and SourceLine. + + * include/cppunit/TestCaller.h: removed 'expect exception' features. + It is now handled by ExceptionTestCaseDecorator and TestCaller no + longer need default template argument support. + + * include/cppunit/TestCase.h: + * include/cppunit/extensions/TestCaller.h: runTest() is now public + instead of protected, so that it can be decorated. + + * include/cppunit/TestResult.h: + * src/cppunit/TestResult.h: added pushProtector() and popProtector() + methods. This allow user to specify their own exception trap when + running test case. + + * include/cppunit/extensions/TestDecorator.h: + * src/cppunit/TestDecorator.cpp: added. Extracted from TestDecorator.h. + The test passed to the constructor is now owned by the decorator. + + * include/cppunit/extensions/TestCaseDecorator.h: + * src/cppunit/TestCaseDecorator.cpp: added. Decorator for TestCase + setUp(), tearDown() and runTest(). + + * include/cppunit/extensions/ExceptionTestCaseDecorator.h: added. + TestCaseDecorator to expect that a specific exception is thrown. + + * include/cppunit/extensions/HelperMacros.h: updated against TestCaller + change. + + * src/cppunit/DefaultFunctor.h: fixed bug (did not return underlying + test return code). + + * src/cppunit/ProtectorChain.cpp: fixed bug in chaing return code. + + * src/cppunit/DefaultFunctor.h: fixed bug. + + * src/msvc6/testrunner/ActiveTest.h: + * src/msvc6/testrunner/ActiveTest.cpp: updated against + TestCaseDecorator ownership policy change. Moved inline functions + to .cpp. + + * examples/cppunittest/TestSetUpTest.cpp: updated to use MockTestCase + and against the new ownership policy. + + * examples/cppunittest/TestDecoratorTest.cpp: + * examples/cppunittest/RepeatedTestTest.cpp: updated against + TestDecorator ownership policy change. + + * examples/cppunittest/ExceptionTestCaseDecoratorTest.h: + * examples/cppunittest/ExceptionTestCaseDecoratorTest.cpp: added. Unit + tests for ExceptionTestCaseDecoratorTest. + +2002-07-16 Baptiste Lepilleur + + * include/cppunit/Protector.h: + * src/cppunit/Protector.cpp: added. Base class for protectors. + + * src/cppunit/DefaultProtector.h: + * src/cppunit/DefaultProtector.cpp: added. Implementation of the default + protector used to catch std::exception and any other exception. + + * src/cppunit/ProtectorChain.h: + * src/cppunit/ProtectorChain.cpp: added. Implementation of a chain of + protector, allowing catching custom exception and implementation of + expected exception. + + * src/cppunit/TestCase.cpp: + * src/cppunit/TestResult.cpp: updated to use protector. + +2002-07-14 Baptiste Lepilleur + + * CodingGuideLines.txt: added. CppUnit's coding guidelines for portability. + + * include/cppunit/portability/CppUnitStack.h: added. wrapper for std::stack. + + * include/cppunit/portability/CppUnitSet.h: added. wrapper for std::set. + + * include/cppunit/ui/text/TestRunner.h: fixed namespace definition for + deprecated TestRunner. + + * include/cppunit/TestAssert.h: + * src/cppunit/TestAssert.cpp: removed old deprecated functions that did + not use SourceLine. Moved assertEquals() and assertDoubleEquals() into + CppUnit namespace. + + * src/cppunit/TestFactoryRegistry.cpp: use CppUnitMap instead of std::map. + + * src/DllPlugInTester/CommandLineParser.h: use CppUnitDeque instead + std::deque. + + * examples/cppunittest/*.h: + * examples/cppunittest/*.cpp: removed all usage of CppUnitTest namespace. + Everything is now in global space. + + * examples/*/*.h: + * examples/*/*.cpp: replaced usage of CppUnit:: with CPPUNIT_NS::. + + * examples/ClockerPlugIn/ClockerModel.h: use CppUnit STL wrapper instead + of STL container. + +2002-07-13 Baptiste Lepilleur + + * include/cppunit/ui/text/TestRunner.h: + * src/cppunit/TextTestRunner.cpp: Renamed TextUi::TestRunner + TextTestRunner and moved it to the CppUnit namespace. Added + a deprecated typedef for compatibility with previous version. + + * include/cppunit/ui/text/TextTestRunner.h: added. + + * include/cppunit/ui/mfc/TestRunner.h: + * src/cppunit/msvc6/testrunner/TestRunner.cpp: Renamed MfcUi::TestRunner + MfcTestRunner. Added deprecated typedef for compatibility. Renamed + TestRunner.cpp to MfcTestRunner.cpp. + + * include/cppunit/ui/mfc/MfcTestRunner.h: added. + + * include/cppunit/ui/qt/TestRunner.h: + * src/qttestrunner/TestRunner.cpp: renamed QtUi::TestRunner QtTestRunner + and moved it to CppUnit namespace. Added a deprecated typedef for + compatibility. Renamed TestRunner.cpp to QtTestRunner.cpp. + + * include/cppunit/ui/qt/TestRunner.h: + * src/qttestrunner/TestRunner.h: Moved TestRunner to CppUnit namespace + and renamed it QtTestRunner. Added deprecated typedef for compatibility. + + * include/cppunit/Asserter.h: + * src/cppunit/Asserter.cpp: changed namespace Asserter to a struct and + made all methods static. + + * include/cppunit/extensions/HelperMacros.h: + * include/cppunit/extensions/SourceLine.h: + * include/cppunit/extensions/TestAssert.h: + * include/cppunit/extensions/TestPlugIn.h: + * include/cppunit/Portability.h: changed CPPUNIT_NS(symbol) to a + symbol macro that expand either to CppUnit or nothing. The symbol is + no longer a parameter. + + * include/cppunit/portability/CppUnitVector.h: + * include/cppunit/portability/CppUnitDeque.h: + * include/cppunit/portability/CppUnitMap.h: added. STL Wrapper for + compilers that do not support template default argumenent and need + the allocator to be passed when instantiating STL container. + + * examples/cppunittest/*.h: + * examples/cppunittest/*.cpp: + * src/msvc6/testrunner/*.h: + * src/msvc6/testrunner/*.cpp: + * src/msvc6/testpluginrunner/*.h: + * src/msvc6/testpluginrunner/*.cpp: + * src/qttestrunner/*.h: + * src/qttestrunner/*.cpp: replaced occurence of CppUnit:: by CPPUNIT_NS. + + * src/cppunit/TestSuite.h: + replaced occurence of std::vector by CppUnitVector. + +2002-07-12 Baptiste Lepilleur + + * include/cppunit/config/Portability.h: If the compiler does not support + namespace (CPPUNIT_HAVE_NAMESPACES=0), define CPPUNIT_NO_STD_NAMESPACE + and CPPUNIT_NO_NAMESPACE. If CPPUNIT_NO_STD_NAMESPACE is defined, then + CppUnit assumes that STL are in the global namespace. If + CPPUNIT_NO_NAMESPACE is defined, then CppUnit classes are placed in the + global namespace instead of the CppUnit namespace. + + * include/cppunit/config/config-bcb5.h: + * include/cppunit/config/config-msvc6.h: added definition of macro + CPPUNIT_HAVE_NAMESPACES. + + * include/cppunit/tools/StringTools.h: use CPPUNIT_WRAP_COLUMN as default + parameter value for wrap(). + + * include/cppunit/*/*.h: + * src/cppunit/*.cpp: changed all CppUnit namespace declaration to use + macros CPPUNIT_NS_BEGIN and CPPUNIT_NS_END. Also, changed reference + to CppUnit namespace (essentially in macros) using CPPUNIT_NS macro. + + * doc/doxyfile.in: + * doc/CppUnit-Win.dox: updated doxygen configuration files so that + CPPUNIT_NS_BEGIN and CPPUNIT_NS_END macros are expanded. This help + generates the documentation using the CppUnit namespace. + +2002-07-11 Baptiste Lepilleur + + * include/cppunit/Portability.h: added macro CPPUNIT_CONST_CAST. + + * src/cppunit/Exception.cpp: + * src/cppunit/Test.cpp: + * examples/cppunittest/MockTestCase.cpp: replaced usage of const_cast with + CPPUNIT_CONST_CAST. + + * include/cppunit/Test.h: + * src/cppunit/Test.cpp: made findTestPath(), findTest() and resolvePath() + const methods. + +2002-07-10 Baptiste Lepilleur + + * include/cppunit/extensions/AutoRegisterSuite.h: + * include/cppunit/extensions/Orthodox.h: + * include/cppunit/extensions/TestSuiteBuilder.h: + * include/cppunit/extensions/TestSuiteFactory.h: + * include/cppunit/TestCaller.h: + * examples/hierarchy/BoardGameTest.h: + * examples/hierarchy/ChessTest.h: replaced usage of 'typename' in template + declaration with 'class'. + + * include/cppunit/ui/text/TestRunner.h: + * src/cppunit/TextTestRunner.cpp: updated to use the generic TestRunner. + Removed methods runTestByName() and runTest(). Inherits + CppUnit::TestRunner. + + * include/cppunit/extensions/TestSuiteBuilder.h: removed templatized method + addTestCallerForException(). It is no longer used since release 1.9.8. + + * examples/cppunittest/MockTestCase.h + * examples/cppunittest/MockTestCase.cpp: removed the usage of 'mutable' + keyword. + +2002-07-04 Baptiste Lepilleur + + * src/msvc6/DSPlugIn/DSPlugIn.dsp: updated so that only the release + configuration get copied to the lib/ directory. + +2002-07-03 Baptiste Lepilleur + + * include/cppunit/XmlOutputter.h: fixed XmlOutputter constructed default + value initializatino which caused compilation error with BC5. + + * src/cppunit/PlugInManager.cpp: added missing CPPUNIT_NO_TESTPLUGIN guard. + + * src/msvc6/testrunner/TestRunner.dsp: + * src/msvc6/testrunner/TestRunner.rc: + * src/msvc6/testrunner/TestRunnerDlg.cpp: + * src/msvc6/testrunner/TestRunnerDlg.h: + * src/msvc6/testrunner/TreeHierarchyDlg.cpp: + * src/msvc6/testrunner/TreeHierarchyDlg.h: + * src/msvc6/testpluginrunner/TestPlugInRunner.dsp: + * src/msvc6/testpluginrunner/TestPlugInRunner.rc: + * src/msvc6/testpluginrunner/TestPlugInRunnerApp.cpp: + * src/msvc6/testpluginrunner/TestPlugInRunnerDlg.cpp: + * src/msvc6/testpluginrunner/TestPlugInRunnerDlg.h: applied Steven Mitter + patch to fix bug #530426 (conflict between TestRunner and host + application's resources). Adapted patch to compile work with Unicode. + + * src/msvc6/testrunner/ResourceLoaders.h: + * src/msvc6/testrunner/ResourceLoaders.cpp: + * src/msvc6/testrunner/Change-Diary-ResourceBugFix.txt: added, from + Steven Mitter's patch. Simplified loadCString() to compile with Unicode. + + * src/cppunit/cppunit.dsp: + * src/cppunit/cppunit_dll.dsp: + * src/DllPlugInTester/DllPlugInTester.dsp: + * src/msvc6/testrunner/TestRunner.dsp: + * src/msvc6/testpluginrunner/TestPlugInRunner.dsp: all lib, dll and exe are + now created in the intermediate directory. A post-build rule is used to + copy them to the lib/ directory. + +2002-06-17 Baptiste Lepilleur + + * include/cppunit/AdditionalMessage.h: + * src/cppunit/AdditionalMessage.cpp: added. Class to help passing + additional message parameter. + + * include/cppunit/Asserter.h: added makeExpected(), makeActual() and + makeNotEqualMessage(). Removed methods made unnecessary by the + use of AdditionalMessage. + + * include/cppunit/Portability.h: added CPPUNIT_WRAP_COLUMN to define + CppUnit default wrap column. + + * src/cppunit/CompilerOutputter.cpp: use CPPUNIT_WRAP_COLUMN instead + of hard-coded value. + +2002-06-16 Baptiste Lepilleur + + * bumped version to 1.9.9 + + * release 1.9.8 + + * include/cppunit/plugin/TestPlugIn.h: updated documentation. + + * include/cppunit/tools/XmlDocument.h: updated documentation. + + * include/cppunit/tools/StringTools.h: + * src/cppunit/StringTools.cpp: added split() and wrap() functions. + + * include/cppunit/CompilerOutputter.h: + * src/cppunit/CompilerOutputter.cpp: extracted wrap() and + splitMessageIntoLines() to StringTools. + + * include/cppunit/XmlOutputterHook.h: + * src/cppunit/XmlOutputterHook.cpp: removed rooNode parameter from + beginDocument() and endDocument(). It can be retreive from document. + Renamed 'node' occurences to 'element'. + + * include/cppunit/XmlOutputter.h: + * src/cppunit/XmlOutputter.cpp: updated against + XmlOutputterHook changes. Renamed 'node' occurences to 'element'. + + * src/cppunit/Message.cpp: + * src/cppunit/XmlElement.cpp: added missing include + + * examples/ClockerPlugIn/ClockerXmlHook.h: + * examples/ClockerPlugIn/ClockerXmlHook.cpp: updated against + XmlOutputterHook changes. + + * examples/cppunittest/MessageTest.cpp: removed std::string() from + assertion. Somehow gcc can't parse it. Added missing include . + + * examples/cppunittest/XmlElement.cpp: added missing include . + + * examples/cppunittest/XmlElementTest.h: + * examples/cppunittest/XmlElementTest.cpp: Renamed 'node' occurences + to 'element'. + + * examples/cppunittest/XmlOutputterTest.cpp: updated against + XmlOutputterHook changes. + + * examples/cppunittest/StringToolsTest.h: + * examples/cppunittest/StringToolsTest.cpp: added. Unit tests for + StringTools. Turn out that VC++ dismiss empty lines in tools output, + which is the reason why empty lines where not printed in + CompilerOutputter. + +2002-06-14 Baptiste Lepilleur + + * include/cppunit/plugin/PlugInManager.h: + * src/cppunit/PlugInManager.cpp: added two methods to use the plug-in + interface for Xml Outputter hooks. + + * include/cppunit/plugin/TestPlugIn.h: added two methods to the plug-in + interface for Xml Outputter hooks. + + * include/cppunit/plugin/TestPlugInAdapter.h: + * src/cppunit/plugin/TestPlugInAdapter.cpp: renamed TestPlugInDefaultImpl. + Added empty implementation for Xml outputter hook methods. + + * include/cppunit/tools/StringTools.h: + * src/cppunit/tools/StringTools.cpp: added. Functions to manipulate string + (conversion, wrapping...) + + * include/cppunit/tools/XmlElement.h: + * src/cppunit/XmlElement.cpp: renamed addNode() to addElement(). Added + methods to walk and modify XmlElement (for hook). Added documentation. + Use StringTools. + + * include/cppunit/XmlOutputter.h: + * src/cppunit/XmlOutputter.cpp: added hook calls & management. + + * include/cppunit/XmlOutputterHook.h: + * src/cppunit/XmlOutputterHook.cpp: added. Hook to customize XML output. + + * src/DllPlugInTester/DllPlugInTester.cpp: call plug-in XmlOutputterHook + when writing XML output. Modified so that memory is freed before + unloading the test plug-in (caused crash when freeing the XmlDocument). + + * examples/ReadMe.txt: + * examples/ClockerPlugIn/ReadMe.txt: added details about the plug-in + (usage, xml content...) + + * examples/ClockerPlugIn/ClockerModel.h: + * examples/ClockerPlugIn/ClockerModel.cpp: extracted from ClockerListener. + Represents the test hierarchy and tracked time for each test. + + * examples/ClockerPlugIn/ClockerListener.h: + * examples/ClockerPlugIn/ClockerListener.cpp: extracted test hierarchy + tracking to ClockerModel. Replaced the 'flat' view option with a 'text' + option to print the timed test tree to stdout. + + * examples/ClockerPlugIn/ClockerPlugIn.cpp: updated to hook the XML + output and use the new classes. + + * examples/ClockerPlugIn/ClockerXmlHook.h: + * examples/ClockerPlugIn/ClockerXmlHook.cpp: added. XmlOutputterHook to + includes the timed test hierarchy and test timing in the XML output. + + * examples/cppunittest/XmlElementTest.h: + * examples/cppunittest/XmlElementTest.cpp: added new test cases. + + * examples/cppunittest/XmlOutputterTest.h: + * examples/cppunittest/XmlOutputterTest.cpp: added tests for + XmlOutputterHook. + +2002-06-14 Baptiste Lepilleur + + * src/cppunit/TypeInfoHelper.cpp: added work around for bug #565481. + gcc 3.0 RTTI name() returns the type prefixed with a number (the + length of the type). The work around strip the number. + + * src/msvc6/testpluginrunner/TestPlugInRunnerApp.cpp: registry key is now + set. Allow to save settings. + + * src/msvc6/testpluginrunner/TestPlugInRunnerDlg.h: + * src/msvc6/testpluginrunner/TestPlugInRunnerDlg.cpp: added layout + initialization for resizing. + + * src/msvc6/testpluginrunner/TestPlugRunner.rc: + * src/msvc6/testpluginrunner/TestPlugInRunner.dsp: added TestRunner + project files. Somehow I can't get cdxCDynamicDialog to compile + as a MFC extension. Included all sources files and resources + as a very dirt work around. + + * src/msvc6/testrunner/TestRunnerDlg.h: + * src/msvc6/testrunner/TestRunnerDlg.cpp: + * src/msvc6/testrunner/TestRunnerModel.h: those classes are no longer + exported in the MFC extension. See TestPlugInRunner issue with + cdxCDynamicDialog. + + * include/cppunit/Message.h: + * include/cppunit/TestPath.h: + * include/cppunit/TestResult.h: + * include/cppunit/TestResultCollector.h: + * include/cppunit/TestSuite.h: + * include/cppunit/TestFactoryRegistry.h: + * include/cppunit/XmlElement.h: + * include/cppunit/TypeInfoHelper.h: commented out STL template export + in DLL. This caused conflicts when instantiting the same template in + a user project. + +2002-06-14 Baptiste Lepilleur + + * src/cppunit/CompilerOutputter.cpp: fixed bug #549762 (line wrap). + + * src/msvc6/testrunner/DynamicWindow/*: added. Dynamic Window library + from Hans Bühler (hans.buehler@topmail.de) to resize window. + + * src/msvc6/testrunner/TestRunnerModel.h: + * src/msvc6/testrunner/TestRunnerModel.cpp: removed dialog bounds from + settings. Added public registry keys for cppunit, main dialog, and + browse dialog. + + * src/msvc6/testrunner/TreeHierarchyDlg.h: + * src/msvc6/testrunner/TreeHierarchyDlg.cpp: dialog is now resizable. + Window placement is stored and restored. + + * src/msvc6/testrunner/TestRunnerDlg.h: + * src/msvc6/testrunner/TestRunnerDlg.cpp: replaced dialog resizing code + by usage of Hans Bühler's Dynamic Window library. Dialog placement + is stored/restored by that library. ProgressBar is now a child window. + Added edit field to see the details of the failure. List on show + the short description of the failure. + + * src/msvc6/testrunner/ProgressBar.h: + * src/msvc6/testrunner/ProgressBar.cpp: is now a CWnd. + + * src/msvc6/testrunner/TestRunner.rc: named all static fill ID for resizing. + Added an invisble static field for progress bar placement. + +2002-06-13 Baptiste Lepilleur + + * doc/other_documentation.dox: fixed some typos. + + * include/cppunit/NotEqualException.h: + * src/cppunit/NotEqualException.cpp: removed. + + * include/cppunit/Exception.h: + * src/cppunit/Exception.cpp: removed 'type' related stuffs. + + * include/cppunit/TextTestResult.h: + * src/cppunit/TextTestResult.cpp: delegate printing to TextOutputter. + + * examples/simple/ExampleTestCase.h: + * examples/simple/ExampleTestCase.cpp: reindented. + + * src/qttestrunner/build: + * src/qttestrunner/qttestrunner.pro: + * src/qttestrunner/TestBrowserDlgImpl.h: + * src/qttestrunner/TestRunnerModel.h: applied Thomas Neidhart's patch, + 'Some minor fixes to compile QTTestrunner under Linux.'. + +2002-06-13 Baptiste Lepilleur + + * include/cppunit/Asserter.h: + * src/cppunit/Asserter.cpp: added functions that take a Message as a + parameter. Existing function have a short description indicating + an assertion failure. + + * include/cppunit/CompilerOuputter.h: + * src/cppunit/CompilerOuputter.cpp: removed printNotEqualMessage() and + printDefaultMessage(). Updated to use Message. + + * include/cppunit/Message.h: + * src/cppunit/Message.cpp: added. Represents a message associated to an + Exception. + + * include/cppunit/Exception.h: + * src/cppunit/Exception.cpp: the message associated to the exception is now + stored as a Message instead of a string. + + * include/cppunit/NotEqualException.cpp: constructs a Message instead of a + string. + + * include/cppunit/TestAssert.h: + * src/cppunit/TestAssert.cpp: updated to use Asserter functions that + take a message when pertinent (CPPUNIT_FAIL...). + + * include/cppunit/TestCaller.h: + * src/cppunit/TestCaller.cpp: exception not caught failure has a better + short description. + + * src/cppunit/TestCase.cpp: better short description when setUp() or + tearDown() fail. + + * src/msvc6/testrunner/TestRunnerDlg.cpp: replace '/n' in failure message + with space. + + * examples/cppunittest/ExceptionTest.cpp: + * examples/cppunittest/NotEqualExceptionTest.cpp: + * examples/cppunittest/TestCallerTest.cpp: + * examples/cppunittest/TestFailureTest.cpp: + * examples/cppunittest/TestResultCollectorTest.h: + * examples/cppunittest/TestResultCollectorTest.cpp: + * examples/cppunittest/TestResultTest.cpp: + * examples/cppunittest/XmlOutputterTest.h: + * examples/cppunittest/XmlOutputterTest.cpp: updated to use Exception/Message. + + * examples/cppunittest/MessageTest.h: + * examples/cppunittest/MessageTest.cpp: added. Unit test for Message. + +2002-06-11 Baptiste Lepilleur + + * install-unix: added some hints extracted from bug #544684 on how to compile + for Solaris/Forte C++ compiler. + + * TODO: cleaned-up and added new things. + + * include/cppunit/extensions/HelperMacros.h: CPPUNIT_TEST_SUITE now declares + a class named ThisTestFixtureFactory which is a wrapper for the fixture + factory. This removes the need to cast the fixture to the correct type when + using the factory. Updated other macros implementation to use this new + factory. Modified CPPUNIT_TEST_CUSTOM(S) macros to use this new factory + class. Added macro CPPUNIT_TEST_ADD to help create new macros like + CPPUNIT_TEST_xxx. + + * examples/cppunittest/HelperMacrosTest.h: + * examples/cppunittest/HelperMacrosTest.cpp: added unit tests for + CPPUNIT_TEST_CUSTOM, CPPUNIT_TEST_CUSTOMS and CPPUNIT_TEST_ADD. + +2002-06-01 Baptiste Lepilleur + + * doc/cookbook.dox: fixed bug. + + * install-unix: added compilation instruction for Solaris/Sun 6.0 + +2002-05-25 Baptiste Lepilleur + + * include/cppunit/extensions/TestSuiteBuilder.h: updated to use TestNamer. Removed + template method addTestCallerForException() which should solve the compilation + issue with Sun 5.0/6.0 compiler. + + * include/cppunit/extensions/HelperMacros.h: updated against TestSuiteBuilder + change. Added CPPUNIT_TEST_CUSTOM and CPPUNIT_TEST_CUSTOMS to add custom + tests to the fixture suite. + + * include/cppunit/extensions/TestNamer.h: + * src/cppunit/TestNamer.cpp: added, TestNamer to name test case and fixture. + +2002-05-23 Baptiste Lepilleur + + * include/cppunit/XmlOutputter.h: + * src/cppunit/XmlOutputter.cpp: extracted class XmlOutputter::Node to + XmlElement. Extracted xml 'prolog' generation to XmlDocument. + + * include/cppunit/tools/XmlElement.h: + * src/cppunit/tools/XmlElement.cpp: added, extracted from XmlOutputter::Node. + + * include/cppunit/tools/XmlDocument.h: + * src/cppunit/tools/XmlDocument.cpp: added, extracted from XmlOutputter. Handle + XML document prolog (encoding & style-sheet) and manage the root element. + + * src/DllPlugInTester/DllPlugInTester.cpp: bug fix, flag --xsl was ignored. + + * examples/cppunittest/XmlOutputterTest.h: + * examples/cppunittest/XmlOutputterTest.cpp: updated for XmlOuputter changes. + extracted tests for XmlOutputter::Node to XmlElementTest + + * examples/cppunittest/XmlElementTest.h: + * examples/cppunittest/XmlElementTest.cpp: added, tests extracted from + XmlOutputterTest. + +2002-05-21 Baptiste Lepilleur + + * src/msvc6/testrunner/MsDevCallerListCtrl.h: + * src/msvc6/testrunner/MsDevCallerListCtrl.cpp: + * src/msvc6/testrunner/Resource.h: + * src/msvc6/testrunner/TestRunner.rc: + * src/msvc6/testrunner/TestRunnerDlg.cpp: + * src/msvc6/testrunner/TestRunnerModel.h: + * src/msvc6/testpluginrunner/TestPlugInRunner.rc: + * src/msvc6/testpluginrunner/TestPlugInRunnerDlg.cpp: + * src/msvc6/testpluginrunner/TestPlugInRunnerDlg.h: + * src/msvc6/testpluginrunner/TestPlugInRunnerModel.cpp: integrated patch from + Marco Welti (Welti@GretagMacbeth.ch) with a few clean up. + Display the name of the test being run during above the progress bar. Allow the + VC++ add-ins to works with TestPlugInRunner (COM init). DLL name can be specified + on the command line after flag '-testsuite'. Display wait cursor, clear and reload + history when reloading DLL. + + * THANKS: added Marco Welti to the list. + +2002-05-07 Baptiste Lepilleur + + * src/DllPlugInTester/CommandLineParser.cpp: fixed compilation issue. + + * src/msvc6/TestRunner/ActiveTest.h: + * src/msvc6/TestRunner/ActiveTest.cpp: reindented. bugfix: thread + handle resource leak (bug #553424). + +2002-04-25 Baptiste Lepilleur + + * src/cppunit/XmlOutputter.cpp: bugfix, use ISO-8859-1 encoding if an + empty string is given. + + * src/DllPlugInTester/CommandLineParser.h: + * src/DllPlugInTester/CommandLineParser.cpp: + * src/DllPlugInTester/DllPlugInTester.cpp: added option -w to wait for + the user to press a key before exiting (Philippe Lavoie patch, + with change). + +2002-04-22 Baptiste Lepilleur + + * include/cppunit/plugin/DynamicLibraryManagerException.h: removed + trailing ',' in enum. + + * examples/ClockerPlugIn/ClockerListener.cpp: bugfix, average test + case time computation. + +2002-04-21 Baptiste Lepilleur + + * bumped version to 1.9.7 + + * comitted stuffs I forgot to in 1.9.6. + +2002-04-21 Baptiste Lepilleur + + * contrib/bc5/bcc-makefile.zip: updated, generic makefile for + Borland 5.5, contributed by project cuppa. + + * examples/cppunittest/*Suite.h: integrated Jeffrey Morgan's patch, + to remove warning with gcc. + + * release 1.9.6 + +2002-04-21 Baptiste Lepilleur + + * src/DllPlugInTester/makefile.am: removed ld.so from LDADD flags. + + * src/DllPlugInTester/CommandLineParser.h: + * src/DllPlugInTester/CommandLineParser.cpp: rewrote, fixed problem + with double quotes in command line... + + * src/DllPlugInTester/CommandLineParserTest.h: + * src/DllPlugInTester/CommandLineParserTest.cpp: + * src/DllPlugInTester/DllPlugInTesterTest.cpp: added, unit tests for + CommandLineParser. + + * src/msvc6/TestPlugIn/*: removed. + + * examples/Money/*: added. New 'hello world' example. + + * doc/Money.dox: added. Article that go along with the Money example. + +2002-04-21 Baptiste Lepilleur + + * THANKS: updated + + * src/cppunit/DynamicLibraryManager.cpp: bugfix: did not pass + library name to exception. + + * include/cppunit/TestPath.h: + * src/cppunit/TestPath.cpp: changed into value object. + + * src/cppunit/BeosDynamicLibraryManager.cpp: integrated patch from + Shibu Yoshiki for BeOS ('cuppa' project team). + + * src/DllPlugInTester/CommandLineParser.h: + * src/DllPlugInTester/CommandLineParser.cpp: added. Command line + parsing. + + * src/DllPlugInTester/DllPlugInTester.cpp: full command line support + with parameters for plug-ins. + + * src/DllPlugInTester/makefile.am: + * examples/simple/makefile.am: + * examples/cppunittest/makefile.am: integrated Jeffrey Morgan's patch, + Unix side should be working again. + + * examples/ReadMe.txt: added. Brief description of each example. + + * examples/cppunittest/CppUnitTestPlugIn.cpp: + * examples/cppunittest/CppUnitTestPlugIn.dsp: added. New project to + build CppUnit's test suite as a test plug-in. + + * examples/cppunittest/CppUnitTestSuite.cpp: updated. Use new + helper macros to create the test suite hierarchy. + + * examples/simple/simple_plugin.opt: added. Contains debug tab + settings. + + * examples/ClockerPlugIn/ClockerListener.cpp: + * examples/ClockerPlugIn/ClockerListener.h: + * examples/ClockerPlugIn/Timer.cpp: + * examples/ClockerPlugIn/Timer.h: + * examples/ClockerPlugIn/WinNtTimer.cpp: + * examples/ClockerPlugIn/WinNtTimer.h: + * examples/ClockerPlugIn/ClockerPlugIn.cpp: + * examples/ClockerPlugIn/ClockerPlugIn.dsp: added. test listener + plug-in that times tests. + + * examples/DumperPlugIn/DumperListener.cpp: + * examples/DumperPlugIn/DumperListener.h: + * examples/DumperPlugIn/DumperPlugIn.cpp: + * examples/DumperPlugIn/DumperPlugIn.dsp: added. test listener + plug-in that dump the test tree. + + +2002-04-19 Baptiste Lepilleur + + * src/cppunit/PlugInManager.cpp: fixed bug in unload(). + + * include/cppunit/TypeInfoHelper.h: + * src/cppunit/TypeInfoHelper.cpp: Implementation is now always available + is CPPUNIT_HAVE_RTTI is not 0. This removes the need to use + different libraries. CPPUNIT_USE_TYPEINFO_NAME can be set on a + case by case basis for HelperMacros. + + * src/cppunit/TestFactoryRegistry.cpp: removed unused include of + TypeInfoHelper.h. + + * include/cppunit/TextTestProgressListener.h: + * src/cppunit/TextTestProgressListener.cpp: used endTest() instead + of done() to finalize. + + * src/msvc6/TestPlugInRunner/TestPlugIn.h: + * src/msvc6/TestPlugInRunner/TestPlugIn.cpp: updated to use the + new test plug-in system. + + * examples/simple/SimplePlugIn.cpp: + * examples/simple/simple_plugin.dsp: crossplatform test plug-in + example using 'simple'. + + * examples/msvc6/EasyTestPlugIn/*: projects replaced with the + crossplatform projecct examples/simple/simple_plugin.dsp. + +2002-04-19 Baptiste Lepilleur + + * configure.in: added some makefile.am + + * contrib/readme.txt: updated. + + * contrib/bc5/bc5-makefile.zip: added borland 5.5 makefile. Contributed by + project cuppa. + + * src/cppunit/TypeInfoHelper.cpp: fixed implementation to be more + portable. + + +2002-04-18 Baptiste Lepilleur + + * bumped version to 1.9.3 + + * FAQ: added question about 4786 warning on VC++. + + * NEWS: updated. + + * contrib/msvc/readme.txt: moved to contrib/readme.txt. + + * contrib/xml-xsl/report.xsl: added XML style sheet contributed by + 'cuppa' project team (http://sourceforge.jp/projects/cuppa/) + + * examples/cppunittest/TestResultTest.h: + * examples/cppunittest/TestResultTest.cpp: added tests for + startTestRun()/endTestRun(). + + * examples/simple/*: added. A simple example. + + * include/cppunit/BriefTestProgressListener.h: + * src/cppunit/BriefTestProgressListener.cpp: added. Verbose progess listener + that print the test name before running the test. + + * include/cppunit/TestListener.h: added startTestRun()/endTestRun(). + + * include/cppunit/TestResult.h: + * src/cppunit/TestResult.cpp: added runTest(), to be called to run + a test by test runner. + + * src/cppunit/TextTestRunner.cpp: + * src/cppunit/TestRunner.cpp: updated to use TestResult::runTest(). + + * include/cppunit/plugin/PlugInManager.h: + * src/cppunit/PlugInManager.cpp: added. Managers for all loaded plug-ins. + + * include/cppunit/plugin/TestPlugInDefaultImpl.h: + * src/cppunit/TestPlugInDefaultImpl.cpp: renamed TestPlugInAdapter. All + implementations are empty. + + * include/cppunit/plugin/TestPlugInSuite.h: removed. + * src/cppunit/TestPlugInSuite.cpp: removed. Replaced by PlugInManager. + + * include/cppunit/plugin/TestPlugIn.h: rewrote the plug-in interface to + provide more versatility. updated macros to match new interface. + + * include/cppunit/extensions/TestFactoryRegistry.h: + * include/cppunit/extensions/TestFactoryRegistry.cpp: Added unregisterFactory(). + Added convenience method addRegistry(). Rewrote registry life cycle + management. AutoRegisterSuite can now detect that the registry has been + destroy and not call to it to unregister its test factory. + + * include/cppunit/extensions/AutoRegisterTest.h: on destruction, the registered + factory is unregistered from the registry. + + * include/cppunit/extensions/HelperMacros.h: added macros + CPPUNIT_REGISTRY_ADD_TO_DEFAULT and CPPUNIT_REGISTRY_ADD to help + build test suite hierarchy. + + * src/cppunit/msvc/DllPlugInTester/*: moved to src/cppunit/DllPlugInTester/. + + * src/cppunit/DllPlugInTester/DllPlugInTester.cpp: removed UNICODE stuffs. Use + the PlugInManager instead of PlugInTestSuite. Simplified: only one test on + command line, but many DLL can be specified. Added configurations to link + against cppunit dll, those are now the default configuration (static linking + don't make much sense for plug-in). + +2002-04-15 Baptiste Lepilleur + + * release 1.9.2. + + * NEWS: updated. + + * configure.in: added include/cppunit/config/Makefile and + include/cppunit/plugin/Makefile to the list of target. + + * doc/CppUnit-win.dox: enabled generation of HTML Help documentation. + + * include/cppunit/config/Makefile.am: + * include/cppunit/plugin/Makefile.am: added. + + * include/cppunit/config-bcb5.h: + * include/cppunit/config-msvc6.h: + * include/cppunit/config-mac.h: moved to include/cppunit/config/. + + * include/cppunit/Portability.h: updated config files location. Added macros + CPPUNIT_STRINGIZE and CPPUNIT_JOIN (implementation adapted from boost.org). + Added macro CPPUNIT_MAKE_UNIQUE_NAME. + + * include/cppunit/Test.h: modified methods order. + + * include/cppunit/extensions/HelperMacros.h: renamed macro + __CPPUNIT_MAKE_UNIQUE_NAME to CPPUNIT_MAKE_UNIQUE_NAME and moved its + definition to include/cppunit/Portability.h. + + * include/cppunit/extensions/TestDecorator.h: Inherits Test instead of TestLeaf. + + * include/cppunit/plugin/DynamicLibraryManager.h: + * src/cppunit/DynamicLibraryManager.cpp: added. DLL manager (load & lookup + symbol). + + * src/cppunit/BeOsDynamicLibraryManager.cpp: + * src/cppunit/UnixDynamicLibraryManager.cpp: + * src/cppunit/Win32DynamicLibraryManager.cpp: added. Implementation of + platform dependent methods of DynamicLibraryManager. + + * include/cppunit/plugin/DynamicLibraryManagerException.h: + * src/cppunit/DynamicLibraryManagerException.cpp: added. Exception thrown + by DynamicLibraryManager. + + * include/cppunit/plugin/TestPlugIn.h: added. CppUnitTestPlugIn interface + definition. Helper macros to implements plug-in. + + * include/cppunit/plugin/TestPlugInSuite.h: + * src/cppunit/plugin/TestPlugInSuite.cpp: added. A suite to wrap a test + plug-in. + + * include/cppunit/plugin/TestPlugInDefaultImpl.h: + * src/cppunit/TestPlugInDefaultImpl.cpp: added. A default implementation + of the test plug-in interface. + + * src/msvc6/DllPlugInTester/DllPlugInTester.cpp: updated to use the + new TestPlugIn. + + * examples/cppunittest/TestResultCollectorTest.cpp: fixed typo. + +2002-04-14 Baptiste Lepilleur + + * NEWS: updated. + + * include/cppunit/TestSucessListener.h: + * src/cppunit/TestSucessListener.cpp: renamed TestSuccessListener + + * doc/cookbook.dox: + * src/msvc6/DllPlugInTester/DllPlugInTester.cpp: + * examples/cppunittest/TestResultCollectorTest.h: + * examples/cppunittest/TestResultCollectorTest.cpp: + * examples/cppunittest/XmlOutputterTest.h: + * examples/cppunittest/XmlOutputterTest.cpp: + * include/cppunit/CompilerOutputter.h: + * include/cppunit/TestListener.h: + * include/cppunit/XmlOutputter.h: + * src/cppunit/XmlOutputter.cpp: + * src/cppunit/CompilerOutputter.cpp: fixed 'success' typo (was misspelled + 'sucess'). + + * include/cppunit/TestResultCollector.h: + * src/cppunit/TestResultCollector.cpp: updated (renaming of + TestSucessListener). + + * src/cppunit/XmlOutputter.cpp: + * examples/cppunittest/XmlOutputterTest.cpp: Changed SucessfulTests tag to + SucessfulTests. + +2002-04-13 Baptiste Lepilleur + + * include/cppunit/XmlOutputter.h: + * src/cppunit/XmlOutputter.cpp: Made XML output more human readable. Idented element. + + * examples/cppunittest/XmlUniformiser.h: + * examples/cppunittest/XmlUniformiser.cpp: + * examples/cppunittest/XmlUniformiserTest.cpp: modified to ignore trailing space + at the end of element content. + +2002-04-13 Baptiste Lepilleur + + * Snapshot 1.9.0 + + * NEWS: updated + + * doc/other_documentation.dox: addded new module for test plug-in. + + * include/msvc6/DSPlugin/TestRunnerDSPlugin.h: + * include/msvc6/DSPlugin/TestRunnerDSPlugin_i.c: added. Those file are + generated by project src/msvc/DSPlugin. They are provided to allow + compilation of TestRunner without compiling DSPlugIn which does not + build on VC++ 7. + + * examples/examples.dsw: removed DSPlugIn for workspace (fail to build + with VC++ 7). Added DllPlugInTester.dsp to workspace. + + * examples/msvc6/TestPlugIn/TestPlugIn.dsp: added post-build unit testing + using the new DllPlugInTester. + + * examples/msvc6/EasyTestPlugIn/*: a new project that + demonstrates the use of CPPUNIT_TESTPLUGIN_IMPL to create a test plug-in. + + * src/cppunit/cppunit.dsw: + * src/TestPlugInRunner.dsw: + * src/TestRunner.dsw: removed. Should use src/CppUnitLibraries.dsw instead. + + * include/cppunit/ui/text/TestRunner.h: + * src/cppunit/TextTestRunner.cpp: removed findTestName() method. Replaced + by Test::findTest(). + + * src/msvc6/DSPlugIn/DSPlugIn.dsp: + * src/msvc6/DSPlugIn/DSAddIn.h: changed include for add-in. MIDL generates + files in sub-directory ToAddToDistribution. Generated file should be + copied to include/msvc6/DSPlugin when modified. This remove the dependecy + of MfcTestRunner on DSPlugIn. + + * src/msvc6/testrunner/ListCtrlFormatter.h: + * src/msvc6/testrunner/ListCtrlFormatter.cpp: added GetNextColumnIndex(). + + * src/msvc6/testrunner/src/TestRunnerDlg.h: + * src/msvc6/testrunner/src/TestRunnerDlg.cpp: set column number in + MsDevCallerListCtrl when initializing the list. + + * src/msvc6/testrunner/src/MsDevCallerListCtrl.h: + * src/msvc6/testrunner/src/MsDevCallerListCtrl.cpp: column indexes for + file and line number are no longer static. Added methods to set those + indexes. Changed DSPlugIn header name. + + * include/msvc6/testrunner/TestPlugInInterface.h: fixed inclusion of + windows header for WINAPI. Added macro CPPUNIT_TESTPLUGIN_IMPL to + automatically implements a test plug-in. + + * src/msvc6/DllPlugInTester/*: added new project. A application to test DLL + and report using CompilerOutputter. Target for post-build testing and + debugging of DLL. + + +2002-04-13 Baptiste Lepilleur + + * include/cppunit/CompilerOutputter.h: + * src/cppunit/CompilerOutputter.h: deprecated defaultOuputter(). Added + setLocationFormat() and format specifiation in constructor. A string + that represent the location format is used to output the location. + Default format is defined by CPPUNIT_COMPILER_LOCATION_FORMAT. + + * include/cppunit/config-msvc6.h: + * include/cppunit/Portability.h: added CPPUNIT_COMPILER_LOCATION_FORMAT. + Use gcc location format if VC++ is not detected. + + * include/cppunit/Test.h: fixed documentation. + + * include/cppunit/TestListener.h: added startSuite() and endSuite() + callbacks. Added new example to documentation. + + * include/cppunit/TestResult.h: + * src/cppunit/TestResult.cpp: + * include/cppunit/TestComposite.h: + * src/cppunit/TestComposite.cpp: Updated to inform the listeners. + + * src/qttestrunner/TestBrowserDlgImpl.cpp: used Test new composite + interface instead of RTTI to explore the test hierarchy. + + * examples/cppunittest/MockTestListener.h: + * examples/cppunittest/MockTestListener.cpp: updated,added support for + startSuite() and endSuite(). + + * examples/cppunittest/TestResultTest.h: + * examples/cppunittest/TestResultTest.cpp: added tests for startSuite() + and endSuite(). + +2002-04-12 Baptiste Lepilleur + + * Makefile.am: added examples/qt to tar ball release. + + * TODO: heavily updated. + + * contrib/msvc/CppUnit*.wwtpl: changed base class for unit test to TestFixture. + + * include/cppunit/Test.h: removed toString() method. Not used by the framework + and source of confusions with getName(). + Added getChildTestCount() and getChildTestAt(), introducing the composite pattern + at top level. Added utility methods findTest() and findTestPath(). + + * src/cppunit/Test.cpp: added. Implementation of new utility methods. + + * include/cppunit/TestCase.h: + * src/cppunit/TestCase.cpp: inherits TestLeaf. Removed toString(), run(void) and + defaultResult(). Removed default constructor. + + * src/cppunit/TestCase.cpp: + * src/cppunit/TestSuite.cpp: fixed some includes that used "" instead of <>. + + * include/cppunit/TestComposite.h: + * src/cppunit/TestComposite.cpp: added. Common implementation of Test for composite + tests (TestSuite). + + * include/cppunit/TestFailure.h: + * src/cppunit/TestFailure.cpp: removed toString(). + + * include/cppunit/TestLeaf.h: + * src/cppunit/TestLeaf.cpp: added. Common implementation of Test for single test + (TestCase). + + * include/cppunit/TestListener.h: added TimingListener example to documentation. + + * include/cppunit/TestPath.h: + * src/cppunit/TestPath.cpp: added. List of test traversed to access a test in the + test hierarchy. + + * include/cppunit/TestRunner.h: added. Generic TestRunner. + + * src/cppunit/TestRunner.cpp: moved to TextTestRunner.cpp. Added new implementation + of includecppunit/TestRunner.h. + + * include/cppunit/TestSuite.h: + * src/cppunit/TestSuite.cpp: inherits TestComposite and implements new Test + interface. Removed toString(). + + * src/cppunit/TextTestRunner.cpp: moved from TestRunner.cpp. Implementation of + include/cppunit/ui/text/TestRunner.h. + + * include/cppunit/extensions/RepeatedTest.h: + * src/cppunit/RepeatedTest.cpp: removed toString(). + + * include/cppunit/extensions/TestDecorator.h: inherits TestLeaf. + Removed toString() + + * include/cppunit/XmlOutputter.h: + * src/cppunit/XmlOutputter.cpp: + * examples/cppunittest/XmlOutputterTest.cpp: + * examples/cppunittest/XmlOutputterTest.h: XML outputter now escape node content. + Add unit test for that bug (#540944). Added style sheet support. Modified + XML structure: failure message as its own element. + + * src/msvc/testrunner/TestRunnerModel.h: + * src/msvc/testrunner/TestRunnerModel.cpp: used Test::findTest() to find a test + by name instead of using RTTI. Added toAnsiString() for convertion when + compiling as UNICODE. + + * src/msvc/testrunner/TreeHierarchyDlg.h: + * src/msvc/testrunner/TreeHierarchyDlg.cpp: used new composite interface of Test + to explorer the test hierarchy instead of RTTI. + + * examples/cppunittest/TestPathTest.h: + * examples/cppunittest/TestPathTest.cpp: added, unit tests for TestPath. + + * examples/cppunittest/TestCaseTest.h: + * examples/cppunittest/TestCaseTest.cpp: added test for TestLeaf. + + * examples/cppunittest/TestSuiteTest.h: + * examples/cppunittest/TestSuiteTest.cpp: added test for TestComposite and + new Test interface. + +2002-04-11 Baptiste Lepilleur + + * configure.in: bumped version to 1.9.0 + + * NEWS: added version 1.9.0 + +2002-04-11 Baptiste Lepilleur + + * doc/FAQ: removed question about the Exception::operator =() problem. + + * release 1.8.0 + +2002-04-11 Steve M. Robbins + + * include/cppunit/ui/mfc/Makefile.am: + * include/cppunit/ui/qt/Makefile.am: + * include/cppunit/ui/text/Makefile.am: Set the libcppunitincludedir + variable. Correct case of header file ui/qt/Config.h. + + * configure.in: Output the new include/*/Makefiles. + +2002-04-10 Baptiste Lepilleur + + * Makefile.am: removed directory cppunitui from copy when making + the dist. + + * include/cppunit/ui: added Makefile.am for dist and install. + +2002-04-10 Baptiste Lepilleur + + * include/cppunitui/: moved to include/cppunit/ui (fix unix + install problem). + + * doc/cookbook.dox: + * examples/cppunittest/CppUnitTestMain.cpp: + * examples/msvc/CppUnitTestApp/HostApp.cpp: + * examples/msvc/HostApp/HostApp.cpp: + * examples/qt/Main.Cpp: + * examples/src/cppunit/TestRunner.cpp: + * examples/src/msvc6/TestRunner/TestRunner.cpp: + * examples/src/qttestrunner/TestRunner.cpp: updated to use + instead of in include directives. + + * doc/CppUnit-win.dox: generated documentation give the include + path at the bottom of the page for each class. + + * NEWS: added compatibility break for 1.7.10 users. + +2002-04-05 Baptiste Lepilleur + + * examples/cppunittest/CppUnitTestMain.cpp: never wait for a key press. + +2002-04-04 Baptiste Lepilleur + + * NEW: added CPPUNIT_ASSERT_EQUAL_MESSAGE compatiblity break. + + * include/cppunit/TestAssert.h: changed arguments order for + CPPUNIT_ASSERT_EQUAL_MESSAGE. 'message' is now the first argument + instead of the last (like CPPUNIT_ASSERT_MESSAGE). + + * examples/cppunittest/MockTestCase.cpp: + * examples/cppunittest/MockTestListener.cpp: updated to reflect + change on CPPUNIT_ASSERT_EQUAL_MESSAGE. + +2002-03-28 Baptiste Lepilleur + + * configure.in: bumped version to 1.7.11 + +2002-03-28 Baptiste Lepilleur + + * doc/cookbook.html: removed. Replaced by cookbook.doc. + + * doc/cookbook.dox: added, conversion of cookbook.html to Doxygen + format. + + * doc/other_documentation.dox: added groups definition. + + * doc/Makefile.am: replaced cookbook.html by cookbook.dox + + * doc/Doxyfile.in: added predefined CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION. + Replaced cookbook.html by cookbook.dox. + + * include/cppunitui/mfc/TestRunner.h: added, extracted from + include/msvc6/testrunner/TestRunner.h. Moved class TestRunner to + namespace CppUnit::MfcUi. + + * include/msvc6/testrunner/TestRunner.h: deprecated. A simple + typedef to CppUnit::MfcUi::TestRunner. + + * include/textui/TestRuner.h: added, extracted from + include/cppunit/TextTestRunner.h. + + * src/cppunit/TextTestRunner.cpp: renamed TestRunner.cpp. Moved + into namespace CppUnit::TextUi. + + * src/msvc6/testruner/TestRunner.cpp: moved into namespace + CppUnit::MfcUi. + + * src/cppunit/CompilerOutputter.cpp: removed printing "- " before + NotEqualException addional message, for consistency between + different TestRunner (Mfc,Text...) + + * include/cppunit/Asserter.h: + * include/cppunit/CompilerOutputter.h: + * include/cppunit/Exception.h: + * include/cppunit/NotEqualException.h: + * include/cppunit/Outputter.h: + * include/cppunit/SourceLine.h: + * include/cppunit/TestAssert.h: + * include/cppunit/TestCaller.h: + * include/cppunit/TestFailure.h: + * include/cppunit/TestFixture.h: + * include/cppunit/TestListener.h: + * include/cppunit/TestResult.h: + * include/cppunit/TestResultCollector.h: + * include/cppunit/TestSucessListener.h: + * include/cppunit/TestSuite.h: + * include/cppunit/TextTestProgressListener.h: + * include/cppunit/TextTestRunner.h: + * include/cppunit/XmlOutputter.h: + * include/cppunit/extensions/AutoRegisterSuite.h: + * include/cppunit/extensions/HelperMacros.h: + * include/cppunit/extensions/TestFactoryRegistry.h: + * include/cppunit/extensions/TestSuiteBuilder.h: + * include/cppunit/extensions/TestSuiteFactory.h: doc + update. organization in groups. + + * examples/msvc6/CppUnitTestApp/CppUnitTestApp.cpp: + * examples/msvc6/HostApp/HostApp.cpp: updated to use + CppUnit::MfcUi::TestRunner. + + * examples/cppunittest/CppUnitTestMain.cpp: updated to use + CppUnit::TextUi::TestRunner. + +2002-03-27 Baptiste Lepilleur + + * include/msvc/testrunner/TestRunner.h: updated doc. reindented. + + * include/cppunit/Asserter.h: + * include/cppunit/Asserter.cpp: + * include/cppunit/TestResultCollector.h: + * include/cppunit/TestResult.h: + * include/cppunit/SynchronizedObject.h: + * include/cppunit/extensions/TestCaller.h: doc update. + + * include/cppunitui/qt/TestRunner.h: doc update. + +2002-03-27 Baptiste Lepilleur + + * makefile.am: added src/CppUnitLibraries.dsw, new contribution, and + src/qttestrunner. + + * TODO: updated (doc). + + * contrib/msvc/AddingUnitTestMethod.dsm: added, submitted by + bloodchen@hotmail.com. + + * constrib/msvc/readme.txt: updated. + + * include/cppunit/TestAsserter.h: + * include/cppunit/SourceLine.h: updated doc. + + * include/cppunit/TestCaller.h: reindented. updated doc. + + * include/cppunit/extensions/HelperMacros.h: relaxed constraint on fixture. + Fixture base class may be TestFixture instead of TestCase. + + * include/cppunit/TestCase.h: + * src/cppunit/TestCase.h: TestCase inherits TestFixture for setUp() and + tearDown() definition. Moved documentation to TestFixture. + + * include/cppunit/TestFixture.h: updated documentation. + + * include/cppunit/TestRegistry.h: + * src/cppunit/TestRegistry.cpp: Removed. Replaced by TestFactoryRegistry. + + * include/cppunit/TextTestRunner.h: + * src/cppunit/TextTestRunner.cpp: made printing progress using a + TextTestProgressListener optional. + + * examples/cppunittest/ExceptionTest.h: + * examples/cppunittest/HelperMacrosTest.h: + * examples/cppunittest/HelperMacrosTest.cpp: + * examples/cppunittest/NotEqualException.h: + * examples/cppunittest/OrthodoxTest.h: + * examples/cppunittest/RepeatedTest.h: + * examples/cppunittest/TestAssertTest.h: + * examples/cppunittest/TestCallerTest.h: + * examples/cppunittest/TestDecoratorTest.h: + * examples/cppunittest/TestFailureTest.h: + * examples/cppunittest/TestResultCollectorTest.h: + * examples/cppunittest/TestResultTest.h: + * examples/cppunittest/TestSetUpTest.h: + * examples/cppunittest/TestSuiteTest.h: + * examples/cppunittest/XmlOutputterTest.h: + * examples/cppunittest/XmlOutputterTest.cpp: + * examples/cppunittest/XmlUniformizerTest.h: + * examples/cppunittest/XmlUniformizerTest.cpp: changed base class for fixture + from TestCase to TestFixture. + + * examples/hierarchy/BoardGameTest.h: + * examples/hierarchy/ChessTest.h: + * examples/hierarchy/main.cpp: updated to use HelperMacros for correct + fixture instantiation (the ChessBoard::testReset test case was using + BoardGame fixture instance instead of ChessBoard). + +2002-03-26 Baptiste Lepilleur + + * configure.in: bumped version to 1.7.9 + +2002-03-26 Baptiste Lepilleur + + * src/msvc6/testpluginrunner/TestPlugInRunner.dsp: fixed release configuration. + +2002-03-25 Baptiste Lepilleur + + * include/cppunit/makefile.am: removed TestRegistry.h + + * include/cppunit/TestRegistry.h: removed. Obsolete, replaced by + TestFactoryRegistry. + + * src/cppunit/makefile.am: removed TestRegistry.cpp. Added cppunit_dll.dsp. + + * include/cppunit/CompilerOutputter.h: + * include/cppunit/NotEqualException.h: + * include/cppunit/SynchronizedObject.h: + * include/cppunit/TestFixture.h: + * include/cppunit/TestListener.h: + * include/cppunit/TestResult.h: + * include/cppunit/TestSucessListener.h: + * include/cppunit/TextOutputter.h: + * include/cppunit/TextTestProgressListener.h: + * include/cppunit/TextTestResult.h: + * include/cppunit/XmlOutputter.h: + * include/cppunit/extensions/TestFactory.h: + * include/cppunit/extensions/TestFactoryRegistry.h: + * include/cppunit/extensions/TestSuiteBuilder.h: + * include/cppunit/extensions/TestSuiteFactory.h: minor doc update. + + * include/cppunit/TestFixture.h: added DLL export. + + * include/cppunit/msvc6/TestPlugInInterface.h: updated doc. Added automatic + exportation of TestPlugIn publishing function. + + * src/cppunit/TestCase.cpp: + * include/cppunit/TestCase.h: inherits setUp() and tearDown() from + class TestFixture. + +2002-03-25 Baptiste Lepilleur + + * configure.in: bumped version to 1.7.7 + +2002-03-25 Baptiste Lepilleur + + * include/cppunit/config-msvc6.h: + * include/cppunit/Portability.h + * include/cppunit/extensions/TestFactoryRegistry.h + * include/cppunit/TestResult.h + * include/cppunit/TestResultCollector.h + * include/cppunit/TestSuite.h + * include/cppunit/TextTestRunner.h + * include/cppunit/XmlOutputter.h: removed warning when compiling CppUnit + as DLL. + + * src/cppunit/DllMain.cpp: added some defines to speed up compilation a bit. + +2002-03-25 Baptiste Lepilleur + + * INSTALL-WIN32.txt: updated for MFC Unicode TestRunner. + + * src/msvc6/testrunner/TestRunner.dsp: added Unicode configurations. + + * src/msvc6/testrunner/ListCtrlSetter.cpp: + * src/msvc6/testrunner/ListCtrlSetter.h: replaced usage of std::string by + CString for easier ansi/unicode switch. + + * src/msvc6/testrunner/MsDevCallerListCtrl.cpp: + * src/msvc6/testrunner/TestRunnerDlg.cpp: + * src/msvc6/testrunner/TestRunnerModel.cpp: + * src/msvc6/testrunner/TestRunnerModel.h: + * src/msvc6/testrunner/TreeHierarchyDlg.cpp: made changes to compile with + either ANSI and UNICODE support. + + * examples/msvc6/HostApp/HostApp.cpp: + * examples/msvc6/HostApp/HostApp.h: + * examples/msvc6/HostApp/HostAppDoc.cpp: + * examples/msvc6/HostApp/HostAppDoc.h: moved TestRunner execution to + HostApp::RunUnitTests() and removed the MainFrame application window. + + * examples/msvc6/HostApp/HostApp.dsp: added Unicode configurations. + +2002-03-24 Baptiste Lepilleur + + * INSTALL-WIN32.txt: added some info to build cppunit as a DLL. + + * include/cppunit/config-msvc6.h: added definition of macro CPPUNIT_API + when building or linking DLL. Defined CPPUNIT_BUILD_DLL when building, and + CPPUNIT_DLL when linking. + + * include/cppunit/Portability.h: added empty definition of macro + CPPUNIT_API when not building or using CppUnit as a DLL. When any of + those symbol is defined, the symbol CPPUNIT_NEED_DLL_DECL is set to 1. + + * include/cppunit/extensions/RepeatedTest.h: + * include/cppunit/extensions/TestDecorator.h: + * include/cppunit/extensions/TestSetUp.h: + * include/cppunit/TestCaller.h + * include/cppunit/extensions/TestFactory.h + * include/cppunit/extensions/TestFactoryRegistry.h + * include/cppunit/extensions/TypeInfoHelper.h + * include/cppunit/Asserter.h + * include/cppunit/Exception.h + * include/cppunit/NotEqualException.h + * include/cppunit/SourceLine.h + * include/cppunit/SynchronizedObject.h + * include/cppunit/Test.h + * include/cppunit/TestAssert.h + * include/cppunit/TestCase.h + * include/cppunit/TestFailure.h + * include/cppunit/TestListener.h + * include/cppunit/TestResult.h + * include/cppunit/TestSuite.h + * include/cppunit/CompilerOutputter.h + * include/cppunit/Outputter.h + * include/cppunit/TestResultCollector.h + * include/cppunit/TestSuccessListener.h + * include/cppunit/TextOutputter.h + * include/cppunit/TextTestProgressListener.h + * include/cppunit/TextTestResult.h + * include/cppunit/TextTestRunner.h + * include/cppunit/XmlOutputter.h: added CPPUNIT_API for DLL export. + + * include/cppunit/TestSuite.h: + * src/cppunit/TestSuite.cpp: reindented + + * include/cppunit/extensions/TestSetUp.h: + * src/cppunit/TestSetUp.cpp: added .cpp. extracted inline method and moved + them to cpp file. + + * src/cppunit/DllMain.cpp: added, contains Dll entry point. + +2002-03-06 Baptiste Lepilleur + + * src/cppunit/TextTestProgressListener.cpp: flush the stream after each + progess step. + +2002-03-03 Baptiste Lepilleur + + * configure.in: updated version number to 1.7.4 + +2002-03-03 Baptiste Lepilleur + + * include/cppunit/makefile.am: + * src/cppunit/makefile.am: added missing SynchronizedObject and + TextOutputter.h. + + * generated 1.7.3 tar ball. + +2002-02-29 Baptiste Lepilleur + + * inclued/cppunit/XmlOutputter.h: + * inclued/cppunit/XmlOutputter.cpp: added optional parameter to constructor + to specify the encoding. + + * configure.in: updated version number to 1.7.3 + +2002-02-28 Baptiste Lepilleur + + * NEW: updated and restructured. + + * include/cppunit/CompilerOutputter.h: + * src/cppunit/CompilerOutputter.cpp: + updated against TestResultChange. Changed TestResult to TestResultCollector. + + * include/cppunit/extensions/HelperMacros.h: minor documentation fix. + + * include/cppunit/Outputter.h: added. Abstract base class for all Outputter. + + * include/cppunit/Portability.h: made the fix on OStringStream suggested by + Bob Summerwill to remove level 4 warning with VC++. + + * include/cppunit/TestAssert.h: added macro CPPUNIT_ASSERT_EQUAL_MESSAGE. + + * src/cppunit/TestFailure.cpp: + * include/cppunit/TestFailure.h: added method clone() to duplicate a + failure. Made all method virtual. + + * include/cppunit/TestListener.h: changed signature of addFailure() to + addFailure( const TestFailure &failure ). Failure is now only a temporary + object. + + * include/cppunit/Outputter.h: added. Abstract base class for all + outputter. Used by TextTestRunner. + + * include/cppunit/SynchronizedObject.h: + * src/cppunit/SynchronizedObject.cpp: added. Class extracted from + TestResult. Base class for objects that can be accessed from different + threads. + + * include/cppunit/TestResult.h: TestFailure.h is no longer included. + + * include/cppunit/TestResult.h: + * src/cppunit/TestResult.cpp: extracted all methods related to keeping track + of the result to the new TestResultCollector class which is a TestListener. + + * include/cppunit/TestResultCollector.h: + * src/cppunit/TestResultCollector.cpp: added. TestListener which kept track + of the result of the test run. All failure/error, and tests are tracked. + + * include/cppunit/TestSucessListener.h: + * src/cppunit/TestSucessListener.cpp: added. TestListener extracted from + TestResult. Is responsible for wasSucessful(). + + * include/cppunit/TestCase.h: + * src/cppunit/TestCase.cpp: reindented. + + * include/cppunit/TextOutputter.h: + * src/cppunit/TextOutputter.cpp: added. Copied from the deprecated + TextTestResult and modified to act as an Ouputter. + + * include/cppunit/TextTestProgressListener.h: + * src/cppunit/TextTestProgressListener.cpp: Copied from the deprecated + TextTestResult and modified to print the dot while the test are running. + + * include/cppunit/TextTestResult.h: + * src/cppunit/TextTestResult.cpp: updated against TestResult change. + No compatiblity break. Deprecated. + + * include/cppunit/TextTestRunner.h: + * src/cppunit/TextTestRunner.cpp: updated to work with the new TestResult. + Use TextTestProgressListener and TextOutputter instead of TextTestResult. + Any outputter with interface Outputter can be used to print the test result + (CompilerOutputter, XmlOutputter, TextOutputter...) + + * include/cppunit/XmlOutputter.h: + * src/cppunit/XmlOutputter.cpp: updated against TestResultChange. + Changed TestResult to TestResultCollector. + + * src/msvc6/TestRunnerDlg.h: + * src/msvc6/TestRunnerDlg.cpp: fixed the 'fullrowselect' feature of the + list view. The dialog is a TestListener itself, it no longer use the + GUITestResult class. + + * src/msvc6/TestRunner.rc: moved the "autorun test button" in such a way that + it did not overlap the progress bar anymore. + + * src/msvc6/MfcSynchronizationObject.h: added. Generic SynchronizedObject + lock for MFC. + + * src/msvc6/GUITestResult.h : + * src/msvc6/GUITestResult.cpp : removed. + + * src/qttestrunner/TestRunnerModel.h: + * src/qttestrunner/TestRunnerModel.cpp: changed addFailure() signature to + reflect change on TestListener. + + * examples/cppunittest/CppUnitTestMain.cpp: updated to use the new Outputter + abstraction and TextTestRunner facilities. + + * examples/cppunittest/FailingTestCase.h: + * examples/cppunittest/FailingTestCase.cpp: removed. Replaced by MockTestCase. + + * examples/cppunittest/FailingTestCase.h: + * examples/cppunittest/FailingTestCase.h: + + * examples/cppunittest/HelperMacrosTest.h: + * examples/cppunittest/HelperMacrosTest.cpp: Updated against TestResult change. + Use MockTestListener instead of TestResult to check for sucess or failure. + + * examples/cppunittest/MockTestListener.h: + * examples/cppunittest/MockTestListener.cpp: the class now behave like a mock + object. + + * examples/cppunittest/MockTestCase.h: + * examples/cppunittest/MockTestCase.cpp: added. Mock TestCase object. + + * examples/cppunittest/OrthodoxTest.h: + * examples/cppunittest/OrthodoxTest.cpp: Updated against TestResult change. + Use MockTestListener instead of TestResult to check for sucess or failure. + + * examples/cppunittest/SynchronizedTestResult.h: Updated against TestResult + change. + + * examples/cppunittest/TestCallerTest.h: + * examples/cppunittest/TestCallerTest.cpp: Updated against TestResult change. + Use MockTestListener instead of TestResult. + + * examples/cppunittest/TestCaseTest.h: + * examples/cppunittest/TestCaseTest.cpp: Updated against TestResult change. + Use MockTestListener and MockTestCase instead of FailingTestCase and TestResult. + + * examples/cppunittest/TestDecoratorTest.h: + * examples/cppunittest/TestDecoratorTest.cpp: Updated against TestResult change. + Use MockTestCase instead of FailingTestCase. + + * examples/cppunittest/TestListenerTest.h: + * examples/cppunittest/TestListenerTest.cpp: removed. Those unit tests have been + rewrote and moved to TestResultTest. + + * examples/cppunittest/TestResultTest.h: + * examples/cppunittest/TestResultTest.cpp: Updated to test the new interface. + Tests from TestListenerTest have been moved here. + + * examples/cppunittest/TestResultCollectorTest.h: + * examples/cppunittest/TestResultCollectorTest.cpp: added. Tests for the class + that been extracted from TestResult. + + * examples/cppunittest/TestSetUpTest.h: + * examples/cppunittest/TestSetUpTest.cpp: renamed SetUp inner class to MockSetUp. + Changed interface to be more akin to a Mock object. + + * examples/cppunittest/TestSuiteTest.h: + * examples/cppunittest/TestSuiteTest.cpp: Updated against TestResult change, + and rewrote to use MockTestCase instead of FailingTestCase. + + * examples/cppunittest/XmlOutputterTest.h: + * examples/cppunittest/XmlOutputterTest.cpp: Updated against TestResult change. + Added some utility methods to make the update easier. + +2001-10-28 Steve M. Robbins + + * INSTALL-unix: Add note about cygwin. + +2001-10-24 Baptiste Lepilleur + + * examples/msvc6/CppUnitTestApp/CppUnitTestApp.dsp: + * examples/msvc6/HostApp/HostApp.dsp: use custom file build instead + of post-build/pre-link step to copy the TestRunner DLL to the + Release/Debug directory. + + * src/msvc6/ProgressBar.cpp: + * src/msvc6/ProgressBar.h: + * src/msvc6/TestRunner.rc: + * src/msvc6/TestRunnerDlg.cpp: + * src/msvc6/TestRunnerDlg.h: + * src/msvc6/testRunner.dsp: + * src/msvc6/TestRunnerModel.cpp: + * src/msvc6/TestRunnerModel.h: included Gigi Sayfan (gigi@morphink.com) + patch. The dialog can now be resized, and list view columns and dialog + sizes are saved. + + * src/msvc6/ProgressBar.cpp: + * src/msvc6/ProgressBar.h: Minor refactoring. + + * THANKS: added Gigi Sayfan to the list. + +2001-10-21 Steve M. Robbins + + * configure.in: Bump version to 1.7.2. + + * Release 1.7.1 (alpha). + + * Merged changes from cvs BRANCH_1_6; details follow. + + * examples/cppunittest/TestSetUpTest.h (class SetUp): Add + namespace qualifier to CppUnit::TestSetup() constructor call. + + * include/cppunit/Makefile.am (dist-hook): Restore hook to + remove config-auto.h from distribution. + + * doc/Makefile.am: Move the definition of htmldir inside if DOC + conditional. Add "else" branch to conditional with dummy targets + for install-data-hook and uninstall-local. Move all-local outside + the conditional, and move "dox" target into both branches of the + conditional. + +2001-10-20 Steve M. Robbins + + * examples/cppunittest/Makefile.am (cppunittestmain_SOURCES): + Include XmlUnformiserTest files. + + * doc/Doxyfile.in (GENERATE_MAN): Do not generate man pages. + * doc/Makefile.am: Do not make man directories. + +2001-10-19 Baptiste Lepilleur + + * include/cppunit/Exception.h: + * src/cppunit/Exception.cpp: what(), added back the throw() qualifier. + +2001-10-14 Baptiste Lepilleur + + * include/cppunitui/* : added, Qt TestRunner. + + * examples/qt/* : added, example showing the use of Qt TestRunner. + + * src/qttestrunner : added, source of the Qt TestRunner DLL. + +2001-10-08 Steve M. Robbins + + * src/cppunit/Exception.cpp (what): Remove "throw()" qualifier, to + match earlier change to header. + +2001-10-07 Baptiste Lepilleur + + * include/cppunit/CompilerTestResultOutputter.h : + renamed CompilerOutputter.h + + * src/cppunit/CompilerTestResultOutputter.cpp : + renamed CompilerOutputter.cpp + + * include/cppunit/CompilerTestResultOutputter.h : + * src/cppunit/CompilerTestResultOutputter.cpp : ajust max line length + for wrapping. Added static factory method defaultOutputter(). Print + the number of test runs on success. + + * include/cppunit/CompilerTestResultOutputter.h : renamed + CompilerOutputter.h. + + * src/cppunit/CompilerTestResultOutputter.cpp : renamed + CompilerOutputter.cpp. + + * examples/cppunittest/CppUnitTestMain.cpp : use factory method + CompilerTestResultOutputter::defaultOutputter(). + + * src/msvc6/DSPlugIn/DSPlugIn.dsp : removed COM registration in + post-build step. IT is automatically done by VC++ when the add-in is + added. Caused build to failed if the add-in was used in VC++. + + * NEWS : updated. + + * src/cppunit/TestAssert.cpp : modified deprecated assert + implementations to use Asserter. + + * examples/cppunittest/XmlTestResultOutputterTest.h : + renamed XmlOutputterTest.h. + + * examples/cppunittest/XmlTestResultOutputterTest.cpp : + renamed XmlOutputterTest.cpp. + + * NEWS : + * examples/cppunittest/CppUnitTestMain.cpp : + * examples/cppunittest/CppUnitTestMain.dsp : + * examples/cppunittest/Makefile.am : + * examples/cppunittest/XmlTestResultOutputterTest.h : + * examples/cppunittest/XmlTestResultOutputterTest.cpp : + * examples/msvc6/CppUniTestApp/CppUnitTestApp.dsp + * include/cppunit/CompilerOutputter.h : + * include/cppunit/Makefile.am : + * include/cppunit/XmlTestResultOutputter.h : + * src/cppunit/CompilerOutputter.cpp : + * src/cppunit/cppunit.dsp : + * src/cppunit/Makefile.am : + * src/cppunit/XmlTestResultOutputter.cpp : change due to renaming + CompilerTestResultOutputter to CompilerOutputter, + XmlTestResultOutputter to XmlOuputter, XmlTestResultOutputterTest + to XmlOutputterTest. + +2001-10-06 Baptiste Lepilleur + + * include/cppunit/CompilerTestResultOutputter.h : + * src/cppunit/CompilerTestResultOutputter.cpp : added. Output result + in a compiler compatible format. + + * src/cppunit/CppUnit.dsp : + * include/cppunit/MakeFile.am : + * src/cppunit/MakeFile.am : added CompilerTestResultOutputter.cpp + and CompilerTestResultOutputter.h. + + * examples/cppunittest/CppUnitTestMain.cpp : if -selftest is specified + on the command line, no standard test result are printed, but compiler + compatible result at printed. + + * examples/cppunittest/CppUnitTestMain.dsp : added post-build step to + run the test suite with -selftest. + + * NEWS : updated. + + * src/cppunit/TextTestRunner.cpp : skip a line after printing + progress. + +2001-10-06 Baptiste Lepilleur + + * examples/cppunittest/CppUnitTestMain.cpp : application returns + 0 is test suite run sucessfuly, 1 otherwise. + + * src/cppunit/Exception.cpp : bug fix, operator =() with VC++. + Removed call to std::exception::operator =() which is bugged + on VC++. + + * doc/FAQ : added a note explaining why the test + ExceptionTest.testAssignment used to fail. + + * NEWS : updated and detailed. + + * include/cppunit/TestResult.h : + * src/cppunit/TestResult.cpp : added reset(). + + * include/cppunit/TextTestRunner.h : + * src/cppunit/TextTestRunner.cpp : Constructor take an optional + TextTestRestult. The TextTestResult remain alive as long as + the runner. Added result() to retreive the result. Printing the + result is now optinal (enabled by default). + +2001-10-05 Baptiste Lepilleur + + * include/cppunit/Asserter.h : + * src/cppunit/Asserter.cpp : added. Helper to create assertion macros. + + * src/cppunit/cppunit.dsp : + * src/cppunit/Makefile.am : + * include/cppunit/Makefile.am : added Asserter.h and Asserter.cpp. + + * include/cppunit/Exception.h : + * src/cppunit/Exception.cpp : added constructor that take a + SourceLine argument. Deprecated static constant and old constructor. + Fixed some constness issues. + + * examples/cppunittest/ExceptionTest.cpp : Refactored. + + * NEWS : partially updated (need to be more detailed) + + * include/cppunit/NotEqualException.h : + * src/cppunit/NotEqualException.cpp : added constructor that take a + SourceLine argument. Deprecated old constructor. Added a third element + to compose message. + + * examples/cppunittest/NotEqualExceptionTest.cpp : moved to "Core" + suite. Added test for SourceLine() and additionalMessage(). + Refactored. + + * include/cppunit/SourceLine.h : + * src/cppunit/SourceLine.cpp : added. Result of applying + IntroduceParameterObject refactoring on filename & line number... + + * include/cppunit/TestAssert.h : + * src/cppunit/TestAssert.cpp : deprecated old assert functions. + added functions assertEquals() and assertDoubleEquals() which use + SourceLine. + + * src/cppunit/TestCase.cpp : Modified for SourceLine. + + * include/cppunit/TestFailure.h : + * src/cppunit/TestFailure.cpp : added failedTestName(), and + sourceLine(). + + * src/msvc6/testrunner/TestRunnerDlg.cpp : modified to use SourceLine. + + * include/cppunit/TextTestResult.h : + * src/cppunit/TextTestResult.cpp : corrected include order and + switched to angled brackets. Refactored. Don't print failure location + if not available. Not equal failure dump additional message if + available. + + * src/cppunit/TextTestRunner.cpp : run() now returns a boolean to + indicate if the run was sucessful. + + * src/cppunit/XmlTestResultOutputter.cpp : replaced itoa() with + OStringStream. Refactored. + + * examples/cppunittest/XmlUniformiser.h : + * examples/cppunittest/XmlUniformiser.cpp : + CPPUNITTEST_ASSERT_XML_EQUAL capture failure location. Refactored + checkXmlEqual(). + + * examples/cppunittest/XmlUniformiserTest.h : + * examples/cppunittest/XmlUniformiserTest.cpp : added test for + CPPUNITTEST_ASSERT_XML_EQUAL. + + * include/cppunit/XmlTestResultOutputter.h : + * src/cppunit/XmlTestResultOutputter.cpp : updated to use SourceLine. + +2001-10-05 Baptiste Lepilleur + + * NEWS : updated. + + * include/cppunit/Exception.h : added include Portability.h. + + * include/cppunit/TestResult.* : changed TestFailures to a deque. + added tests(). + + * examples/cppunittest/CppUnitTest.dsp : + * examples/cppunittest/MakeFile.am : + * examples/msvc6/CppUnitTestApp/CppUnitTestApp.dsp : Added + XmlTestResultOutputterTest.*, XmlUniformiser.*, XmlUniformiserTest.*, + UnitTestToolSuite.h, OutputSuite.h. + + * examples/msvc6/CppUnitTestApp/CppUnitTestApp.dsp : revised project + folders structure. Added missing NoteEqualExceptionTest.*. + + * examples/cppunittest/CppUnitTestSuite.cpp : added 'Output' and + 'UnitTestTool' suites. + + * src/cppunit/cppunit.dsp: removed estring.h. Revised project folders + structure. Removed TestRegistry.*. Added TestSetUp.h, + XmlTestResultOutputter.*. + + * src/cppunit/MakeFile.am: added XmlTestResultOutputter.*. + + * src/testrunner/TestRunnerDlg.cpp: removed disabled code. + +2001-10-03 Baptiste Lepilleur + + * include/cppunit/TestFailure.cpp : + * include/cppunit/TestFailure.h : fixed some constness issues. Added + argument to indicate the type of failure to constructor. Added + isError(). + + * include/cppunit/TestListener.h : removed addError(). addFailure() + now take a TestFailure as argument. + + * include/cppunit/TestResult.h : + * include/cppunit/TestResult.cpp : removed errors(). Refactored. Fixed + some constness issues. Added typedef TestFailures for vector returned + by failures(). failures() returns a const reference on the list of + failure. added testFailuresTotal(). Constructor can take an optional + synchronization object. + + * include/cppunit/TextTestResult.h : + * include/cppunit/TextTestResult.cpp : removed printErrors(). + Refactored. Updated to suit new TestResult, errors and failures are + reported in the same list. + + * examples/cppunittest/TestFailureTest.cpp : + * examples/cppunittest/TestFailureTest.h : modified to use the new + TestFailure constructor. Added one test. + + * examples/cppunittest/TestListenerTest.cpp: removed addError(). + Refactored to suit new TestListener. + + * examples/cppunittest/TestResultTest.h : + * examples/cppunittest/TestResultTest.cpp : modified to suit the + new TestResult. + +2001-10-02 Baptiste Lepilleur + + * include/cppunit/extensions/TestFactoryRegistry.h + * src/cppunit/TestFactoryRegistry.cpp : fixed memory leaks that + occured when a TestFactoryRegistry was registered into another + TestFactoryRegistry. + + * include/cppunit/extensions/AutoRegisterSuite.h : updated doc. + + * include/cppunit/extensions/HelperMacros.h : added macro + CPPUNIT_TEST_SUITE_NAMED_REGISTRATION to register a suite into + a named suite. Updated doc. + + * examples/cppunittest/CoreSuite.h: + * examples/cppunittest/ExtensionSuite.h: + * examples/cppunittest/HelperSuite.h: added, declaration of suite for + use with CPPUNIT_TEST_SUITE_NAMED_REGISTRATION. + + * examples/cppunittest/makefile.am : added HelperSuite.h, CoreSuite.h, + ExtensionSuite.h, CppUnitTestSuite.h and CppUnitTestSuite.cpp. + + * examples/cppunittest/CppUnitTestSuite.*: added. + + * examples/cppunittest/ExceptionTest.cpp: + * examples/cppunittest/TestAssertTest.cpp: + * examples/cppunittest/TestCaseTest.cpp: + * examples/cppunittest/TestFailureTest.cpp: + * examples/cppunittest/TestListenerTest.cpp: + * examples/cppunittest/TestResultTest.cpp: + * examples/cppunittest/TestSuiteTest.cpp: moved into named suite + "Core" using CPPUNIT_TEST_SUITE_NAMED_REGISTRATION. + + * examples/cppunittest/OrthodoxTest.cpp: + * examples/cppunittest/RepeatedTest.cpp: + * examples/cppunittest/TestDecoratorTest.cpp: + * examples/cppunittest/TestSetUpTest.cpp: moved into named suite + "Extension" using CPPUNIT_TEST_SUITE_NAMED_REGISTRATION. + + * examples/cppunittest/HelperMacrosTest.cpp: + * examples/cppunittest/TestCallerTest.cpp: moved into named suite + "Helper" using CPPUNIT_TEST_SUITE_NAMED_REGISTRATION. + + * examples/cppunittest/CppUnitTest.dsp : + * examples/msvc6/CppUnitTestApp/CppUnitTestApp.dsp : added + Makefile.am, HelperSuite.h, CoreSuite.h, ExtensionSuite.h, + CppUnitTestSuite.h and CppUnitTestSuite.cpp. + +2001-10-01 Baptiste Lepilleur + + * NEWS : updated. + + * doc/other_documentation.dox : added all the authors to the list of + authors. + + * examples/cppunittest/HelperMacrosTest.*: added unit tests for + CPPUNIT_TEST_FAIL & CPPUNIT_TEST_EXCEPTION. + + * examples/cppunittest/TestAssertTest.*: added unit tests for + CPPUNIT_FAIL. Corrected spelling error. Relaxed constraint on message + produced by CPPUNIT_ASSERT_MESSAGE. Refactored some tests. + + * include/cppunit/extensions/HelperMacros.h : added macro + CPPUNIT_TEST_EXCEPTION to create a test case for the specified method + that must throw an exception of the specified type. + + * include/cppunit/extensions/TestSuiteBuilder.h : made + makeTestName() public. Added addTestCallerForException() to add a + test case expecting an exception of the specified type to be + caught. + + * include/cppunit/TestAssert.h : added macro CPPUNIT_FAIL as a + shortcut for CPPUNIT_ASSERT_MESSAGE( message, false ). + +2001-09-30 Steve M. Robbins + + * configure.in: Set version to 1.7.0. + +2001-09-30 Steve M. Robbins + + * Release 1.6.1. + + * doc/footer.html: Do not meddle with font size. + + * doc/header.html: Add link to FAQ. Do not meddle with font size. + + * doc/Doxyfile.in (PROJECT_NAME): Set to "CppUnit", to be + consistent on capitalization. + (PROJECT_NUMBER): Include "Version" in the string. + + * doc/Makefile.am (EXTRA_DIST): Distribute FAQ. + + * Makefile.am (EXTRA_DIST): Distribute contrib/msvc/CppUnit.WWTpl + and contrib/msvc/readme.txt. + (dist-hook): Change line endings of these files. + + * include/cppunit/extensions/RepeatedTest.h + * src/cppunit/RepeatedTest.cpp (countTestCases, toString): + Add const qualifier to function. + +2001-09-30 Baptiste Lepilleur + + * contrib/msvc/CppUnit.WWTpl: added, template for WorkSpace Whiz! + to create new classes and unit tests. + + * doc/FAQ: + * INSTALL-WIN32.txt: moved FAQ from install-WIN32 to that file. Added + a generic question to hint at the helper macros. + + * include/cppunit/extensions/HelperMacros.h: bug #464844, moved + declaration of ThisTestCaseFactory from CPPUNIT_TEST_SUITE_END to + CPPUNIT_TEST_SUITE where the Fixture class name is available from + the macro parameter. + +2001-09-30 Steve M. Robbins + + * include/cppunit/config-mac.h: New. Macintosh configuration, + courtesy of Duane Murphy. + + * include/cppunit/Portability.h: Move include inside + #if-block that needs it. + + * doc/Makefile.am (doc-dist): Creates tar file of HTML doc files. + Remove all wildcarded filenames. Do not bother with manpages. + + * Makefile.am (EXTRA_DIST): Distribute INSTALL-unix and + cppunit-config.1. + (man_MANS): Install cppunit-config.1. + (doc-dist): Use "make doc-dist" in doc directory. + + * cppunit-config.1: Document --prefix and --exec-prefix. + + * cppunit-config.in (Usage): Remove "[LIBRARIES]" from help string. + +2001-09-29 Steve M. Robbins + + * configure.in: Set version to 1.6.1. + +2001-09-29 Baptiste Lepilleur + + * example/cppunittest/TestCaller.*: remove some memory leaks. + TestCaller exception catching features is now tested correctly. + Previous test tested nothing! + +2001-09-23 Steve M. Robbins + + * configure.in: Set version to 1.6.0. + + * Makefile.am (EXTRA_DIST): Add BUGS. + + * NEWS: Incorporate Baptiste's notes. + + * BUGS: New file for list of known bugs. + + * README: Note about file BUGS. + +2001-09-24 Baptiste Lepilleur + + * include/cppunit/TestAssert.h : changed header order to remove + warning on VC++ + + * include/cppunit/TestCaller.h : bugfix: threw 'new Exception' + instead of 'Exception'. + +2001-09-23 Steve M. Robbins + + * doc/footer.html: Put devel list in mailto tag. + + * doc/Makefile.am (man_MANS): Restore ability to install manpages. + (htmldir): HTML pages installed under $(pkgdatadir). + + * doc/other_documentation.dox: Reference cookbook.html + in same directory. Remove obsolete text. + + * configure.in: Do not set CFLAGS; remove --enable-debug-mode. + + * include/cppunit/Portability.h: + * include/cppunit/extensions/HelperMacros.h: Allow user + to request the old-style CU_TEST family of macros. + + * doc/Doxyfile.in (EXCLUDE_PATTERNS): Remove estring.h. + + * README: Add contact and bug-reporting info. + + * INSTALL-unix: New. Move the unix install notes here + from README. + + * AUTHORS: Put myself on the list. + +2001-09-21 Baptiste Lepilleur + + * include/cppunit/TestFailure.h : made destructor virtual. + + * INSTALL-WIN32.txt : added some more infos about DSPlugIn. + + * src/msvc6/DSPlugIn/DSPlugIn.rgs: added some registry data + that where missing to register the COM object. + + * src/msvc6/DSPlugIn/DSPlugIn.rc: updated some dll version info. + + * src/msvc6/DSPlugIn/DSPlugIn.dsp: fixed the custom build step to + register the DLL using regsvr32.exe. Added a post-build step to + copy the dll to the lib/ directory. This prevent a blocking + compilation error if the DLL is in use by VC++. + +2001-09-20 Steve M. Robbins + + * Makefile.am (snapshot): Replace "date -I" GNUism with portable + specification for ISO date format. + (dist-hook): Correct rule to change line endings for INSTALL-WIN32.txt. + + * include/cppunit/Portability.h: + * config/ac_cxx_have_strstream.m4 (AC_CXX_HAVE_STRSTREAM): Extend + to check for and use in preference to . + Patrick Hartling reports the former is required for the SGI + MIPSpro 7.3.1.2 compiler. + +2001-09-19 Baptiste Lepilleur + + * examples/cppunittest/makefile.am : added TestSetupTest.(cpp/h) + + * examples/examples.dsw: removed some unnecessary dependencies. + + * examples/msvc6/HostApp/HostApp.dsp: fixed release configuration + + * src/msvc6/DSPlugIn/DSPlugIn.dsp: fixed release configuration, and + disabled the custom build command that does not work. + + * include/cppunit/extensions/HelperMacros.h: reordered header to remove + some warning with VC++. + + * INSTALL-WIN32.txt : detailed what was in each project. Added a FAQ + about the failing test case in cppunittest. + +2001-09-19 Steve M. Robbins + + * README: Describe how to check if libtool is fixed. + + * Makefile.am (dist-hook): Include INSTALL-WIN32.txt in the list + of files to convert to MSDOS line endings. + (snapshot): Use ISO-8601 compliant date for filename. + (ACLOCAL_AMFLAGS): Specify local directory. + +2001-09-18 Steve M. Robbins + + * include/cppunit/TextTestResult.h: Change include from + to . Sugggested by Peer Sommerlund. + + * include/cppunit/Portability.h: Qualify ostrstream with std. + Suggested by Patrick Hartling. + +2001-09-18 Baptiste Lepilleur + + * examples/examples.dsw: + * examples/msvc6/CppUnitTestApp/CppUnitTestApp.dsw: + * examples/msvc6/HostApp/HostApp.dsw: + * examples/msvc6/TestPlugIn/TestPlugIn.dsw: Added missing + project dependency. + + * src/msvc6/DSPlugIn/DSPlugIn.dsp: fixed *.tlb output directory. + + * include/msvc6/testrunner/TestPlugInInterface.h: does not define + NOMINMAX if already defined. + +2001-09-17 Baptiste Lepilleur + + * Makefile.am: Added INSTALL-WIN32.txt to EXTRA_DIST. + + * INSTALL-WIN32.txt: added, short documentation for CppUnit and VC++. + + * include/cppunit/extensions/HelperMacros.h: bug #448363, removed + an extraneous ';' at the end of CPPUNIT_TEST_SUITE_END macro. + + * examples/cppunittest/TestCallerTest.cpp: bug #448332, fixed + memory leaks. + + * src/msvc6/testrunner/TestRunnerDlg.h: + * src/msvc6/testpluginrunner/TestPlugInRunnerDlg.h: + * src/msvc6/testpluginrunner/TestPlugInRunnerDlg.cpp: change to define + IDD to a dummy value when subclassing the dialog. + + * src/cppunit/cppunit.dsp: + * src/msvc6/testrunner/TestRunner.dsp: + * src/msvc6/testpluginrunner/TestPlugInRunner.dsp: + * examples/cppunitttest/CppUnitTestMain.dsp: + * examples/hierarchy.dsp: + * examples/msvc6/TestPlugIn/TestPlugIn.dsp: + * examples/msvc6/HostApp/HostApp.dsp: all configurations can be compiled. + + * src/msvc6/testpluginrunner/TestPlugInRunner.dsw: added dependency to + cppunit.dsp and TestRunner.dsp. + +2001-09-16 Steve M. Robbins + + * Revert TestFixture-related changes from 2001-07-15: + + * src/cppunit/cppunit.dsp (SOURCE): Remove TestFixture.h. + + * src/cppunit/TestCase.cpp (setUp, tearDown): Restore function + bodies. + + * include/cppunit/TestCase.h (class TestCase): Do not derive + from class TestFixture. Restore member functions setUp() + and tearDown(). + + * include/cppunit/TestCaller.h: Do not include + . + + * include/cppunit/Makefile.am (libcppunitinclude_HEADERS): Remove + TestFixture.h. + +2001-09-14 Baptiste Lepilleur + * src/msvc6/testrunner/TestRunner.dsp: fixed release configuration. + + * src/msvc6/testrunner/TestRunner.dsw: added DSPlugIn.dsp. TestRunner + depends on DSPlugIn. + + * src/msvc6/testrunner/TestRunner.cpp: + * src/msvc6/testrunner/TestRunnerDlg.h: + * src/msvc6/testrunner/TestRunnerDlg.cpp: + * src/msvc6/testrunner/MsDevCallerListCtrl.cpp: + * src/msvc6/testrunner/MsDevCallerListCtrl.h: + * src/msvc6/DSPlugIn/*: integrated patch from + Patrick Berny (PPBerny@web.de). An add-ins for VC++. Double-cliking + a failed test in the TestRunner, VC++ will open the source file and + go to the failure location. + + * src/cppunit/Exception.cpp: + * include/cppunit/Exception.h: compile fix, call to overrided + operator = of parent class failed. Using typedef to the parent + class fix that. + + * src/cppunit/cppunit.dsp: added TestFixture.h + + * src/cppunit/TestFactoryRegistry.cpp: removed which isn't + needed any more. + + * include/cppunit/TestCase.h: + * include/cppunit/TestSuite.h: + * include/cppunit/extensions/TestFactoryRegistry.h: added + include before any other includes to remove warning + with VC++. + + * include/cppunit/Portability.h: moved platform specific includes at + the beginning of the header. fixed CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION + declaration. + + * include/cppunit/config-msvc6.h: removed pragma once (useless, should + be put in each header to have an effect). + +2001-08-07 Steve M. Robbins + + * doc/Makefile.am: Add workaround for broken Doxygen. + + * src/cppunit/TextTestResult.cpp (operator<<): Remove CppUnit:: + prefix. + + * configure.in: Add check for . + * src/cppunit/TestAssert.cpp: Use if not + available. + * src/cppunit/TestCase.cpp: Do not include . + + * include/cppunit/config-bcb5.h (HAVE_CMATH): + * include/cppunit/config-msvc6.h (HAVE_CMATH): Add. + + * src/cppunit/Exception.cpp: Qualify std::exception. + + * examples/cppunittest/OrthodoxTest.h (TestCase): Add assignment + operator. MIPSpro fails to compile without one. + + * Makefile.am: Removed automake conditional "DOC". + * doc/Makefile.am: Placed "DOC" conditional around + rules that invoke Doxygen. + + * config/Makefile.am: Removed. + * configure.in: Do not create config/Makefile. + * Makefile.am (EXTRA_DIST): Distribute config/*.m4. + (SUBDIRS): Do not descend into config. + +2001-07-15 Steve M. Robbins + + * include/cppunit/TestFixture.h: New. Declare class TextFixture. + + * include/cppunit/TestCaller.h: + * include/cppunit/TestCase.h: + * src/cppunit/TestCase.cpp: + * include/cppunit/Makefile.am: Subclass TestCase from TestFixture. + +2001-07-14 Steve M. Robbins + + * include/cppunit/Exception.h: + * include/cppunit/Test.h: + * include/cppunit/TestCaller.h: + * include/cppunit/TestCase.h: + * include/cppunit/TestFailure.h: + * include/cppunit/TestListener.h: + * include/cppunit/TestSuite.h: + * include/cppunit/extensions/RepeatedTest.h: + * include/cppunit/extensions/TestDecorator.h: + * src/cppunit/TestCase.cpp: Add documentation. + +2001-07-13 Steve M. Robbins + + * examples/cppunittest/TestAssertTest.h: + * examples/cppunittest/TestAssertTest.cpp: Add tests + for CPPUNIT_ASSERT_EQUAL. + +2001-07-12 Steve M. Robbins + + * configure.in: Set to version 1.5.6. On the assumption that + backwards compatibility has been broken (though I'm not certain), + set the binary age and interface age to zero. + + * examples/cppunittest/TestFailureTest.h: + * include/cppunit/Exception.h: + * include/cppunit/NotEqualException.h: + * src/cppunit/Exception.cpp: + * src/cppunit/NotEqualException.cpp: Add "throw()" to overridden + std::exception destructors; required for GCC 3.0. + +2001-07-07 Steve M. Robbins + + * include/cppunit/Makefile.am: Clean config-auto.h using + DISTCLEANFILES. + + * doc/Makefile.am: Temporarily disable manpage installation. + Fix html installation to ensure files removed by uninstall. + + * src/cppunit/estring.h: Removed. + + * src/cppunit/Makefile.am: + * src/cppunit/TestCase.cpp: + * src/cppunit/TextTestResult.cpp: Recode to avoid use of estring. + + * examples/cppunittest/OrthodoxTest.h: Add const qualifier + to operator== methods. + + * include/cppunit/config-bcb5.h: + * include/cppunit/config-msvc6.h: Define CPPUNIT_HAVE_SSTREAM to 1. + + * config/ac_cxx_have_sstream.m4: New. Defines macro + AC_CXX_HAVE_SSTREAM. Taken from the autoconf archive. + + * config/ac_cxx_have_strstream.m4: New. Copy of above, + modified to check for presence of strstream; defines + macro AC_CXX_HAVE_STRSTREAM. + + * configure.in: Invoke AC_CXX_HAVE_SSTREAM and + AC_CXX_HAVE_STRSTREAM. + + * include/cppunit/Portability.h: Define class + CppUnit::OStringStream. + + * include/cppunit/TestAssert.h: + * src/cppunit/TestFactoryRegistry.cpp: Replace std::ostringstream + by CppUnit::OStringStream. + + +2001-07-06 Steve M. Robbins + + * configure.in: Add --disable-typeinfo-name option. + + * README: Add note about new configure option. + + * configure.in: Remove AM_DISABLE_STATIC. + + * INSTALL: Update to version from autoconf 2.50. + +2001-07-05 Steve M. Robbins + + * include/cppunit/Portability.h: Remove definition of + CPPUNIT_USE_TYPEINFO. + + * configure.in: Define USE_TYPEINFO_NAME in config.h. + + * include/cppunit/config-msvc6.h (CPPUNIT_USE_TYPEINFO_NAME): + * include/cppunit/config-bcb5.h (CPPUNIT_USE_TYPEINFO_NAME): Add + definition. + + * include/cppunit/TestCaller.h: + * include/cppunit/extensions/TypeInfoHelper.h: + * include/cppunit/extensions/TestSuiteBuilder.h: + * include/cppunit/extensions/HelperMacros.h: + * src/cppunit/TypeInfoHelper.cpp: + * src/cppunit/TestFactoryRegistry.cpp: + * src/cppunit/TestCase.cpp (toString): + Switch from CPPUNIT_USE_TYPEINFO to CPPUNIT_USE_TYPEINFO_NAME. + + * src/cppunit/TestAssert.cpp: Remove include of estring.h. + + * configure.in: Invoke AC_PROG_CC to workaround a automake + bug. Move probes for CC/CXX ahead of the libtool macros. + + * examples/hierarchy/Makefile.am: + * examples/cppunittest/Makefile.am: + * src/cppunit/Makefile.am (INCLUDES): Search + $(top_builddir)/include for . + +2001-06-27 Baptiste Lepilleur + + * examples/msvc6/CppUnitTestApp/CppUnitTestApp.dsp: + moved dll copy from post-build to custom build setting, so that the + dll is copied even if the CppUnitTestApp was not modified. + + * examples/msvc6/TestPlugIn/: a new example of test plug in. + + * src/msvc6/TestRunner/ListCtrlFormatter.* + * src/msvc6/TestRunner/ListCtrlSetter.*: + added, helper to manipulate list control. + + * src/msvc6/TestRunner/TestRunnerDlg.*: change to make the error list + more compact. text moved to string resources. icons added for typ + test tfailure type. + + * src/msvc6/TestRunner/MostRecentTests.*: added, classes that will + replace the current implementation of MRU test which make it hard + to subclass the dialog. + + * src/msvc6/TestRunner/res/errortype.bmp: added, bitmap with error + types (failure and error). + + * src/msvc6/TestPlugInRunner/: A test runner to run test plug in. + Test plug in are DLL that publish a specified plug in interface. + Those DLL are loaded and reloaded by the TestPlugInRunner to run + tests. This remove the need to wrap DLL with a executable to test + them. + + * src/cppunit/cppunit.dsp: + removed config.h from project + added Portability.h and config-msvc6.h + + * include/cppunit/config-msvc6.h: + undef CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST + + +2001-06-20 Steve M. Robbins + + * autogen.sh: Stop when tool fails. Try /usr/local/share/aclocal + only if aclocal fails without it. + + * README.CVS: New. + +2001-06-18 Steve M. Robbins + + * include/cppunit/Portability.h (CPPUNIT_USE_TYPEINFO): + (CPPUNIT_ENABLE_NAKED_ASSERT): + (CPPUNIT_HAVE_CPP_SOURCEANNOTATION): Fix setting of + default values. + +2001-06-17 Steve M. Robbins + + * configure.in: Require autoconf 2.50 or better. + +2001-06-17 Bastiaan Bakker + + * configure.in: moved config.h from include/ to config/ + + * configure.in: added AC_CREATE_PREFIX_CONFIG_H call + + * config/ac_create_prefix_config_h.m4: added + + * configure.in: removed include/cppunit/config.h from AC_OUTPUT + * include/cppunit/config.h.in: obsoleted by + AC_CREATE_PREFIX_CONFIG_H macro. + + * configure.in: + * config/bb_enable_doxygen.m4: moved doxygen stuff into + BB_ENABLE_DOXYGEN macro + + * include/cppunit/Makefile.am: removed config.h, added config-auto.h, + config-msvc6.h, config-bcb5.h, Portability.h + + * include/cppunit/Makefile.am: added dist-hook to exclude + config-auto.h from dist tar + + * include/cppunit/TestAssert.h: + * include/cppunit/extensions/TypeInfoHelper.h: + * include/cppunit/extensions/TestSuiteBuilder.h: + * include/cppunit/extensions/HelperMacros.h: + * src/cppunit/TypeInfoHelper.cpp: + * src/cppunit/TestRegistry.cpp: + * src/cppunit/TestFactoryRegistry.cpp: + * src/cppunit/TestCase.cpp: replaced #include of with + + + * src/cppunit/TypeInfoHelper.cpp: use new macro name + CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST + + +2001-06-12 Baptiste Lepilleur + + * include/cppunit/NotEqualException.h + * src/cppunit/NotEqualException.h: + Fixed constructor and operator = (aren't unit test nice?). Added + methods expectedValue() and actualValue(). + + * include/cppunit/TestAssert.h: + * src/cppunit/TestAssert.cpp: + Use NotEqualException to report equality failure. + + * src/cppunit/TestFactoryRegistry.cpp: fixed makeTest(). It did not use m_name for + naming the suite. + + * src/cppunit/TestResult.cpp: + Report expect/was on different line for assertEquals failure. + + * examples/cppunittest/NotEqualExceptionTest.*: added unit tests for + NotEqualException. + + * examples/cppunittest/OrthodoxTest.*: operator ! use explicit construction. + + * examples/msvc6/CppUnitTestApp/CppUnitTestApp.cpp: modified so that the dialog + is not displayed after the tests are run. + +2001-06-11 Steve M. Robbins + + * examples/cppunittest/TestResultTest.cpp (testAddTwoErrors, + testAddTwoFailures): Replace vector::at() with more portable + vector::operator[]; GCC doesn't have the former. + + * include/cppunit/extensions/TestDecorator.h (countTestCases): + Declare return type. + + * src/cppunit/Makefile.am (libcppunit_la_SOURCES): Add + TestAssert.cpp, RepeatedTest.cpp. + + * include/cppunit/TestCaller.h (NoExceptionExpected): Fix + constructor name. + +2001-06-11 Baptiste Lepilleur + + * include/cppunit/Exception.h: now inherit from std::exception + instead of ::exception. Added clone(), type(), and isInstanceOf() + methods for subclassing support. Changed UNKNOWNLINENUMBER type to + long for consistence with lineNumber(). + + * include/cppunit/NotEqualException.h: addded, exception to be + used with assertEquals(). + + * include/cppunit/TestAssert.h: changed TestAssert into a + namespace instead of a class. This remove the need of template + member methods and does not cause compiler internal error on + VC++. Macro CPPUNIT_ASSERT_MESSAGE has been added to fail test + with a specified message. + + * include/cppunit/TestCaller.h: added "Expected exception" + support. Based on Tim Jansen patch (#403745), but use a traits + instead of RTTI to distingh between "No expected exception" and + "Excepted exception". Exception type name is reported using RTTI + if CPPUNIT_USE_TYPEINFO is defined. + + * include/cppunit/extensions/HelperMacros.h: static method suite() + implemented by CPPUNIT_TEST_SUITE_END macro now returns a + TestSuite instead of a Test. + + * include/cppunit/extensions/RepeatedTest.h: corrected + countTestCases, operator = declaration. + + * include/cppunit/extensions/TestDecorator.h: removed const from + run() method. Did not match run() declaration of Test class. + + * include/cppunit/extensions/TestFactory.h: fixed a comment. + + * include/cppunit/extensions/TestSetup.h: corrected run() method + declaration. Methods setUp() and tearDown() were not declared + virtual. + + * include/cppunit/extensions/TestSuiteBuilder.h: added a method + addTestCaller() which take a pointer on a fixture. + + * include/cppunit/NotEqualException.cpp: addded, exception to be + used with assertEquals(). + + * src/cppunit/RepeatedTest.cpp: added to reduce header dependency + (TestResult.h was missing). + + * src/cppunit/TestAssert.cpp: added to put non template functions + there. + + * src/cppunit/TestCase.cpp: added std:: prefix to catch + (exception& e). Integrated a modified version of Tim Jansen patch + (#403745) for TestCase to make the unit test (TestCaseTest) + pass. If the setUp() fail then neither the runTest() nor the + tearDown() method is called. + + * examples/examples.dsw: added cppunittest projects to workspace. + + * examples/cppunittest/TestResultTest.*: renamed + TestListenerTest.* + + * examples/cppunittest/*: added unit tests for: HelperMacros, + TestAssert, TestCaller, TestCase, TestFailure, TestResult, + TestSuite, TestDecoratorTest, TestSetUp, RepeatedTestTest, + Orthodox, Exception. + +2001-06-05 Baptiste Lepilleur + + * src/cppunit/TypeInfoHelper.cpp: removed #include , + cppunit/config.h was already included. + + * src/cppunit/cppunit.dsp: removed TestAssert.cpp from project. + + * added/updated .cvsignore files for beter handling of windows + projects. + + * added include/cppunit/config.h with a default configuration for + VC++ 6.0. + + * include/cppunit/.cvsignore: removed config.h from the list of + ignored file. + + * renamed VC++ configurations without RTTI from "Debug No + CU_USE_TYPEINFO" to "Debug Crossplatform". + + * include/cppunit/TestAssert.h: added include for fabs(). + +2001-06-02 Steve M. Robbins + + * src/cppunit/Exception.cpp: Remove unnecessary namespace + declaration; it confuses Doxygen. + +2001-06-02 Steve M. Robbins + + * configure.in: Add AC_CXX_STRING_COMPARE_STRING_FIRST. + + * autogen.sh: Add "-I config" to aclocal flags, to pick up + the new .m4 files. + + * config/ac_cxx_namespaces.m4: New. Taken from + http://cryp.to/autoconf-archive. + + * config/ac_cxx_string_compare_string_first.m4: New. Detect + if std::string::compare() takes string argument first. + +2001-06-02 Steve M. Robbins + + * include/cppunit/TestAssert.h: Declare generic assertion_traits + class. Replace notEqualsMessage functions for long and double by + a generic, template function. Replace assertEquals for longs by a + generic template function. Inline all class methods. Define new + assertion macros CPPUNIT_ASSERT, CPPUNIT_ASSERT_EQUAL, and + CPPUNIT_ASSERT_DOUBLES_EQUAL; the old names are available by + editing . + + * src/cppunit/TestAssert.cpp: Removed. Move code to inline + functions. + + * config/ac_cxx_rtti.m4: New. Taken from + http://cryp.to/autoconf-archive. + + * include/cppunit/config.h.in: New. Input file for installable, + generated config.h file. + + * configure.in: Use AC_CXX_RTTI; generate include/cppunit/config.h. + + * include/cppunit/extensions/HelperMacros.h: + * include/cppunit/extensions/TestSuiteBuilder.h: + * include/cppunit/extensions/TypeInfoHelper.h: + * src/cppunit/TestCase.cpp: + * src/cppunit/TestFactoryRegistry.cpp: + * src/cppunit/TypeInfoHelper.cpp: + Use "#if CPPUNIT_USE_TYPEINFO" rather than "#ifdef". + + * src/cppunit/TypeInfoHelper.cpp: Allow for std::string::compare() + that takes the string in the first argument. + + * doc/cookbook.html: + * examples/cppunittest/TestCallerTest.cpp: + * examples/cppunittest/TestResultTest.cpp: + * examples/hierarchy/BoardGameTest.h: + * examples/hierarchy/ChessTest.h: + * examples/msvc6/HostApp/ExampleTestCase.cpp: + * include/cppunit/TestCase.h: + * include/cppunit/extensions/Orthodox.h: + Replace assert by CPPUNIT_ASSERT. + Replace assertLongsEqual by CPPUNIT_ASSERT_EQUAL. + Replace assertDoublesEqual by CPPUNIT_ASSERT_DOUBLES_EQUAL. + + * * (CU_TEST_SUITE, CU_TEST, CU_TEST_SUITE_END, + CU_TEST_SUITE_REGISTRATION): Replace prefix CU_ with CPPUNIT_. + + * examples/cppunittest/.cvsignore: Add UNIX generated files. + +2001-06-01 Bastiaan Bakker + + * examples/cppunittest/Makefile.am: added + + * configure.in: added examples/cppunittest/Makefile to AC_OUTPUT. + + * examples/cppunittest/TestCallerTest (suite), + examples/cppunittest/TestResultTest (suite): fixed 'ISO C++ + forbids taking the address of a bound member function to form + a pointer to member function' bug reported by g++. + + * examples/cppunittest/TestCallerTest (suite), + examples/cppunittest/TestResultTest (suite): removed dependency on + RTTI. + +2001-06-01 Baptiste Lepilleur + + * added project cppunittest to examples/: unit tests to test cppunit. + The main file is CppUnitTestMain.cpp. Unit tests have been implemented + for TestCaller and TestListener. + + * added project CppUnitTestApp to examples/msvc6: graphical runner + for cppunittest. + + * added TestListener to TestResult. It is a port of junit + TestListener. + + * updated some .cvsignore to ignore files generated with VC++. + +2001-05-30 Bastiaan Bakker + + * src/cppunit/TestCase.cpp (toString): put type_info in std + namespace and inside CU_USE_TYPEINFO ifdef. + +2001-05-29 Steve M. Robbins + + * examples/hierarchy/main.cpp: Remove extraneous includes. + + * src/cppunit/TextTestResult.cpp (addError, addFailure): Do not + emit a newline. + + * include/cppunit/extensions/HelperMacros.h: Rework documentation. + (CU_TEST_SUITE): Move definition of member function suite() ... + (CU_TEST_SUITE_END): ... to here. + (CU_TEST): Use '&' to take address of member function + "testMethod". + + * include/cppunit/extensions/AutoRegisterSuite.h: Declare "factory" + as a TestFactory*. + +2001-05-28 Steve M. Robbins + + * doc/other_documentation.dox: Don't include "CppUnit" in + anchor text, since Doxygen puts its own anchor around it. + + * doc/Makefile.am (html/index.html): Depend on + other_documentation.dox. + + * doc/Doxyfile.in (EXCLUDE): Move config.h and estring.h to + EXCLUDE_PATTERNS; they were not being excluded. + + * ChangeLog: Reformat all entries to start with . See + for change log + format. + + * doc/cookbook.html: Update all code examples, except for TestRunner + section. + +2001-05-23 Baptiste Lepilleur + + * Updated CU_TEST_SUITE macro documentation. It is now stated + explicitly that you do not need to specify template parameter as + macro argument. The documentation example has been updated to + reflect that. + +2001-05-23 Bastiaan Bakker + + * autogen.sh: added '--add-missing' option to automake. + * autogen.sh: added '--force' option to libtoolize and removed + '--copy'. + * config: removed generated files from CVS. + +2001-05-20 Baptiste Lepilleur + + * Fixed bug #424320 (VC++ TestRunner): access violation caused by + NULL pointer in history list. NULL pointer are not added to the + history anymore. + +2001-05-19 Baptiste Lepilleur + + * Added some items to the TODO list for VC++ TestRunner. + + * "Debug" configuration is now the default configuration in VC++ + project. + + * Modified sort order in the test browser of VC++ TestRunner so + that tests are in the same order as in the suite. Suites are still + sorted alphabetically. + + * Merged Steve M. Robbins patch to replace assertImplementation + with assert in hierarchy example. + + * Added a TextTestRunner to runner tests. It is based on Michael + Feather's version, but have been rewriten. + + * Removed traces that printed the test name in TextTestResult + while running. + + * Added the test name to error and failure report in + TextTestResult. + + * Updated hierarchy example to use TextTestRunner. + +2001-05-18 Baptiste Lepilleur + + * Symbol CU_USE_TYPEINFO must be defined instead of USE_TYPEINFO + to compile RTTI. + + * Added back default constructor to TestSuiteBuilder which use + RTTI. It is available only if CU_USE_TYPEINFO is defined. + + * Moved TypeInfoHelper.h from src/cppunit to + include/cppunit/extensions. + + * Macro CU_TEST_SUITE in HelperMacros.h now use TestSuiteBuilder + default constructor if CU_USE_TYPEINFO is defined, otherwise it + use the type name given to the CU_TEST_SUITE macro. + + * TestFactoryRegistry::registerFactory(factory) now generate a + dummy name based on a serial number instead of using RTTI. The + macro CU_TEST_SUITE_REGISTRATION and class AutoRegisterSuite can + now when CU_USE_TYPEINFO is not defined. + + * Added a new Configuration named "Debug Without CU_USE_TYPEINFO" + to msvc6 projects. The flag CU_USE_TYPEINFO is not defined in that + configuration. + +2001-05-17 Steve M. Robbins + + * Makefile.am (dist-hook): Copy files relative to $(top_srcdir). + + * doc/Makefile.am: Generated doc files depend on Doxyfile. + + * doc/Doxyfile.in: Use autoconf substitutions in file names. + + * examples/hierarchy/Makefile.am (check_PROGRAMS): Build hierarchy + with "make check", not "make all". + + * examples/hierarchy/Makefile.am (INCLUDES): + + * src/cppunit/Makefile.am (INCLUDES): Search in + $(top_srcdir)/include. + + * Added .cvsignore files. + +2001-05-16 Bastiaan Bakker + + * Merged Debian packaging support files by Christian Leutloff from + debian package version 1.5.4-2. Added make target 'debian' for + debian package creation. + +2001-05-09 Bastiaan Bakker + + * Release as 1.5.5. + + * Finished CppUnitW 1.2 merge. Removed RTTI depency from + TestSuite. Added TestCaller constructor for calling methods in + existing TestCases. + +2001-04-29 Bastiaan Bakker + + * Merged Baptiste Lepilleurs CppUnitW 1.2. Some differences: + TypeInfo stuff (in TestSuite) compiled in only if USE_TYPEINFO is + set. TestSuite.getTests now returns a const ref instead of taking + a ref as parameter. Removed auto_ptr stuff from + TestFactoryRegistry: auto_ptr cannot be used in containers. + +2001-04-28 Bastiaan Bakker + + * Merged MSVC++ specific TestRunner and example adapted from + Micheal Feathers version by Baptiste Lepilleur. + + * Moved cppunit subdir into src. + +2001-04-24 Bastiaan Bakker + + * Merged Baptiste Lepilleurs patch for TestRegistry: now TestCases + do not automatically register with the Registry anymore. + + * Added extension headers from Micheal Feathers port to + include/cppunit/extensions. + +2001-04-19 Bastiaan Bakker + + * Added MSVC++ workspace and project files, submitted by Baptiste + Lepilleur. + +2001-04-15 Bastiaan Bakker + + * Moved public headers from cppunit into new subdir + include/cppunit. This should make more clear which headers are + used internally only (like estring.h). + + * Moved autoconf auxiliary stuff into new subdir config, to make + the top dir less crowded. + + * Prefixed std:: to cerr, cout and endl. + +2001-04-14 Bastiaan Bakker + + * Release as 1.5.4 + + * Added support for RPM generation. + + * Added autoconf support for Doxygen document generation: Doxygen + and GraphViz dot are automatically detected and LaTeX and HTML can + be switch on or off. + + * cppunit/TextTestResult.cpp: changed cout to stream. Fixes bug + #232636 + + * cppunit/TextTestReulst.cpp: add '#include '. Fixes + bug #223290 + + * cppunit/*.cpp: removed bogus 'inline' specifiers. Fixes bug + #224542 and #223291. + + * doc/header.html: corrected link to CppUnit project page Fixes + bug #414073 + + * cppunit/*.cpp, examples/hierarchy/main.cpp: removed all 'using + namespace ...' occurences. + +2001-01-31 Tim Jansen + + * cppunit/TestCase.cpp, cppunit/TestCase.h, cppunit/TestSuite.h, + cppunit/TestSuite.cpp: applied patch #402271 by bwithrow. Fixes + bug #220207 + + * cppunit/TestSuite.cpp (deleteContents): clear vector after + contents have been deleted (so there are no invalid pointers in + the vector) Patch #403540 / #403542 + + * cppunit/TestCaller.h: create Fixture with empty constructor so + that only the TestCaller but not the Fixture instance is + registered in the TestRegistry Patch #403541 / #403542 + + * examples/hierarchy/BoardGameTest.h, + examples/hierarchy/ChessTest.h, examples/hierarchy/main.cpp: + initialize example TestCases with TestSuite so that the + TestCallers are registered in the TestRegistry Patch + #403542. Fixes bug #415249 + + * cppunit/TestCaller.h, cppunit/TestCase.cpp, cppunit/TestCase.h: + changed documentation; made hopefully clearer which constructor + registers the instance in the TestRegistry; corrected syntax in + code example Patch #403542. diff --git a/UnitTests/cppunit/CodingGuideLines.txt b/UnitTests/cppunit/CodingGuideLines.txt new file mode 100644 index 000000000..5651ee802 --- /dev/null +++ b/UnitTests/cppunit/CodingGuideLines.txt @@ -0,0 +1,61 @@ +CppUnit's coding guidelines for portability: +-------------------------------------------- + +- don't explicitly declare CppUnit namespace, instead use macro + CPPUNIT_NS_BEGIN and CPPUNIT_NS_END. + +- don't explicitly use 'CppUnit' to refer to class in CppUnit namespace, + instead use macro CPPUNIT_NS which expands to either 'CppUnit' or + nothing depending on the configuration. + +- don't use the 'using directive', always use full qualification. For STL, + always use std::. + +- don't use C++ style cast directly, instead use CppUnit's cast macro + (CPPUNIT_CONST_CAST). + +- don't use the mutable keyword, instead do a const cast. + +- don't use the typename keyword in template declaration, instead use 'class'. + +- don't make use of RTTI (typeid) or dynamic_cast mandatory. + +- don't use STL container directly, instead use CppUnit's wrapper located + in include/cppunit/portability. This help support compilers that don't + support default template parameter and require an allocator to be + specified. + +- don't use default template parameters. If needed, use STLPort wrapper + technic (see include/cppunit/portability/). + +- don't use templatized member functions (template method declared inside a + class), instead declares them as simple template functions (even + mainstream compiler such as VC++ 6 as trouble with them). + +- don't use default parameter value in template function. Not supported + by all compiler (on OS/390 for instance). + +- don't use STL container at() method, instead use the array accessor []. + at() is not supported on some gcc versions. + +- dereferencing containers must be done by (*ref_ptr).data instead of + ref_ptr->data. + +In brief, it should be possible to compile CppUnit on a C++ compiler that do +not have the following features: +- C++ style cast +- mutable and typename keyword +- RTTI +- template default parameters +- templatized member functions (that is a template function declared within a + class). +- namespace + +As such, usage of those features should always be optional. + +Following those guidelines should allow to compile on most compilers, as long +as STL are available (in std namespace or not), with some form of strstream and +iostream, as well as exception support. + +-- +Baptiste Lepilleur diff --git a/UnitTests/cppunit/THANKS b/UnitTests/cppunit/THANKS new file mode 100644 index 000000000..89cfa9c7a --- /dev/null +++ b/UnitTests/cppunit/THANKS @@ -0,0 +1,23 @@ +Tim Jansen +Christian Leutloff +Steve M. Robbins +Patrick Berny +Patrick Hartling +Peer Sommerlund +Duane Murphy +Gigi Sayfan +Armin "bored" Michel +Jeffrey Morgan +'cuppa' project team (http://sourceforge.jp/projects/cuppa/) +Phil Verghese +Lavoie Philippe +Pavel Zabelin +Marco Welti +Thomas Neidhart +Hans Bühler (Dynamic Window library used by MFC UI) +John Sisson +Steven Mitter +Stephan Stapel +Abdessattar Sassi (hp-ux plug-in support) +Max Quatember and Andreas Pfaffenbichler (VC++ 7 MFC TestRunner go to source line) +Vincent Rivière diff --git a/UnitTests/cppunit/TODO b/UnitTests/cppunit/TODO new file mode 100644 index 000000000..19fa3240a --- /dev/null +++ b/UnitTests/cppunit/TODO @@ -0,0 +1,35 @@ +* Bugs: +Asserter::makeNotEqualMessage() strip the shortDescription of the additional message. + +* CppUnit: + - STL concept checker. + - Memory leak tracking: setUp/tearDown should be leak safe if no failure occured. + +* UnitTest + - add tests for XmlOutputter::setStyleSheet (current assertion macro strip when + testing ) + +* VC++ TestRunner: + - Modify MfcUi::TestRunner to expose TestResult (which allow specific TestListener + for global initialization). + - Update MfcTestRunner to use TestPath to store test in the registry + +* Documentation: + CookBook: + - how to create simple test cases (with CppUnit namespace) + - test case using only CPPUINT_ASSERT + - test case using CPPUNIT_ASSERT_EQUAL + - advanced assertions with the CPPUNIT_ASSERT_MESSAGE + - Helper Macros for convenience + - Creating a suite + - Composing a suite from more suites (i.e. compose tests for n modules to + form a big test for the whole program) + - customizing output using an user defined TestListener + - how to write the TestListener (subclass of TestListener) + - how to hook it in + - how to use the GUI + - MSVC++ special stuff + - other custmization stuff I haven't understood yet + + CppUnit: architecture overview. + diff --git a/UnitTests/cppunit/include/cppunit/AdditionalMessage.h b/UnitTests/cppunit/include/cppunit/AdditionalMessage.h new file mode 100644 index 000000000..917d75414 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/AdditionalMessage.h @@ -0,0 +1,76 @@ +#ifndef CPPUNIT_ADDITIONALMESSAGE_H +#define CPPUNIT_ADDITIONALMESSAGE_H + +#include + + +CPPUNIT_NS_BEGIN + + +/*! \brief An additional Message for assertions. + * \ingroup CreatingNewAssertions + * + * Provides a implicit constructor that takes a single string. This allow this + * class to be used as the message arguments in macros. + * + * The constructed object is either a Message with a single detail string if + * a string was passed to the macro, or a copy of the Message passed to the macro. + * + * Here is an example of usage: + * \code + * + * void checkStringEquals( const std::string &expected, + * const std::string &actual, + * const CppUnit::SourceLine &sourceLine, + * const CppUnit::AdditionalMessage &message ); + * + * #define XTLUT_ASSERT_STRING_EQUAL_MESSAGE( expected, actual, message ) \ + * ::XtlUt::Impl::checkStringEquals( ::Xtl::toString(expected), \ + * ::Xtl::toString(actual), \ + * CPPUNIT_SOURCELINE(), \ + * message ) + * \endcode + * + * In the previous example, the user can specify a simple string for \a message, + * or a complex Message object. + * + * \see Message + */ +class CPPUNIT_API AdditionalMessage : public Message +{ +public: + typedef Message SuperClass; + + /// Constructs an empty Message. + AdditionalMessage(); + + /*! \brief Constructs a Message with the specified detail string. + * \param detail1 Detail string of the message. If empty, then it is not added. + */ + AdditionalMessage( const std::string &detail1 ); + + /*! \brief Constructs a Message with the specified detail string. + * \param detail1 Detail string of the message. If empty, then it is not added. + */ + AdditionalMessage( const char *detail1 ); + + /*! \brief Constructs a copy of the specified message. + * \param other Message to copy. + */ + AdditionalMessage( const Message &other ); + + /*! \brief Assignment operator. + * \param other Message to copy. + * \return Reference on this object. + */ + AdditionalMessage &operator =( const Message &other ); + +private: +}; + + +CPPUNIT_NS_END + + + +#endif // CPPUNIT_ADDITIONALMESSAGE_H diff --git a/UnitTests/cppunit/include/cppunit/Asserter.h b/UnitTests/cppunit/include/cppunit/Asserter.h new file mode 100644 index 000000000..94dadaad7 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/Asserter.h @@ -0,0 +1,143 @@ +#ifndef CPPUNIT_ASSERTER_H +#define CPPUNIT_ASSERTER_H + +#include +#include +#include + +CPPUNIT_NS_BEGIN + + +class Message; + + +/*! \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 + * #include + * + * 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 + */ +struct Asserter +{ + /*! \brief Throws a Exception with the specified message and location. + */ + static void CPPUNIT_API fail( const Message &message, + const SourceLine &sourceLine = SourceLine() ); + + /*! \brief Throws a Exception with the specified message and location. + * \deprecated Use fail( Message, SourceLine ) instead. + */ + static void CPPUNIT_API fail( std::string message, + const SourceLine &sourceLine = SourceLine() ); + + /*! \brief 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. + */ + static void CPPUNIT_API failIf( bool shouldFail, + const Message &message, + const SourceLine &sourceLine = SourceLine() ); + + /*! \brief Throws a Exception with the specified message and location. + * \deprecated Use failIf( bool, Message, SourceLine ) instead. + * \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. + */ + static void CPPUNIT_API failIf( bool shouldFail, + std::string message, + const SourceLine &sourceLine = SourceLine() ); + + /*! \brief Returns a expected value string for a message. + * Typically used to create 'not equal' message, or to check that a message + * contains the expected content when writing unit tests for your custom + * assertions. + * + * \param expectedValue String that represents the expected value. + * \return \a expectedValue prefixed with "Expected: ". + * \see makeActual(). + */ + static std::string CPPUNIT_API makeExpected( const std::string &expectedValue ); + + /*! \brief Returns an actual value string for a message. + * Typically used to create 'not equal' message, or to check that a message + * contains the expected content when writing unit tests for your custom + * assertions. + * + * \param actualValue String that represents the actual value. + * \return \a actualValue prefixed with "Actual : ". + * \see makeExpected(). + */ + static std::string CPPUNIT_API makeActual( const std::string &actualValue ); + + static Message CPPUNIT_API makeNotEqualMessage( const std::string &expectedValue, + const std::string &actualValue, + const AdditionalMessage &additionalMessage = AdditionalMessage(), + const std::string &shortDescription = "equality assertion failed"); + + /*! \brief Throws an Exception with the specified message and location. + * \param expected Text describing the expected value. + * \param actual Text describing the actual value. + * \param sourceLine Location of the assertion. + * \param additionalMessage Additional message. Usually used to report + * what are the differences between the expected and actual value. + * \param shortDescription Short description for the failure message. + */ + static void CPPUNIT_API failNotEqual( std::string expected, + std::string actual, + const SourceLine &sourceLine, + const AdditionalMessage &additionalMessage = AdditionalMessage(), + std::string shortDescription = "equality assertion failed" ); + + /*! \brief Throws an Exception 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 sourceLine Location of the assertion. + * \param additionalMessage Additional message. Usually used to report + * where the "difference" is located. + * \param shortDescription Short description for the failure message. + */ + static void CPPUNIT_API failNotEqualIf( bool shouldFail, + std::string expected, + std::string actual, + const SourceLine &sourceLine, + const AdditionalMessage &additionalMessage = AdditionalMessage(), + std::string shortDescription = "equality assertion failed" ); + +}; + + +CPPUNIT_NS_END + + +#endif // CPPUNIT_ASSERTER_H diff --git a/UnitTests/cppunit/include/cppunit/BriefTestProgressListener.h b/UnitTests/cppunit/include/cppunit/BriefTestProgressListener.h new file mode 100644 index 000000000..137ca44b3 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/BriefTestProgressListener.h @@ -0,0 +1,43 @@ +#ifndef CPPUNIT_BRIEFTESTPROGRESSLISTENER_H +#define CPPUNIT_BRIEFTESTPROGRESSLISTENER_H + +#include + + +CPPUNIT_NS_BEGIN + + +/*! \brief TestListener that prints the name of each test before running it. + * \ingroup TrackingTestExecution + */ +class CPPUNIT_API BriefTestProgressListener : public TestListener +{ +public: + /*! Constructs a BriefTestProgressListener object. + */ + BriefTestProgressListener(); + + /// Destructor. + virtual ~BriefTestProgressListener(); + + void startTest( Test *test ); + + void addFailure( const TestFailure &failure ); + + void endTest( Test *test ); + +private: + /// Prevents the use of the copy constructor. + BriefTestProgressListener( const BriefTestProgressListener © ); + + /// Prevents the use of the copy operator. + void operator =( const BriefTestProgressListener © ); + +private: + bool m_lastTestFailed; +}; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_BRIEFTESTPROGRESSLISTENER_H diff --git a/UnitTests/cppunit/include/cppunit/CompilerOutputter.h b/UnitTests/cppunit/include/cppunit/CompilerOutputter.h new file mode 100644 index 000000000..885fe6526 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/CompilerOutputter.h @@ -0,0 +1,146 @@ +#ifndef CPPUNIT_COMPILERTESTRESULTOUTPUTTER_H +#define CPPUNIT_COMPILERTESTRESULTOUTPUTTER_H + +#include +#include +#include + +CPPUNIT_NS_BEGIN + + +class Exception; +class SourceLine; +class Test; +class TestFailure; +class TestResultCollector; + +/*! + * \brief Outputs a TestResultCollector in a compiler compatible format. + * \ingroup WritingTestResult + * + * Printing the test results in a compiler compatible format (assertion + * location has the same format as compiler error), allow you to use your + * IDE to jump to the assertion failure. Location format can be customized (see + * setLocationFormat() ). + * + * For example, when running the test in a post-build with VC++, if an assertion + * fails, you can jump to the assertion by pressing F4 (jump to next error). + * + * Heres is an example of usage (from examples/cppunittest/CppUnitTestMain.cpp): + * \code + * int main( int argc, char* argv[] ) { + * // if command line contains "-selftest" then this is the post build check + * // => the output must be in the compiler error format. + * bool selfTest = (argc > 1) && + * (std::string("-selftest") == argv[1]); + * + * CppUnit::TextUi::TestRunner runner; + * runner.addTest( CppUnitTest::suite() ); // Add the top suite to the test runner + * + * if ( selfTest ) + * { // Change the default outputter to a compiler error format outputter + * // The test runner owns the new outputter. + * runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(), + * std::cerr ) ); + * } + * + * // Run the test and don't wait a key if post build check. + * bool wasSuccessful = runner.run( "", !selfTest ); + * + * // Return error code 1 if the one of test failed. + * return wasSuccessful ? 0 : 1; + * } + * \endcode + */ +class CPPUNIT_API CompilerOutputter : public Outputter +{ +public: + /*! \brief Constructs a CompilerOutputter object. + * \param result Result of the test run. + * \param stream Stream used to output test result. + * \param locationFormat Error location format used by your compiler. Default + * to \c CPPUNIT_COMPILER_LOCATION_FORMAT which is defined + * in the configuration file. See setLocationFormat() for detail. + * \see setLocationFormat(). + */ + CompilerOutputter( TestResultCollector *result, + OStream &stream, + const std::string &locationFormat = CPPUNIT_COMPILER_LOCATION_FORMAT ); + + /// Destructor. + virtual ~CompilerOutputter(); + + /*! \brief Sets the error location format. + * + * Indicates the format used to report location of failed assertion. This format should + * match the one used by your compiler. + * + * The location format is a string in which the occurence of the following character + * sequence are replaced: + * + * - "%l" => replaced by the line number + * - "%p" => replaced by the full path name of the file ("G:\prg\vc\cppunit\MyTest.cpp") + * - "%f" => replaced by the base name of the file ("MyTest.cpp") + * + * Some examples: + * + * - VC++ error location format: "%p(%l):" => produce "G:\prg\MyTest.cpp(43):" + * - GCC error location format: "%f:%l:" => produce "MyTest.cpp:43:" + * + * Thoses are the two compilers currently supported (gcc format is used if + * VC++ is not detected). If you want your compiler to be automatically supported by + * CppUnit, send a mail to the mailing list (preferred), or submit a feature request + * that indicates how to detect your compiler with the preprocessor (\#ifdef...) and + * your compiler location format. + */ + void setLocationFormat( const std::string &locationFormat ); + + /*! \brief Creates an instance of an outputter that matches your current compiler. + * \deprecated This class is specialized through parameterization instead of subclassing... + * Use CompilerOutputter::CompilerOutputter instead. + */ + static CompilerOutputter *defaultOutputter( TestResultCollector *result, + OStream &stream ); + + void write(); + + void setNoWrap(); + + void setWrapColumn( int wrapColumn ); + + int wrapColumn() const; + + virtual void printSuccess(); + virtual void printFailureReport(); + virtual void printFailuresList(); + virtual void printStatistics(); + virtual void printFailureDetail( TestFailure *failure ); + virtual void printFailureLocation( SourceLine sourceLine ); + virtual void printFailureType( TestFailure *failure ); + virtual void printFailedTestName( TestFailure *failure ); + virtual void printFailureMessage( TestFailure *failure ); + +private: + /// Prevents the use of the copy constructor. + CompilerOutputter( const CompilerOutputter © ); + + /// Prevents the use of the copy operator. + void operator =( const CompilerOutputter © ); + + virtual bool processLocationFormatCommand( char command, + const SourceLine &sourceLine ); + + virtual std::string extractBaseName( const std::string &fileName ) const; + +private: + TestResultCollector *m_result; + OStream &m_stream; + std::string m_locationFormat; + int m_wrapColumn; +}; + + +CPPUNIT_NS_END + + +#endif // CPPUNIT_COMPILERTESTRESULTOUTPUTTER_H diff --git a/UnitTests/cppunit/include/cppunit/Exception.h b/UnitTests/cppunit/include/cppunit/Exception.h new file mode 100644 index 000000000..bf5fcacf6 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/Exception.h @@ -0,0 +1,90 @@ +#ifndef CPPUNIT_EXCEPTION_H +#define CPPUNIT_EXCEPTION_H + +#include +#include +#include +#include + + +CPPUNIT_NS_BEGIN + + +/*! \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: + /*! \brief Constructs the exception with the specified message and source location. + * \param message Message associated to the exception. + * \param sourceLine Source location related to the exception. + */ + Exception( const Message &message = Message(), + const SourceLine &sourceLine = SourceLine() ); + +#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED + /*! + * \deprecated Use other constructor instead. + */ + Exception( std::string message, + long lineNumber, + std::string fileName ); +#endif + + /*! \brief Constructs a copy of an exception. + * \param other Exception to copy. + */ + Exception( const Exception &other ); + + /// Destructs the exception + virtual ~Exception() throw(); + + /// Performs an assignment + Exception &operator =( const Exception &other ); + + /// Returns descriptive message + const char *what() const throw(); + + /// Location where the error occured + SourceLine sourceLine() const; + + /// Message related to the exception. + Message message() const; + + /// Set the message. + void setMessage( const Message &message ); + +#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED + /// The line on which the error occurred + long lineNumber() const; + + /// The file in which the error occurred + std::string fileName() const; + + static const std::string UNKNOWNFILENAME; + static const long UNKNOWNLINENUMBER; +#endif + + /// Clones the exception. + virtual Exception *clone() const; + +protected: + // VC++ does not recognize call to parent class when prefixed + // with a namespace. This is a workaround. + typedef std::exception SuperClass; + + Message m_message; + SourceLine m_sourceLine; + std::string m_whatMessage; +}; + + +CPPUNIT_NS_END + + +#endif // CPPUNIT_EXCEPTION_H + diff --git a/UnitTests/cppunit/include/cppunit/Message.h b/UnitTests/cppunit/include/cppunit/Message.h new file mode 100644 index 000000000..1ae51cc2b --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/Message.h @@ -0,0 +1,156 @@ +#ifndef CPPUNIT_MESSAGE_H +#define CPPUNIT_MESSAGE_H + +#include + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( push ) +#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z +#endif + +#include +#include + + +CPPUNIT_NS_BEGIN + + +#if CPPUNIT_NEED_DLL_DECL +// template class CPPUNIT_API std::deque; +#endif + +/*! \brief Message associated to an Exception. + * \ingroup CreatingNewAssertions + * A message is composed of two items: + * - a short description (~20/30 characters) + * - a list of detail strings + * + * The short description is used to indicate how the detail strings should be + * interpreted. It usually indicates the failure types, such as + * "assertion failed", "forced failure", "unexpected exception caught", + * "equality assertion failed"... It should not contains new line character (\n). + * + * Detail strings are used to provide more information about the failure. It + * can contains the asserted expression, the expected and actual values in an + * equality assertion, some addional messages... Detail strings can contains + * new line characters (\n). + */ +class CPPUNIT_API Message +{ +public: + Message(); + + // Ensure thread-safe copy by detaching the string. + Message( const Message &other ); + + explicit Message( const std::string &shortDescription ); + + Message( const std::string &shortDescription, + const std::string &detail1 ); + + Message( const std::string &shortDescription, + const std::string &detail1, + const std::string &detail2 ); + + Message( const std::string &shortDescription, + const std::string &detail1, + const std::string &detail2, + const std::string &detail3 ); + + Message &operator =( const Message &other ); + + /*! \brief Returns the short description. + * \return Short description. + */ + const std::string &shortDescription() const; + + /*! \brief Returns the number of detail string. + * \return Number of detail string. + */ + int detailCount() const; + + /*! \brief Returns the detail at the specified index. + * \param index Zero based index of the detail string to return. + * \returns Detail string at the specified index. + * \exception std::invalid_argument if \a index < 0 or index >= detailCount(). + */ + std::string detailAt( int index ) const; + + /*! \brief Returns a string that represents a list of the detail strings. + * + * Example: + * \code + * Message message( "not equal", "Expected: 3", "Actual: 7" ); + * std::string details = message.details(); + * // details contains: + * // "- Expected: 3\n- Actual: 7\n" \endcode + * + * \return A string that is a concatenation of all the detail strings. Each detail + * string is prefixed with '- ' and suffixed with '\n' before being + * concatenated to the other. + */ + std::string details() const; + + /*! \brief Removes all detail strings. + */ + void clearDetails(); + + /*! \brief Adds a single detail string. + * \param detail Detail string to add. + */ + void addDetail( const std::string &detail ); + + /*! \brief Adds two detail strings. + * \param detail1 Detail string to add. + * \param detail2 Detail string to add. + */ + void addDetail( const std::string &detail1, + const std::string &detail2 ); + + /*! \brief Adds three detail strings. + * \param detail1 Detail string to add. + * \param detail2 Detail string to add. + * \param detail3 Detail string to add. + */ + void addDetail( const std::string &detail1, + const std::string &detail2, + const std::string &detail3 ); + + /*! \brief Adds the detail strings of the specified message. + * \param message All the detail strings of this message are added to this one. + */ + void addDetail( const Message &message ); + + /*! \brief Sets the short description. + * \param shortDescription New short description. + */ + void setShortDescription( const std::string &shortDescription ); + + /*! \brief Tests if a message is identical to another one. + * \param other Message this message is compared to. + * \return \c true if the two message are identical, \c false otherwise. + */ + bool operator ==( const Message &other ) const; + + /*! \brief Tests if a message is different from another one. + * \param other Message this message is compared to. + * \return \c true if the two message are not identical, \c false otherwise. + */ + bool operator !=( const Message &other ) const; + +private: + std::string m_shortDescription; + + typedef CppUnitDeque Details; + Details m_details; +}; + + +CPPUNIT_NS_END + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( pop ) +#endif + + +#endif // CPPUNIT_MESSAGE_H diff --git a/UnitTests/cppunit/include/cppunit/Outputter.h b/UnitTests/cppunit/include/cppunit/Outputter.h new file mode 100644 index 000000000..f31d6815d --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/Outputter.h @@ -0,0 +1,26 @@ +#ifndef CPPUNIT_OUTPUTTER_H +#define CPPUNIT_OUTPUTTER_H + +#include + + +CPPUNIT_NS_BEGIN + + +/*! \brief Abstract outputter to print test result summary. + * \ingroup WritingTestResult + */ +class CPPUNIT_API Outputter +{ +public: + /// Destructor. + virtual ~Outputter() {} + + virtual void write() =0; +}; + + +CPPUNIT_NS_END + + +#endif // CPPUNIT_OUTPUTTER_H diff --git a/UnitTests/cppunit/include/cppunit/Portability.h b/UnitTests/cppunit/include/cppunit/Portability.h new file mode 100644 index 000000000..591eb8614 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/Portability.h @@ -0,0 +1,183 @@ +#ifndef CPPUNIT_PORTABILITY_H +#define CPPUNIT_PORTABILITY_H + +#if defined(_WIN32) && !defined(WIN32) +# define WIN32 1 +#endif + +/* include platform specific config */ +#if defined(__BORLANDC__) +# include +#elif defined (_MSC_VER) +# if _MSC_VER == 1200 && defined(_WIN32_WCE) //evc4 +# include +# else +# include +# endif +#else +# include +#endif + +// Version number of package +#ifndef CPPUNIT_VERSION +#define CPPUNIT_VERSION "1.12.0" +#endif + +#include // define CPPUNIT_API & CPPUNIT_NEED_DLL_DECL +#include + + +/* 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() */ +#if !defined(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. */ +#if !defined(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! */ +#if !defined(CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION) +# define CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION 1 +#endif + +/* Assumes that STL and CppUnit are in global space if the compiler does not + support namespace. */ +#if !defined(CPPUNIT_HAVE_NAMESPACES) +# if !defined(CPPUNIT_NO_NAMESPACE) +# define CPPUNIT_NO_NAMESPACE 1 +# endif // !defined(CPPUNIT_NO_NAMESPACE) +# if !defined(CPPUNIT_NO_STD_NAMESPACE) +# define CPPUNIT_NO_STD_NAMESPACE 1 +# endif // !defined(CPPUNIT_NO_STD_NAMESPACE) +#endif // !defined(CPPUNIT_HAVE_NAMESPACES) + +/* Define CPPUNIT_STD_NEED_ALLOCATOR to 1 if you need to specify + * the allocator you used when instantiating STL container. Typically + * used for compilers that do not support template default parameter. + * CPPUNIT_STD_ALLOCATOR will be used as the allocator. Default is + * std::allocator. On some compilers, you may need to change this to + * std::allocator. + */ +#if CPPUNIT_STD_NEED_ALLOCATOR +# if !defined(CPPUNIT_STD_ALLOCATOR) +# define CPPUNIT_STD_ALLOCATOR std::allocator +# endif // !defined(CPPUNIT_STD_ALLOCATOR) +#endif // defined(CPPUNIT_STD_NEED_ALLOCATOR) + + +// Compiler error location format for CompilerOutputter +// If not define, assumes that it's gcc +// See class CompilerOutputter for format. +#if !defined(CPPUNIT_COMPILER_LOCATION_FORMAT) +#if defined(__GNUC__) && ( defined(__APPLE_CPP__) || defined(__APPLE_CC__) ) +// gcc/Xcode integration on Mac OS X +# define CPPUNIT_COMPILER_LOCATION_FORMAT "%p:%l: " +#else +# define CPPUNIT_COMPILER_LOCATION_FORMAT "%f:%l:" +#endif +#endif + +// If CPPUNIT_HAVE_CPP_CAST is defined, then c++ style cast will be used, +// otherwise, C style cast are used. +#if defined( CPPUNIT_HAVE_CPP_CAST ) +# define CPPUNIT_CONST_CAST( TargetType, pointer ) \ + const_cast( pointer ) + +# define CPPUNIT_STATIC_CAST( TargetType, pointer ) \ + static_cast( pointer ) +#else // defined( CPPUNIT_HAVE_CPP_CAST ) +# define CPPUNIT_CONST_CAST( TargetType, pointer ) \ + ((TargetType)( pointer )) +# define CPPUNIT_STATIC_CAST( TargetType, pointer ) \ + ((TargetType)( pointer )) +#endif // defined( CPPUNIT_HAVE_CPP_CAST ) + +// If CPPUNIT_NO_STD_NAMESPACE is defined then STL are in the global space. +// => Define macro 'std' to nothing +#if defined(CPPUNIT_NO_STD_NAMESPACE) +# undef std +# define std +#endif // defined(CPPUNIT_NO_STD_NAMESPACE) + +// If CPPUNIT_NO_NAMESPACE is defined, then put CppUnit classes in the +// global namespace: the compiler does not support namespace. +#if defined(CPPUNIT_NO_NAMESPACE) +# define CPPUNIT_NS_BEGIN +# define CPPUNIT_NS_END +# define CPPUNIT_NS +#else // defined(CPPUNIT_NO_NAMESPACE) +# define CPPUNIT_NS_BEGIN namespace CppUnit { +# define CPPUNIT_NS_END } +# define CPPUNIT_NS CppUnit +#endif // defined(CPPUNIT_NO_NAMESPACE) + +/*! Stringize a symbol. + * + * Use this macro to convert a preprocessor symbol to a string. + * + * Example of usage: + * \code + * #define CPPUNIT_PLUGIN_EXPORTED_NAME cppunitTestPlugIn + * const char *name = CPPUNIT_STRINGIZE( CPPUNIT_PLUGIN_EXPORTED_NAME ); + * \endcode + */ +#define CPPUNIT_STRINGIZE( symbol ) _CPPUNIT_DO_STRINGIZE( symbol ) + +/// \internal +#define _CPPUNIT_DO_STRINGIZE( symbol ) #symbol + +/*! Joins to symbol after expanding them into string. + * + * Use this macro to join two symbols. Example of usage: + * + * \code + * #define MAKE_UNIQUE_NAME(prefix) CPPUNIT_JOIN( prefix, __LINE__ ) + * \endcode + * + * The macro defined in the example concatenate a given prefix with the line number + * to obtain a 'unique' identifier. + * + * \internal From boost documentation: + * The following piece of macro magic joins the two + * arguments together, even when one of the arguments is + * itself a macro (see 16.3.1 in C++ standard). The key + * is that macro expansion of macro arguments does not + * occur in CPPUNIT_JOIN2 but does in CPPUNIT_JOIN. + */ +#define CPPUNIT_JOIN( symbol1, symbol2 ) _CPPUNIT_DO_JOIN( symbol1, symbol2 ) + +/// \internal +#define _CPPUNIT_DO_JOIN( symbol1, symbol2 ) _CPPUNIT_DO_JOIN2( symbol1, symbol2 ) + +/// \internal +#define _CPPUNIT_DO_JOIN2( symbol1, symbol2 ) symbol1##symbol2 + +/// \internal Unique suffix for variable name. Can be overridden in platform specific +/// config-*.h. Default to line number. +#ifndef CPPUNIT_UNIQUE_COUNTER +# define CPPUNIT_UNIQUE_COUNTER __LINE__ +#endif + +/*! Adds the line number to the specified string to create a unique identifier. + * \param prefix Prefix added to the line number to create a unique identifier. + * \see CPPUNIT_TEST_SUITE_REGISTRATION for an example of usage. + */ +#define CPPUNIT_MAKE_UNIQUE_NAME( prefix ) CPPUNIT_JOIN( prefix, CPPUNIT_UNIQUE_COUNTER ) + +/*! Defines wrap colunm for %CppUnit. Used by CompilerOuputter. + */ +#if !defined(CPPUNIT_WRAP_COLUMN) +# define CPPUNIT_WRAP_COLUMN 79 +#endif + +#endif // CPPUNIT_PORTABILITY_H diff --git a/UnitTests/cppunit/include/cppunit/Protector.h b/UnitTests/cppunit/include/cppunit/Protector.h new file mode 100644 index 000000000..d14e75f64 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/Protector.h @@ -0,0 +1,94 @@ +#ifndef CPPUNIT_PROTECTOR_H +#define CPPUNIT_PROTECTOR_H + +#include + +CPPUNIT_NS_BEGIN + +class Exception; +class Message; +class ProtectorContext; +class TestResult; + + +class CPPUNIT_API Functor +{ +public: + virtual ~Functor(); + + virtual bool operator()() const =0; +}; + + +/*! \brief Protects one or more test case run. + * + * Protector are used to globably 'decorate' a test case. The most common + * usage of Protector is to catch exception that do not subclass std::exception, + * such as MFC CException class or Rogue Wave RWXMsg class, and capture the + * message associated to the exception. In fact, CppUnit capture message from + * Exception and std::exception using a Protector. + * + * Protector are chained. When you add a Protector using + * TestResult::pushProtector(), your protector is in fact passed as a Functor + * to the first protector of the chain. + * + * TestCase protects call to setUp(), runTest() and tearDown() by calling + * TestResult::protect(). + * + * Because the protector chain is handled by TestResult, a protector can be + * active for a single test, or a complete test run. + * + * Here are some possible usages: + * - run all test case in a separate thread and assumes the test failed if it + * did not finish in a given time (infinite loop work around) + * - performance tracing : time only the runTest() time. + * \sa TestResult, TestCase, TestListener. + */ +class CPPUNIT_API Protector +{ +public: + virtual ~Protector(); + + virtual bool protect( const Functor &functor, + const ProtectorContext &context ) =0; + +protected: + void reportError( const ProtectorContext &context, + const Exception &error ) const; + + void reportError( const ProtectorContext &context, + const Message &message, + const SourceLine &sourceLine = SourceLine() ) const; + + void reportFailure( const ProtectorContext &context, + const Exception &failure ) const; + + Message actualMessage( const Message &message, + const ProtectorContext &context ) const; +}; + + +/*! \brief Scoped protector push to TestResult. + * + * Adds the specified Protector to the specified TestResult for the object + * life-time. + */ +class CPPUNIT_API ProtectorGuard +{ +public: + /// Pushes the specified protector. + ProtectorGuard( TestResult *result, + Protector *protector ); + + /// Pops the protector. + ~ProtectorGuard(); + +private: + TestResult *m_result; +}; + +CPPUNIT_NS_END + + +#endif // CPPUNIT_PROTECTOR_H + diff --git a/UnitTests/cppunit/include/cppunit/SourceLine.h b/UnitTests/cppunit/include/cppunit/SourceLine.h new file mode 100644 index 000000000..f7a85df7f --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/SourceLine.h @@ -0,0 +1,63 @@ +#ifndef CPPUNIT_SOURCELINE_H +#define CPPUNIT_SOURCELINE_H + +#include +#include + +/*! \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_NS::SourceLine( __FILE__, __LINE__ ) + + +CPPUNIT_NS_BEGIN + + +/*! \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(); + + // Ensure thread-safe copy by detaching the string buffer. + SourceLine( const SourceLine &other ); + + SourceLine( const std::string &fileName, + int lineNumber ); + + SourceLine &operator =( const SourceLine &other ); + + /// 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; +}; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_SOURCELINE_H diff --git a/UnitTests/cppunit/include/cppunit/SynchronizedObject.h b/UnitTests/cppunit/include/cppunit/SynchronizedObject.h new file mode 100644 index 000000000..0f7d094aa --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/SynchronizedObject.h @@ -0,0 +1,80 @@ +#ifndef CPPUNIT_SYNCHRONIZEDOBJECT_H +#define CPPUNIT_SYNCHRONIZEDOBJECT_H + +#include + + +CPPUNIT_NS_BEGIN + + +/*! \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 + { + 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 © ); +}; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_SYNCHRONIZEDOBJECT_H diff --git a/UnitTests/cppunit/include/cppunit/Test.h b/UnitTests/cppunit/include/cppunit/Test.h new file mode 100644 index 000000000..a56be0fbe --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/Test.h @@ -0,0 +1,117 @@ +#ifndef CPPUNIT_TEST_H +#define CPPUNIT_TEST_H + +#include +#include + +CPPUNIT_NS_BEGIN + + +class TestResult; +class TestPath; + +/*! \brief Base class for all test objects. + * \ingroup BrowsingCollectedTestResult + * + * 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( TestResult *result ) =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 number of direct child of the test. + */ + virtual int getChildTestCount() const =0; + + /*! \brief Returns the child test of the specified index. + * + * This method test if the index is valid, then call doGetChildTestAt() if + * the index is valid. Otherwise std::out_of_range exception is thrown. + * + * You should override doGetChildTestAt() method. + * + * \param index Zero based index of the child test to return. + * \return Pointer on the test. Never \c NULL. + * \exception std::out_of_range is \a index is < 0 or >= getChildTestCount(). + */ + virtual Test *getChildTestAt( int index ) const; + + /*! \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 Finds the test with the specified name and its parents test. + * \param testName Name of the test to find. + * \param testPath If the test is found, then all the tests traversed to access + * \a test are added to \a testPath, including \c this and \a test. + * \return \c true if a test with the specified name is found, \c false otherwise. + */ + virtual bool findTestPath( const std::string &testName, + TestPath &testPath ) const; + + /*! \brief Finds the specified test and its parents test. + * \param test Test to find. + * \param testPath If the test is found, then all the tests traversed to access + * \a test are added to \a testPath, including \c this and \a test. + * \return \c true if the specified test is found, \c false otherwise. + */ + virtual bool findTestPath( const Test *test, + TestPath &testPath ) const; + + /*! \brief Finds the test with the specified name in the hierarchy. + * \param testName Name of the test to find. + * \return Pointer on the first test found that is named \a testName. Never \c NULL. + * \exception std::invalid_argument if no test named \a testName is found. + */ + virtual Test *findTest( const std::string &testName ) const; + + /*! \brief Resolved the specified test path with this test acting as 'root'. + * \param testPath Test path string to resolve. + * \return Resolved TestPath. + * \exception std::invalid_argument if \a testPath could not be resolved. + * \see TestPath. + */ + virtual TestPath resolveTestPath( const std::string &testPath ) const; + +protected: + /*! Throws an exception if the specified index is invalid. + * \param index Zero base index of a child test. + * \exception std::out_of_range is \a index is < 0 or >= getChildTestCount(). + */ + virtual void checkIsValidIndex( int index ) const; + + /*! \brief Returns the child test of the specified valid index. + * \param index Zero based valid index of the child test to return. + * \return Pointer on the test. Never \c NULL. + */ + virtual Test *doGetChildTestAt( int index ) const =0; +}; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_TEST_H + diff --git a/UnitTests/cppunit/include/cppunit/TestAssert.h b/UnitTests/cppunit/include/cppunit/TestAssert.h new file mode 100644 index 000000000..f74797b9d --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/TestAssert.h @@ -0,0 +1,428 @@ +#ifndef CPPUNIT_TESTASSERT_H +#define CPPUNIT_TESTASSERT_H + +#include +#include +#include +#include +#include +#include // For struct assertion_traits + + +CPPUNIT_NS_BEGIN + + +/*! \brief Traits used by CPPUNIT_ASSERT_EQUAL(). + * + * Here is an example of specialising these traits: + * + * \code + * template<> + * struct assertion_traits // 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 +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(); + } +}; + + +/*! \brief Traits used by CPPUNIT_ASSERT_DOUBLES_EQUAL(). + * + * This specialisation from @c struct @c assertion_traits<> ensures that + * doubles are converted in full, instead of being rounded to the default + * 6 digits of precision. Use the system defined ISO C99 macro DBL_DIG + * within float.h is available to define the maximum precision, otherwise + * use the hard-coded maximum precision of 15. + */ +template <> +struct assertion_traits +{ + static bool equal( double x, double y ) + { + return x == y; + } + + static std::string toString( double x ) + { +#ifdef DBL_DIG + const int precision = DBL_DIG; +#else + const int precision = 15; +#endif // #ifdef DBL_DIG + char buffer[128]; +#ifdef __STDC_SECURE_LIB__ // Use secure version with visual studio 2005 to avoid warning. + sprintf_s(buffer, sizeof(buffer), "%.*g", precision, x); +#else + sprintf(buffer, "%.*g", precision, x); +#endif + return buffer; + } +}; + + +/*! \brief (Implementation) Asserts that two objects of the same type are equals. + * Use CPPUNIT_ASSERT_EQUAL instead of this function. + * \sa assertion_traits, Asserter::failNotEqual(). + */ +template +void assertEquals( const T& expected, + const T& actual, + SourceLine sourceLine, + const std::string &message ) +{ + if ( !assertion_traits::equal(expected,actual) ) // lazy toString conversion... + { + Asserter::failNotEqual( assertion_traits::toString(expected), + assertion_traits::toString(actual), + sourceLine, + message ); + } +} + + +/*! \brief (Implementation) Asserts that two double are equals given a tolerance. + * Use CPPUNIT_ASSERT_DOUBLES_EQUAL instead of this function. + * \sa Asserter::failNotEqual(). + * \sa CPPUNIT_ASSERT_DOUBLES_EQUAL for detailed semantic of the assertion. + */ +void CPPUNIT_API assertDoubleEquals( double expected, + double actual, + double delta, + SourceLine sourceLine, + const std::string &message ); + + +/* 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 + */ +#define CPPUNIT_ASSERT(condition) \ + ( CPPUNIT_NS::Asserter::failIf( !(condition), \ + CPPUNIT_NS::Message( "assertion failed", \ + "Expression: " #condition), \ + CPPUNIT_SOURCELINE() ) ) +#else +#define CPPUNIT_ASSERT(condition) \ + ( CPPUNIT_NS::Asserter::failIf( !(condition), \ + CPPUNIT_NS::Message( "assertion failed" ), \ + 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) \ + ( CPPUNIT_NS::Asserter::failIf( !(condition), \ + CPPUNIT_NS::Message( "assertion failed", \ + "Expression: " \ + #condition, \ + message ), \ + CPPUNIT_SOURCELINE() ) ) + +/** Fails with the specified message. + * \ingroup Assertions + * \param message Message reported in diagnostic. + */ +#define CPPUNIT_FAIL( message ) \ + ( CPPUNIT_NS::Asserter::fail( CPPUNIT_NS::Message( "forced failure", \ + message ), \ + CPPUNIT_SOURCELINE() ) ) + +#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED +/// Generalized macro for primitive value comparisons +#define CPPUNIT_ASSERT_EQUAL(expected,actual) \ + ( CPPUNIT_NS::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_NS::assertEquals( (expected), \ + (actual), \ + CPPUNIT_SOURCELINE(), \ + "" ) ) + +/** Asserts that two values are equals, provides additional message 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_NS::assertEquals( (expected), \ + (actual), \ + CPPUNIT_SOURCELINE(), \ + (message) ) ) +#endif + +/*! \brief Macro for primitive double value comparisons. + * \ingroup Assertions + * + * The assertion pass if both expected and actual are finite and + * \c fabs( \c expected - \c actual ) <= \c delta. + * If either \c expected or actual are infinite (+/- inf), the + * assertion pass if \c expected == \c actual. + * If either \c expected or \c actual is a NaN (not a number), then + * the assertion fails. + */ +#define CPPUNIT_ASSERT_DOUBLES_EQUAL(expected,actual,delta) \ + ( CPPUNIT_NS::assertDoubleEquals( (expected), \ + (actual), \ + (delta), \ + CPPUNIT_SOURCELINE(), \ + "" ) ) + + +/*! \brief Macro for primitive double value comparisons, setting a + * user-supplied message in case of failure. + * \ingroup Assertions + * \sa CPPUNIT_ASSERT_DOUBLES_EQUAL for detailed semantic of the assertion. + */ +#define CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(message,expected,actual,delta) \ + ( CPPUNIT_NS::assertDoubleEquals( (expected), \ + (actual), \ + (delta), \ + CPPUNIT_SOURCELINE(), \ + (message) ) ) + + +/** Asserts that the given expression throws an exception of the specified type. + * \ingroup Assertions + * Example of usage: + * \code + * std::vector v; + * CPPUNIT_ASSERT_THROW( v.at( 50 ), std::out_of_range ); + * \endcode + */ +# define CPPUNIT_ASSERT_THROW( expression, ExceptionType ) \ + CPPUNIT_ASSERT_THROW_MESSAGE( CPPUNIT_NS::AdditionalMessage(), \ + expression, \ + ExceptionType ) + + +// implementation detail +#if CPPUNIT_USE_TYPEINFO_NAME +#define CPPUNIT_EXTRACT_EXCEPTION_TYPE_( exception, no_rtti_message ) \ + CPPUNIT_NS::TypeInfoHelper::getClassName( typeid(exception) ) +#else +#define CPPUNIT_EXTRACT_EXCEPTION_TYPE_( exception, no_rtti_message ) \ + std::string( no_rtti_message ) +#endif // CPPUNIT_USE_TYPEINFO_NAME + +// implementation detail +#define CPPUNIT_GET_PARAMETER_STRING( parameter ) #parameter + +/** Asserts that the given expression throws an exception of the specified type, + * setting a user supplied message in case of failure. + * \ingroup Assertions + * Example of usage: + * \code + * std::vector v; + * CPPUNIT_ASSERT_THROW_MESSAGE( "- std::vector v;", v.at( 50 ), std::out_of_range ); + * \endcode + */ +# define CPPUNIT_ASSERT_THROW_MESSAGE( message, expression, ExceptionType ) \ + do { \ + bool cpputCorrectExceptionThrown_ = false; \ + CPPUNIT_NS::Message cpputMsg_( "expected exception not thrown" ); \ + cpputMsg_.addDetail( message ); \ + cpputMsg_.addDetail( "Expected: " \ + CPPUNIT_GET_PARAMETER_STRING( ExceptionType ) ); \ + \ + try { \ + expression; \ + } catch ( const ExceptionType & ) { \ + cpputCorrectExceptionThrown_ = true; \ + } catch ( const std::exception &e) { \ + cpputMsg_.addDetail( "Actual : " + \ + CPPUNIT_EXTRACT_EXCEPTION_TYPE_( e, \ + "std::exception or derived") ); \ + cpputMsg_.addDetail( std::string("What() : ") + e.what() ); \ + } catch ( ... ) { \ + cpputMsg_.addDetail( "Actual : unknown."); \ + } \ + \ + if ( cpputCorrectExceptionThrown_ ) \ + break; \ + \ + CPPUNIT_NS::Asserter::fail( cpputMsg_, \ + CPPUNIT_SOURCELINE() ); \ + } while ( false ) + + +/** Asserts that the given expression does not throw any exceptions. + * \ingroup Assertions + * Example of usage: + * \code + * std::vector v; + * v.push_back( 10 ); + * CPPUNIT_ASSERT_NO_THROW( v.at( 0 ) ); + * \endcode + */ +# define CPPUNIT_ASSERT_NO_THROW( expression ) \ + CPPUNIT_ASSERT_NO_THROW_MESSAGE( CPPUNIT_NS::AdditionalMessage(), \ + expression ) + + +/** Asserts that the given expression does not throw any exceptions, + * setting a user supplied message in case of failure. + * \ingroup Assertions + * Example of usage: + * \code + * std::vector v; + * v.push_back( 10 ); + * CPPUNIT_ASSERT_NO_THROW( "std::vector v;", v.at( 0 ) ); + * \endcode + */ +# define CPPUNIT_ASSERT_NO_THROW_MESSAGE( message, expression ) \ + do { \ + CPPUNIT_NS::Message cpputMsg_( "unexpected exception caught" ); \ + cpputMsg_.addDetail( message ); \ + \ + try { \ + expression; \ + } catch ( const std::exception &e ) { \ + cpputMsg_.addDetail( "Caught: " + \ + CPPUNIT_EXTRACT_EXCEPTION_TYPE_( e, \ + "std::exception or derived" ) ); \ + cpputMsg_.addDetail( std::string("What(): ") + e.what() ); \ + CPPUNIT_NS::Asserter::fail( cpputMsg_, \ + CPPUNIT_SOURCELINE() ); \ + } catch ( ... ) { \ + cpputMsg_.addDetail( "Caught: unknown." ); \ + CPPUNIT_NS::Asserter::fail( cpputMsg_, \ + CPPUNIT_SOURCELINE() ); \ + } \ + } while ( false ) + + +/** Asserts that an assertion fail. + * \ingroup Assertions + * Use to test assertions. + * Example of usage: + * \code + * CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT( 1 == 2 ) ); + * \endcode + */ +# define CPPUNIT_ASSERT_ASSERTION_FAIL( assertion ) \ + CPPUNIT_ASSERT_THROW( assertion, CPPUNIT_NS::Exception ) + + +/** Asserts that an assertion fail, with a user-supplied message in + * case of error. + * \ingroup Assertions + * Use to test assertions. + * Example of usage: + * \code + * CPPUNIT_ASSERT_ASSERTION_FAIL_MESSAGE( "1 == 2", CPPUNIT_ASSERT( 1 == 2 ) ); + * \endcode + */ +# define CPPUNIT_ASSERT_ASSERTION_FAIL_MESSAGE( message, assertion ) \ + CPPUNIT_ASSERT_THROW_MESSAGE( message, assertion, CPPUNIT_NS::Exception ) + + +/** Asserts that an assertion pass. + * \ingroup Assertions + * Use to test assertions. + * Example of usage: + * \code + * CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT( 1 == 1 ) ); + * \endcode + */ +# define CPPUNIT_ASSERT_ASSERTION_PASS( assertion ) \ + CPPUNIT_ASSERT_NO_THROW( assertion ) + + +/** Asserts that an assertion pass, with a user-supplied message in + * case of failure. + * \ingroup Assertions + * Use to test assertions. + * Example of usage: + * \code + * CPPUNIT_ASSERT_ASSERTION_PASS_MESSAGE( "1 != 1", CPPUNIT_ASSERT( 1 == 1 ) ); + * \endcode + */ +# define CPPUNIT_ASSERT_ASSERTION_PASS_MESSAGE( message, assertion ) \ + CPPUNIT_ASSERT_NO_THROW_MESSAGE( message, assertion ) + + + + +// 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 + + +CPPUNIT_NS_END + +#endif // CPPUNIT_TESTASSERT_H diff --git a/UnitTests/cppunit/include/cppunit/TestCaller.h b/UnitTests/cppunit/include/cppunit/TestCaller.h new file mode 100644 index 000000000..dc4d82ed9 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/TestCaller.h @@ -0,0 +1,204 @@ +#ifndef CPPUNIT_TESTCALLER_H // -*- C++ -*- +#define CPPUNIT_TESTCALLER_H + +#include +#include + + +#if CPPUNIT_USE_TYPEINFO_NAME +# include +#endif + + +CPPUNIT_NS_BEGIN + +#if 0 +/*! \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 +struct ExpectedExceptionTraits +{ + static void expectedException() + { +#if CPPUNIT_USE_TYPEINFO_NAME + throw Exception( Message( + "expected exception not thrown", + "Expected exception type: " + + TypeInfoHelper::getClassName( typeid( ExceptionType ) ) ) ); +#else + throw Exception( "expected exception not thrown" ); +#endif + } +}; + + +/*! \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 +{ + static void expectedException() + { + } +}; + + +#endif + +//*** 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( "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 +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 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 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 name, TestMethod test, Fixture* fixture) : + TestCase( name ), + m_ownFixture( true ), + m_fixture( fixture ), + m_test( test ) + { + } + + ~TestCaller() + { + if (m_ownFixture) + delete m_fixture; + } + + void runTest() + { +// try { + (m_fixture->*m_test)(); +// } +// catch ( ExpectedException & ) { +// return; +// } + +// ExpectedExceptionTraits::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; +}; + + + +CPPUNIT_NS_END + +#endif // CPPUNIT_TESTCALLER_H diff --git a/UnitTests/cppunit/include/cppunit/TestCase.h b/UnitTests/cppunit/include/cppunit/TestCase.h new file mode 100644 index 000000000..d4b7a46a8 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/TestCase.h @@ -0,0 +1,55 @@ +#ifndef CPPUNIT_TESTCASE_H +#define CPPUNIT_TESTCASE_H + +#include +#include +#include +#include +#include + + +CPPUNIT_NS_BEGIN + + +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 TestLeaf, + public TestFixture +{ +public: + + TestCase( const std::string &name ); + + TestCase(); + + ~TestCase(); + + virtual void run(TestResult *result); + + std::string getName() const; + + //! FIXME: this should probably be pure virtual. + virtual void runTest(); + +private: + TestCase( const TestCase &other ); + TestCase &operator=( const TestCase &other ); + +private: + const std::string m_name; +}; + +CPPUNIT_NS_END + +#endif // CPPUNIT_TESTCASE_H diff --git a/UnitTests/cppunit/include/cppunit/TestComposite.h b/UnitTests/cppunit/include/cppunit/TestComposite.h new file mode 100644 index 000000000..0ded95fcd --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/TestComposite.h @@ -0,0 +1,45 @@ +#ifndef CPPUNIT_TESTCOMPSITE_H // -*- C++ -*- +#define CPPUNIT_TESTCOMPSITE_H + +#include +#include + +CPPUNIT_NS_BEGIN + + +/*! \brief A Composite of Tests. + * + * Base class for all test composites. Subclass this class if you need to implement + * a custom TestSuite. + * + * \see Test, TestSuite. + */ +class CPPUNIT_API TestComposite : public Test +{ +public: + TestComposite( const std::string &name = "" ); + + ~TestComposite(); + + void run( TestResult *result ); + + int countTestCases() const; + + std::string getName() const; + +private: + TestComposite( const TestComposite &other ); + TestComposite &operator =( const TestComposite &other ); + + virtual void doStartSuite( TestResult *controller ); + virtual void doRunChildTests( TestResult *controller ); + virtual void doEndSuite( TestResult *controller ); + +private: + const std::string m_name; +}; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_TESTCOMPSITE_H diff --git a/UnitTests/cppunit/include/cppunit/TestFailure.h b/UnitTests/cppunit/include/cppunit/TestFailure.h new file mode 100644 index 000000000..64199790d --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/TestFailure.h @@ -0,0 +1,58 @@ +#ifndef CPPUNIT_TESTFAILURE_H // -*- C++ -*- +#define CPPUNIT_TESTFAILURE_H + +#include +#include + +CPPUNIT_NS_BEGIN + + +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, + bool isError ); + + virtual ~TestFailure (); + + virtual Test *failedTest() const; + + virtual Exception *thrownException() const; + + virtual SourceLine sourceLine() const; + + virtual bool isError() const; + + virtual std::string failedTestName() const; + + virtual TestFailure *clone() const; + +protected: + Test *m_failedTest; + Exception *m_thrownException; + bool m_isError; + +private: + TestFailure( const TestFailure &other ); + TestFailure &operator =( const TestFailure& other ); +}; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_TESTFAILURE_H diff --git a/UnitTests/cppunit/include/cppunit/TestFixture.h b/UnitTests/cppunit/include/cppunit/TestFixture.h new file mode 100644 index 000000000..1223adbc9 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/TestFixture.h @@ -0,0 +1,99 @@ +#ifndef CPPUNIT_TESTFIXTURE_H // -*- C++ -*- +#define CPPUNIT_TESTFIXTURE_H + +#include + +CPPUNIT_NS_BEGIN + + +/*! \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( "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( + * "testAdd", &MathTest::testAdd)); + * suiteOfTests->addTest(new CppUnit::TestCaller( + * "testDivideByZero", &MathTest::testDivideByZero)); + * return suiteOfTests; + * } + * \endcode + * + * A set of macros have been created for convenience. They are located in HelperMacros.h. + * + * \see TestResult, TestSuite, TestCaller, + * \see CPPUNIT_TEST_SUB_SUITE, CPPUNIT_TEST, CPPUNIT_TEST_SUITE_END, + * \see CPPUNIT_TEST_SUITE_REGISTRATION, CPPUNIT_TEST_EXCEPTION, CPPUNIT_TEST_FAIL. + */ +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() {}; +}; + + +CPPUNIT_NS_END + + +#endif diff --git a/UnitTests/cppunit/include/cppunit/TestLeaf.h b/UnitTests/cppunit/include/cppunit/TestLeaf.h new file mode 100644 index 000000000..c83b07597 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/TestLeaf.h @@ -0,0 +1,44 @@ +#ifndef CPPUNIT_TESTLEAF_H +#define CPPUNIT_TESTLEAF_H + +#include + + +CPPUNIT_NS_BEGIN + + +/*! \brief A single test object. + * + * Base class for single test case: a test that doesn't have any children. + * + */ +class CPPUNIT_API TestLeaf: public Test +{ +public: + /*! Returns 1 as the default number of test cases invoked by run(). + * + * You may override this method when many test cases are invoked (RepeatedTest + * for example). + * + * \return 1. + * \see Test::countTestCases(). + */ + int countTestCases() const; + + /*! Returns the number of child of this test case: 0. + * + * You should never override this method: a TestLeaf as no children by definition. + * + * \return 0. + */ + int getChildTestCount() const; + + /*! Always throws std::out_of_range. + * \see Test::doGetChildTestAt(). + */ + Test *doGetChildTestAt( int index ) const; +}; + +CPPUNIT_NS_END + +#endif // CPPUNIT_TESTLEAF_H diff --git a/UnitTests/cppunit/include/cppunit/TestListener.h b/UnitTests/cppunit/include/cppunit/TestListener.h new file mode 100644 index 000000000..330262d33 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/TestListener.h @@ -0,0 +1,148 @@ +#ifndef CPPUNIT_TESTLISTENER_H // -*- C++ -*- +#define CPPUNIT_TESTLISTENER_H + +#include + + +CPPUNIT_NS_BEGIN + + +class Exception; +class Test; +class TestFailure; +class TestResult; + + +/*! \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. + * + * Here is an example to track test time: + * + * + * \code + * #include + * #include + * #include // for clock() + * + * class TimingListener : public CppUnit::TestListener + * { + * public: + * void startTest( CppUnit::Test *test ) + * { + * _chronometer.start(); + * } + * + * void endTest( CppUnit::Test *test ) + * { + * _chronometer.end(); + * addTest( test, _chronometer.elapsedTime() ); + * } + * + * // ... (interface to add/read test timing result) + * + * private: + * Clock _chronometer; + * }; + * \endcode + * + * And another example that track failure/success at test suite level and captures + * the TestPath of each suite: + * \code + * class SuiteTracker : public CppUnit::TestListener + * { + * public: + * void startSuite( CppUnit::Test *suite ) + * { + * m_currentPath.add( suite ); + * } + * + * void addFailure( const TestFailure &failure ) + * { + * m_suiteFailure.top() = false; + * } + * + * void endSuite( CppUnit::Test *suite ) + * { + * m_suiteStatus.insert( std::make_pair( suite, m_suiteFailure.top() ) ); + * m_suitePaths.insert( std::make_pair( suite, m_currentPath ) ); + * + * m_currentPath.up(); + * m_suiteFailure.pop(); + * } + * + * private: + * std::stack m_suiteFailure; + * CppUnit::TestPath m_currentPath; + * std::map m_suiteStatus; + * std::map m_suitePaths; + * }; + * \endcode + * + * \see TestResult + */ +class CPPUNIT_API TestListener +{ +public: + virtual ~TestListener() {} + + /// Called when just before a TestCase is run. + virtual void startTest( Test * /*test*/ ) {} + + /*! \brief 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*/ ) {} + + /// Called just after a TestCase was run (even if a failure occured). + virtual void endTest( Test * /*test*/ ) {} + + /*! \brief Called by a TestComposite just before running its child tests. + */ + virtual void startSuite( Test * /*suite*/ ) {} + + /*! \brief Called by a TestComposite after running its child tests. + */ + virtual void endSuite( Test * /*suite*/ ) {} + + /*! \brief Called by a TestRunner before running the test. + * + * You can use this to do some global initialisation. A listener + * could also use to output a 'prolog' to the test run. + * + * \param test Test that is going to be run. + * \param eventManager Event manager used for the test run. + */ + virtual void startTestRun( Test * /*test*/, + TestResult * /*eventManager*/ ) {} + + /*! \brief Called by a TestRunner after running the test. + * + * TextTestProgressListener use this to emit a line break. You can also use this + * to do some global uninitialisation. + * + * \param test Test that was run. + * \param eventManager Event manager used for the test run. + */ + virtual void endTestRun( Test * /*test*/, + TestResult * /*eventManager*/ ) {} +}; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_TESTLISTENER_H + + diff --git a/UnitTests/cppunit/include/cppunit/TestPath.h b/UnitTests/cppunit/include/cppunit/TestPath.h new file mode 100644 index 000000000..c3c851cc5 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/TestPath.h @@ -0,0 +1,211 @@ +#ifndef CPPUNIT_TESTPATH_H +#define CPPUNIT_TESTPATH_H + +#include + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( push ) +#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z +#endif + +#include +#include + +CPPUNIT_NS_BEGIN + + +class Test; + +#if CPPUNIT_NEED_DLL_DECL +// template class CPPUNIT_API std::deque; +#endif + + +/*! \brief A List of Test representing a path to access a Test. + * \ingroup ExecutingTest + * + * The path can be converted to a string and resolved from a string with toString() + * and TestPath( Test *root, const std::string &pathAsString ). + * + * Pointed tests are not owned by the class. + * + * \see Test::resolvedTestPath() + */ +class CPPUNIT_API TestPath +{ +public: + /*! \brief Constructs an invalid path. + * + * The path is invalid until a test is added with add(). + */ + TestPath(); + + /*! \brief Constructs a valid path. + * + * \param root Test to add. + */ + TestPath( Test *root ); + + /*! \brief Constructs a path using a slice of another path. + * \param otherPath Path the test are copied from. + * \param indexFirst Zero based index of the first test to copy. Adjusted to be in valid + * range. \a count is adjusted with \a indexFirst. + * \param count Number of tests to copy. If < 0 then all test starting from index + * \a indexFirst are copied. + */ + TestPath( const TestPath &otherPath, + int indexFirst, + int count = -1 ); + + /*! \brief Resolves a path from a string returned by toString(). + * + * If \a pathAsString is an absolute path (begins with '/'), then the first test name + * of the path must be the name of \a searchRoot. Otherwise, \a pathAsString is a + * relative path, and the first test found using Test::findTest() matching the first + * test name is used as root. An empty string resolve to a path containing + * \a searchRoot. + * + * The resolved path is always valid. + * + * \param searchRoot Test used to resolve the path. + * \param pathAsString String that contains the path as a string created by toString(). + * \exception std::invalid_argument if one of the test names can not be resolved. + * \see toString(). + */ + TestPath( Test *searchRoot, + const std::string &pathAsString ); + + /*! \brief Copy constructor. + * \param other Object to copy. + */ + TestPath( const TestPath &other ); + + virtual ~TestPath(); + + /*! \brief Tests if the path contains at least one test. + * \return \c true if the path contains at least one test, otherwise returns \c false. + */ + virtual bool isValid() const; + + /*! \brief Adds a test to the path. + * \param test Pointer on the test to add. Must not be \c NULL. + */ + virtual void add( Test *test ); + + /*! \brief Adds all the tests of the specified path. + * \param path Path that contains the test to add. + */ + virtual void add( const TestPath &path ); + + /*! \brief Inserts a test at the specified index. + * \param test Pointer on the test to insert. Must not be \c NULL. + * \param index Zero based index indicating where the test is inserted. + * \exception std::out_of_range is \a index < 0 or \a index > getTestCount(). + */ + virtual void insert( Test *test, int index ); + + /*! \brief Inserts all the tests at the specified path at a given index. + * \param path Path that contains the test to insert. + * \param index Zero based index indicating where the tests are inserted. + * \exception std::out_of_range is \a index < 0 or \a index > getTestCount(), and + * \a path is valid. + */ + virtual void insert( const TestPath &path, int index ); + + /*! \brief Removes all the test from the path. + * + * The path becomes invalid after this call. + */ + virtual void removeTests(); + + /*! \brief Removes the test at the specified index of the path. + * \param index Zero based index of the test to remove. + * \exception std::out_of_range is \a index < 0 or \a index >= getTestCount(). + */ + virtual void removeTest( int index ); + + /*! \brief Removes the last test. + * \exception std::out_of_range is the path is invalid. + * \see isValid(). + */ + virtual void up(); + + /*! \brief Returns the number of tests in the path. + * \return Number of tests in the path. + */ + virtual int getTestCount() const; + + /*! \brief Returns the test of the specified index. + * \param index Zero based index of the test to return. + * \return Pointer on the test at index \a index. Never \c NULL. + * \exception std::out_of_range is \a index < 0 or \a index >= getTestCount(). + */ + virtual Test *getTestAt( int index ) const; + + /*! \brief Get the last test of the path. + * \return Pointer on the last test (test at the bottom of the hierarchy). Never \c NULL. + * \exception std::out_of_range if the path is not valid ( isValid() returns \c false ). + */ + virtual Test *getChildTest() const; + + /*! \brief Returns the path as a string. + * + * For example, if a path is composed of three tests named "All Tests", "Math" and + * "Math::testAdd", toString() will return: + * + * "All Tests/Math/Math::testAdd". + * + * \return A string composed of the test names separated with a '/'. It is a relative + * path. + */ + virtual std::string toString() const; + + /*! \brief Assignment operator. + * \param other Object to copy. + * \return This object. + */ + TestPath &operator =( const TestPath &other ); + +protected: + /*! \brief Checks that the specified test index is within valid range. + * \param index Zero based index to check. + * \exception std::out_of_range is \a index < 0 or \a index >= getTestCount(). + */ + void checkIndexValid( int index ) const; + + /// A list of test names. + typedef CppUnitDeque PathTestNames; + + /*! \brief Splits a path string into its test name components. + * \param pathAsString Path string created with toString(). + * \param testNames Test name components are added to that container. + * \return \c true if the path is relative (does not begin with '/'), \c false + * if it is absolute (begin with '/'). + */ + bool splitPathString( const std::string &pathAsString, + PathTestNames &testNames ); + + /*! \brief Finds the actual root of a path string and get the path string name components. + * \param searchRoot Test used as root if the path string is absolute, or to search + * the root test if the path string is relative. + * \param pathAsString Path string. May be absolute or relative. + * \param testNames Test name components are added to that container. + * \return Pointer on the resolved root test. Never \c NULL. + * \exception std::invalid_argument if either the root name can not be resolved or if + * pathAsString contains no name components. + */ + Test *findActualRoot( Test *searchRoot, + const std::string &pathAsString, + PathTestNames &testNames ); + +protected: + typedef CppUnitDeque Tests; + Tests m_tests; + +}; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_TESTPATH_H + diff --git a/UnitTests/cppunit/include/cppunit/TestResult.h b/UnitTests/cppunit/include/cppunit/TestResult.h new file mode 100644 index 000000000..e7e1050a0 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/TestResult.h @@ -0,0 +1,156 @@ +#ifndef CPPUNIT_TESTRESULT_H +#define CPPUNIT_TESTRESULT_H + +#include + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( push ) +#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z +#endif + +#include +#include +#include + +CPPUNIT_NS_BEGIN + + +class Exception; +class Functor; +class Protector; +class ProtectorChain; +class Test; +class TestFailure; +class TestListener; + + +#if CPPUNIT_NEED_DLL_DECL +// template class CPPUNIT_API std::deque; +#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 +{ +public: + /// Construct a TestResult + TestResult( SynchronizationObject *syncObject = 0 ); + + /// Destroys a test result + virtual ~TestResult(); + + virtual void addListener( TestListener *listener ); + + virtual void removeListener( TestListener *listener ); + + /// Resets the stop flag. + virtual void reset(); + + /// Stop testing + virtual void stop(); + + /// Returns whether testing should be stopped + virtual bool shouldStop() const; + + /// Informs TestListener that a test will be started. + virtual void startTest( Test *test ); + + /*! \brief Adds an error to the list of errors. + * The passed in exception + * caused the error + */ + virtual void addError( Test *test, Exception *e ); + + /*! \brief Adds a failure to the list of failures. The passed in exception + * caused the failure. + */ + virtual void addFailure( Test *test, Exception *e ); + + /// Informs TestListener that a test was completed. + virtual void endTest( Test *test ); + + /// Informs TestListener that a test suite will be started. + virtual void startSuite( Test *test ); + + /// Informs TestListener that a test suite was completed. + virtual void endSuite( Test *test ); + + /*! \brief Run the specified test. + * + * Calls startTestRun(), test->run(this), and finally endTestRun(). + */ + virtual void runTest( Test *test ); + + /*! \brief Protects a call to the specified functor. + * + * See Protector to understand how protector works. A default protector is + * always present. It captures CppUnit::Exception, std::exception and + * any other exceptions, retrieving as much as possible information about + * the exception as possible. + * + * Additional Protector can be added to the chain to support other exception + * types using pushProtector() and popProtector(). + * + * \param functor Functor to call (typically a call to setUp(), runTest() or + * tearDown(). + * \param test Test the functor is associated to (used for failure reporting). + * \param shortDescription Short description override for the failure message. + */ + virtual bool protect( const Functor &functor, + Test *test, + const std::string &shortDescription = std::string("") ); + + /// Adds the specified protector to the protector chain. + virtual void pushProtector( Protector *protector ); + + /// Removes the last protector from the protector chain. + virtual void popProtector(); + +protected: + /*! \brief Called to add a failure to the list of failures. + */ + void addFailure( const TestFailure &failure ); + + virtual void startTestRun( Test *test ); + virtual void endTestRun( Test *test ); + +protected: + typedef CppUnitDeque TestListeners; + TestListeners m_listeners; + ProtectorChain *m_protectorChain; + bool m_stop; + +private: + TestResult( const TestResult &other ); + TestResult &operator =( const TestResult &other ); +}; + + +CPPUNIT_NS_END + + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( pop ) +#endif + +#endif // CPPUNIT_TESTRESULT_H + + diff --git a/UnitTests/cppunit/include/cppunit/TestResultCollector.h b/UnitTests/cppunit/include/cppunit/TestResultCollector.h new file mode 100644 index 000000000..01b0a547a --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/TestResultCollector.h @@ -0,0 +1,87 @@ +#ifndef CPPUNIT_TESTRESULTCOLLECTOR_H +#define CPPUNIT_TESTRESULTCOLLECTOR_H + +#include + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( push ) +#pragma warning( disable: 4251 4660 ) // X needs to have dll-interface to be used by clients of class Z +#endif + +#include +#include + + +CPPUNIT_NS_BEGIN + +#if CPPUNIT_NEED_DLL_DECL +// template class CPPUNIT_API std::deque; +// template class CPPUNIT_API std::deque; +#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 CPPUNIT_API TestResultCollector : public TestSuccessListener +{ +public: + typedef CppUnitDeque TestFailures; + typedef CppUnitDeque Tests; + + + /*! Constructs a TestResultCollector object. + */ + TestResultCollector( SynchronizationObject *syncObject = 0 ); + + /// Destructor. + virtual ~TestResultCollector(); + + void startTest( 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; + +protected: + void freeFailures(); + + Tests m_tests; + TestFailures m_failures; + int m_testErrors; + +private: + /// Prevents the use of the copy constructor. + TestResultCollector( const TestResultCollector © ); + + /// Prevents the use of the copy operator. + void operator =( const TestResultCollector © ); +}; + + + +CPPUNIT_NS_END + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( pop ) +#endif + + +#endif // CPPUNIT_TESTRESULTCOLLECTOR_H diff --git a/UnitTests/cppunit/include/cppunit/TestRunner.h b/UnitTests/cppunit/include/cppunit/TestRunner.h new file mode 100644 index 000000000..930370ad9 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/TestRunner.h @@ -0,0 +1,135 @@ +#ifndef CPPUNIT_TESTRUNNER_H +#define CPPUNIT_TESTRUNNER_H + +#include +#include + +CPPUNIT_NS_BEGIN + + +class Test; +class TestResult; + + +/*! \brief Generic test runner. + * \ingroup ExecutingTest + * + * The TestRunner assumes ownership of all added tests: you can not add test + * or suite that are local variable since they can't be deleted. + * + * Example of usage: + * \code + * #include + * #include + * #include + * #include + * #include + * #include + * + * + * int + * main( int argc, char* argv[] ) + * { + * std::string testPath = (argc > 1) ? std::string(argv[1]) : ""; + * + * // Create the event manager and test controller + * CppUnit::TestResult controller; + * + * // Add a listener that colllects test result + * CppUnit::TestResultCollector result; + * controller.addListener( &result ); + * + * // Add a listener that print dots as test run. + * CppUnit::TextTestProgressListener progress; + * controller.addListener( &progress ); + * + * // Add the top suite to the test runner + * CppUnit::TestRunner runner; + * runner.addTest( CppUnit::TestFactoryRegistry::getRegistry().makeTest() ); + * try + * { + * std::cout << "Running " << testPath; + * runner.run( controller, testPath ); + * + * std::cerr << std::endl; + * + * // Print test in a compiler compatible format. + * CppUnit::CompilerOutputter outputter( &result, std::cerr ); + * outputter.write(); + * } + * catch ( std::invalid_argument &e ) // Test path not resolved + * { + * std::cerr << std::endl + * << "ERROR: " << e.what() + * << std::endl; + * return 0; + * } + * + * return result.wasSuccessful() ? 0 : 1; + * } + * \endcode + */ +class CPPUNIT_API TestRunner +{ +public: + /*! \brief Constructs a TestRunner object. + */ + TestRunner( ); + + /// Destructor. + virtual ~TestRunner(); + + /*! \brief Adds the specified test. + * \param test Test to add. The TestRunner takes ownership of the test. + */ + virtual void addTest( Test *test ); + + /*! \brief Runs a test using the specified controller. + * \param controller Event manager and controller used for testing + * \param testPath Test path string. See Test::resolveTestPath() for detail. + * \exception std::invalid_argument if no test matching \a testPath is found. + * see TestPath::TestPath( Test*, const std::string &) + * for detail. + */ + virtual void run( TestResult &controller, + const std::string &testPath = "" ); + +protected: + /*! \brief (INTERNAL) Mutating test suite. + */ + class CPPUNIT_API WrappingSuite : public TestSuite + { + public: + WrappingSuite( const std::string &name = "All Tests" ); + + int getChildTestCount() const; + + std::string getName() const; + + void run( TestResult *result ); + + protected: + Test *doGetChildTestAt( int index ) const; + + bool hasOnlyOneTest() const; + + Test *getUniqueChildTest() const; + }; + +protected: + WrappingSuite *m_suite; + +private: + /// Prevents the use of the copy constructor. + TestRunner( const TestRunner © ); + + /// Prevents the use of the copy operator. + void operator =( const TestRunner © ); + +private: +}; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_TESTRUNNER_H diff --git a/UnitTests/cppunit/include/cppunit/TestSuccessListener.h b/UnitTests/cppunit/include/cppunit/TestSuccessListener.h new file mode 100644 index 000000000..60c5ff500 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/TestSuccessListener.h @@ -0,0 +1,39 @@ +#ifndef CPPUNIT_TESTSUCCESSLISTENER_H +#define CPPUNIT_TESTSUCCESSLISTENER_H + +#include +#include + + +CPPUNIT_NS_BEGIN + + +/*! \brief TestListener that checks if any test case failed. + * \ingroup TrackingTestExecution + */ +class CPPUNIT_API TestSuccessListener : public TestListener, + public SynchronizedObject +{ +public: + /*! Constructs a TestSuccessListener object. + */ + TestSuccessListener( SynchronizationObject *syncObject = 0 ); + + /// Destructor. + virtual ~TestSuccessListener(); + + virtual void reset(); + + void addFailure( const TestFailure &failure ); + + /// Returns whether the entire test was successful or not. + virtual bool wasSuccessful() const; + +private: + bool m_success; +}; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_TESTSUCCESSLISTENER_H diff --git a/UnitTests/cppunit/include/cppunit/TestSuite.h b/UnitTests/cppunit/include/cppunit/TestSuite.h new file mode 100644 index 000000000..2b9cd8d49 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/TestSuite.h @@ -0,0 +1,80 @@ +#ifndef CPPUNIT_TESTSUITE_H // -*- C++ -*- +#define CPPUNIT_TESTSUITE_H + +#include + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( push ) +#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z +#endif + +#include +#include + +CPPUNIT_NS_BEGIN + + +#if CPPUNIT_NEED_DLL_DECL +// template class CPPUNIT_API std::vector; +#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 ( + * "testAdd", testAdd)); + * suite->addTest(new CppUnit::TestCaller ( + * "testDivideByZero", testDivideByZero)); + * \endcode + * Note that \link TestSuite TestSuites \endlink assume lifetime + * control for any tests added to them. + * + * TestSuites do not register themselves in the TestRegistry. + * \see Test + * \see TestCaller + */ +class CPPUNIT_API TestSuite : public TestComposite +{ +public: + /*! Constructs a test suite with the specified name. + */ + TestSuite( std::string name = "" ); + + ~TestSuite(); + + /*! Adds the specified test to the suite. + * \param test Test to add. Must not be \c NULL. + */ + void addTest( Test *test ); + + /*! Returns the list of the tests (DEPRECATED). + * \deprecated Use getChildTestCount() & getChildTestAt() of the + * TestComposite interface instead. + * \return Reference on a vector that contains the tests of the suite. + */ + const CppUnitVector &getTests() const; + + /*! Destroys all the tests of the suite. + */ + virtual void deleteContents(); + + int getChildTestCount() const; + + Test *doGetChildTestAt( int index ) const; + +private: + CppUnitVector m_tests; +}; + + +CPPUNIT_NS_END + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( pop ) +#endif + +#endif // CPPUNIT_TESTSUITE_H diff --git a/UnitTests/cppunit/include/cppunit/TextOutputter.h b/UnitTests/cppunit/include/cppunit/TextOutputter.h new file mode 100644 index 000000000..6bd9ceaae --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/TextOutputter.h @@ -0,0 +1,59 @@ +#ifndef CPPUNIT_TEXTOUTPUTTER_H +#define CPPUNIT_TEXTOUTPUTTER_H + +#include +#include +#include + +CPPUNIT_NS_BEGIN + + +class Exception; +class SourceLine; +class TestResultCollector; +class TestFailure; + + +/*! \brief Prints a TestResultCollector to a text stream. + * \ingroup WritingTestResult + */ +class CPPUNIT_API TextOutputter : public Outputter +{ +public: + TextOutputter( TestResultCollector *result, + OStream &stream ); + + /// Destructor. + virtual ~TextOutputter(); + + void write(); + virtual void printFailures(); + virtual void printHeader(); + + virtual void printFailure( TestFailure *failure, + int failureNumber ); + virtual void printFailureListMark( int failureNumber ); + virtual void printFailureTestName( TestFailure *failure ); + virtual void printFailureType( TestFailure *failure ); + virtual void printFailureLocation( SourceLine sourceLine ); + virtual void printFailureDetail( Exception *thrownException ); + virtual void printFailureWarning(); + virtual void printStatistics(); + +protected: + TestResultCollector *m_result; + OStream &m_stream; + +private: + /// Prevents the use of the copy constructor. + TextOutputter( const TextOutputter © ); + + /// Prevents the use of the copy operator. + void operator =( const TextOutputter © ); +}; + + + +CPPUNIT_NS_END + +#endif // CPPUNIT_TEXTOUTPUTTER_H diff --git a/UnitTests/cppunit/include/cppunit/TextTestProgressListener.h b/UnitTests/cppunit/include/cppunit/TextTestProgressListener.h new file mode 100644 index 000000000..7521c40bc --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/TextTestProgressListener.h @@ -0,0 +1,44 @@ +#ifndef CPPUNIT_TEXTTESTPROGRESSLISTENER_H +#define CPPUNIT_TEXTTESTPROGRESSLISTENER_H + +#include + + +CPPUNIT_NS_BEGIN + + +/*! + * \brief TestListener that show the status of each TestCase test result. + * \ingroup TrackingTestExecution + */ +class CPPUNIT_API TextTestProgressListener : public TestListener +{ +public: + /*! Constructs a TextTestProgressListener object. + */ + TextTestProgressListener(); + + /// Destructor. + virtual ~TextTestProgressListener(); + + void startTest( Test *test ); + + void addFailure( const TestFailure &failure ); + + void endTestRun( Test *test, + TestResult *eventManager ); + +private: + /// Prevents the use of the copy constructor. + TextTestProgressListener( const TextTestProgressListener © ); + + /// Prevents the use of the copy operator. + void operator =( const TextTestProgressListener © ); + +private: +}; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_TEXTTESTPROGRESSLISTENER_H diff --git a/UnitTests/cppunit/include/cppunit/TextTestResult.h b/UnitTests/cppunit/include/cppunit/TextTestResult.h new file mode 100644 index 000000000..e7b1fa3ea --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/TextTestResult.h @@ -0,0 +1,39 @@ +#ifndef CPPUNIT_TEXTTESTRESULT_H +#define CPPUNIT_TEXTTESTRESULT_H + +#include +#include +#include + +CPPUNIT_NS_BEGIN + + +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 +{ +public: + TextTestResult(); + + virtual void addFailure( const TestFailure &failure ); + virtual void startTest( Test *test ); + virtual void print( OStream &stream ); +}; + +/** insertion operator for easy output */ +CPPUNIT_API OStream &operator <<( OStream &stream, + TextTestResult &result ); + +CPPUNIT_NS_END + +#endif // CPPUNIT_TEXTTESTRESULT_H + + diff --git a/UnitTests/cppunit/include/cppunit/TextTestRunner.h b/UnitTests/cppunit/include/cppunit/TextTestRunner.h new file mode 100644 index 000000000..23890e086 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/TextTestRunner.h @@ -0,0 +1,6 @@ +#ifndef CPPUNIT_TEXTTESTRUNNER_H +#define CPPUNIT_TEXTTESTRUNNER_H + +#include + +#endif // CPPUNIT_TEXTTESTRUNNER_H diff --git a/UnitTests/cppunit/include/cppunit/XmlOutputter.h b/UnitTests/cppunit/include/cppunit/XmlOutputter.h new file mode 100644 index 000000000..0de9676d8 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/XmlOutputter.h @@ -0,0 +1,167 @@ +#ifndef CPPUNIT_XMLTESTRESULTOUTPUTTER_H +#define CPPUNIT_XMLTESTRESULTOUTPUTTER_H + +#include + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( push ) +#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z +#endif + +#include +#include +#include +#include + + +CPPUNIT_NS_BEGIN + + +class Test; +class TestFailure; +class TestResultCollector; +class XmlDocument; +class XmlElement; +class XmlOutputterHook; + + +/*! \brief Outputs a TestResultCollector in XML format. + * \ingroup WritingTestResult + * + * Save the test result as a XML stream. + * + * Additional datas can be added to the XML document using XmlOutputterHook. + * Hook are not owned by the XmlOutputter. They should be valid until + * destruction of the XmlOutputter. They can be removed with removeHook(). + * + * \see XmlDocument, XmlElement, XmlOutputterHook. + */ +class CPPUNIT_API XmlOutputter : public Outputter +{ +public: + /*! \brief Constructs a XmlOutputter object. + * \param result Result of the test run. + * \param stream Stream used to output the XML output. + * \param encoding Encoding used in the XML file (default is Latin-1). + */ + XmlOutputter( TestResultCollector *result, + OStream &stream, + std::string encoding = std::string("ISO-8859-1") ); + + /// Destructor. + virtual ~XmlOutputter(); + + /*! \brief Adds the specified hook to the outputter. + * \param hook Hook to add. Must not be \c NULL. + */ + virtual void addHook( XmlOutputterHook *hook ); + + /*! \brief Removes the specified hook from the outputter. + * \param hook Hook to remove. + */ + virtual void removeHook( XmlOutputterHook *hook ); + + /*! \brief Writes the specified result as an XML document to the stream. + * + * Refer to examples/cppunittest/XmlOutputterTest.cpp for example + * of use and XML document structure. + */ + virtual void write(); + + /*! \brief Sets the XSL style sheet used. + * + * \param styleSheet Name of the style sheet used. If empty, then no style sheet + * is used (default). + */ + virtual void setStyleSheet( const std::string &styleSheet ); + + /*! \brief set the output document as standalone or not. + * + * For the output document, specify wether it's a standalone XML + * document, or not. + * + * \param standalone if true, the output will be specified as standalone. + * if false, it will be not. + */ + virtual void setStandalone( bool standalone ); + + typedef CppUnitMap > FailedTests; + + /*! \brief Sets the root element and adds its children. + * + * Set the root element of the XML Document and add its child elements. + * + * For all hooks, call beginDocument() just after creating the root element (it + * is empty at this time), and endDocument() once all the datas have been added + * to the root element. + */ + virtual void setRootNode(); + + virtual void addFailedTests( FailedTests &failedTests, + XmlElement *rootNode ); + + virtual void addSuccessfulTests( FailedTests &failedTests, + XmlElement *rootNode ); + + /*! \brief Adds the statics element to the root node. + * + * Creates a new element containing statistics data and adds it to the root element. + * Then, for all hooks, call statisticsAdded(). + * \param rootNode Root element. + */ + virtual void addStatistics( XmlElement *rootNode ); + + /*! \brief Adds a failed test to the failed tests node. + * Creates a new element containing datas about the failed test, and adds it to + * the failed tests element. + * Then, for all hooks, call failTestAdded(). + */ + virtual void addFailedTest( Test *test, + TestFailure *failure, + int testNumber, + XmlElement *testsNode ); + + virtual void addFailureLocation( TestFailure *failure, + XmlElement *testElement ); + + + /*! \brief Adds a successful test to the successful tests node. + * Creates a new element containing datas about the successful test, and adds it to + * the successful tests element. + * Then, for all hooks, call successfulTestAdded(). + */ + virtual void addSuccessfulTest( Test *test, + int testNumber, + XmlElement *testsNode ); +protected: + virtual void fillFailedTestsMap( FailedTests &failedTests ); + +protected: + typedef CppUnitDeque Hooks; + + TestResultCollector *m_result; + OStream &m_stream; + std::string m_encoding; + std::string m_styleSheet; + XmlDocument *m_xml; + Hooks m_hooks; + +private: + /// Prevents the use of the copy constructor. + XmlOutputter( const XmlOutputter © ); + + /// Prevents the use of the copy operator. + void operator =( const XmlOutputter © ); + +private: +}; + + +CPPUNIT_NS_END + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( pop ) +#endif + + +#endif // CPPUNIT_XMLTESTRESULTOUTPUTTER_H diff --git a/UnitTests/cppunit/include/cppunit/XmlOutputterHook.h b/UnitTests/cppunit/include/cppunit/XmlOutputterHook.h new file mode 100644 index 000000000..5ded3b1ee --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/XmlOutputterHook.h @@ -0,0 +1,163 @@ +#ifndef CPPUNIT_XMLOUTPUTTERHOOK_H +#define CPPUNIT_XMLOUTPUTTERHOOK_H + +#include + + +CPPUNIT_NS_BEGIN + + +class Test; +class TestFailure; +class XmlDocument; +class XmlElement; + + + +/*! \brief Hook to customize Xml output. + * + * XmlOutputterHook can be passed to XmlOutputter to customize the XmlDocument. + * + * Common customizations are: + * - adding some datas to successfull or failed test with + * failTestAdded() and successfulTestAdded(), + * - adding some statistics with statisticsAdded(), + * - adding other datas with beginDocument() or endDocument(). + * + * See examples/ClockerPlugIn which makes use of most the hook. + * + * Another simple example of an outputter hook is shown below. It may be + * used to add some meta information to your result files. In the example, + * the author name as well as the project name and test creation date is + * added to the head of the xml file. + * + * In order to make this information stored within the xml file, the virtual + * member function beginDocument() is overriden where a new + * XmlElement object is created. + * + * This element is simply added to the root node of the document which + * makes the information automatically being stored when the xml file + * is written. + * + * \code + * #include + * #include + * #include + * + * ... + * + * class MyXmlOutputterHook : public CppUnit::XmlOutputterHook + * { + * public: + * MyXmlOutputterHook(const std::string projectName, + * const std::string author) + * { + * m_projectName = projectName; + * m_author = author; + * }; + * + * virtual ~MyXmlOutputterHook() + * { + * }; + * + * void beginDocument(CppUnit::XmlDocument* document) + * { + * if (!document) + * return; + * + * // dump current time + * std::string szDate = CppUnit::StringTools::toString( (int)time(0) ); + * CppUnit::XmlElement* metaEl = new CppUnit::XmlElement("SuiteInfo", + * ""); + * + * metaEl->addElement( new CppUnit::XmlElement("Author", m_author) ); + * metaEl->addElement( new CppUnit::XmlElement("Project", m_projectName) ); + * metaEl->addElement( new CppUnit::XmlElement("Date", szDate ) ); + * + * document->rootElement().addElement(metaEl); + * }; + * private: + * std::string m_projectName; + * std::string m_author; + * }; + * \endcode + * + * Within your application's main code, you need to snap the hook + * object into your xml outputter object like shown below: + * + * \code + * CppUnit::TextUi::TestRunner runner; + * std::ofstream outputFile("testResults.xml"); + * + * CppUnit::XmlOutputter* outputter = new CppUnit::XmlOutputter( &runner.result(), + * outputFile ); + * MyXmlOutputterHook hook("myProject", "meAuthor"); + * outputter->addHook(&hook); + * runner.setOutputter(outputter); + * runner.addTest( VectorFixture::suite() ); + * runner.run(); + * outputFile.close(); + * \endcode + * + * This results into the following output: + * + * \code + * + * + * meAuthor + * myProject + * 1028143912 + * + * + * ... + * \endcode + * + * \see XmlOutputter, CppUnitTestPlugIn. + */ +class CPPUNIT_API XmlOutputterHook +{ +public: + /*! Called before any elements is added to the root element. + * \param document XML Document being created. + */ + virtual void beginDocument( XmlDocument *document ); + + /*! Called after adding all elements to the root element. + * \param document XML Document being created. + */ + virtual void endDocument( XmlDocument *document ); + + /*! Called after adding a fail test element. + * \param document XML Document being created. + * \param testElement \ element. + * \param test Test that failed. + * \param failure Test failure data. + */ + virtual void failTestAdded( XmlDocument *document, + XmlElement *testElement, + Test *test, + TestFailure *failure ); + + /*! Called after adding a successful test element. + * \param document XML Document being created. + * \param testElement \ element. + * \param test Test that was successful. + */ + virtual void successfulTestAdded( XmlDocument *document, + XmlElement *testElement, + Test *test ); + + /*! Called after adding the statistic element. + * \param document XML Document being created. + * \param statisticsElement \ element. + */ + virtual void statisticsAdded( XmlDocument *document, + XmlElement *statisticsElement ); + + virtual ~XmlOutputterHook() {} +}; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_XMLOUTPUTTERHOOK_H diff --git a/UnitTests/cppunit/include/cppunit/config/CppUnitApi.h b/UnitTests/cppunit/include/cppunit/config/CppUnitApi.h new file mode 100644 index 000000000..a068bbd54 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/config/CppUnitApi.h @@ -0,0 +1,33 @@ +#ifndef CPPUNIT_CONFIG_CPPUNITAPI +#define CPPUNIT_CONFIG_CPPUNITAPI + +#undef CPPUNIT_API + +#ifdef WIN32 + +// 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 + +#endif + + +#ifndef CPPUNIT_API +#define CPPUNIT_API +#undef CPPUNIT_NEED_DLL_DECL +#define CPPUNIT_NEED_DLL_DECL 0 +#endif + + +#endif // CPPUNIT_CONFIG_CPPUNITAPI diff --git a/UnitTests/cppunit/include/cppunit/config/SelectDllLoader.h b/UnitTests/cppunit/include/cppunit/config/SelectDllLoader.h new file mode 100644 index 000000000..dc1c01155 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/config/SelectDllLoader.h @@ -0,0 +1,76 @@ +#ifndef CPPUNIT_CONFIG_SELECTDLLLOADER_H +#define CPPUNIT_CONFIG_SELECTDLLLOADER_H + +/*! \file + * Selects DynamicLibraryManager implementation. + * + * Don't include this file directly. Include Portability.h instead. + */ + +/*! + * \def CPPUNIT_NO_TESTPLUGIN + * \brief If defined, then plug-in related classes and functions will not be compiled. + * + * \internal + * CPPUNIT_HAVE_WIN32_DLL_LOADER + * If defined, Win32 implementation of DynamicLibraryManager will be used. + * + * CPPUNIT_HAVE_BEOS_DLL_LOADER + * If defined, BeOs implementation of DynamicLibraryManager will be used. + * + * CPPUNIT_HAVE_UNIX_DLL_LOADER + * If defined, Unix implementation (dlfcn.h) of DynamicLibraryManager will be used. + */ + +/*! + * \def CPPUNIT_PLUGIN_EXPORT + * \ingroup WritingTestPlugIn + * \brief A macro to export a function from a dynamic library + * + * This macro export the C function following it from a dynamic library. + * Exporting the function makes it accessible to the DynamicLibraryManager. + * + * Example of usage: + * \code + * #include + * + * CPPUNIT_PLUGIN_EXPORT CppUnitTestPlugIn *CPPUNIT_PLUGIN_EXPORTED_NAME(void) + * { + * ... + * return &myPlugInInterface; + * } + * \endcode + */ + +#if !defined(CPPUNIT_NO_TESTPLUGIN) + +// Is WIN32 platform ? +#if defined(WIN32) +#define CPPUNIT_HAVE_WIN32_DLL_LOADER 1 +#undef CPPUNIT_PLUGIN_EXPORT +#define CPPUNIT_PLUGIN_EXPORT extern "C" __declspec(dllexport) + +// Is BeOS platform ? +#elif defined(__BEOS__) +#define CPPUNIT_HAVE_BEOS_DLL_LOADER 1 + +// Is Unix platform and have shl_load() (hp-ux) +#elif defined(CPPUNIT_HAVE_SHL_LOAD) +#define CPPUNIT_HAVE_UNIX_SHL_LOADER 1 + +// Is Unix platform and have include +#elif defined(CPPUNIT_HAVE_LIBDL) +#define CPPUNIT_HAVE_UNIX_DLL_LOADER 1 + +// Otherwise, disable support for DllLoader +#else +#define CPPUNIT_NO_TESTPLUGIN 1 +#endif + +#if !defined(CPPUNIT_PLUGIN_EXPORT) +#define CPPUNIT_PLUGIN_EXPORT extern "C" +#endif // !defined(CPPUNIT_PLUGIN_EXPORT) + +#endif // !defined(CPPUNIT_NO_TESTPLUGIN) + +#endif // CPPUNIT_CONFIG_SELECTDLLLOADER_H diff --git a/UnitTests/cppunit/include/cppunit/config/SourcePrefix.h b/UnitTests/cppunit/include/cppunit/config/SourcePrefix.h new file mode 100644 index 000000000..2334601b5 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/config/SourcePrefix.h @@ -0,0 +1,14 @@ +#ifndef CPPUNIT_CONFIG_H_INCLUDED +#define CPPUNIT_CONFIG_H_INCLUDED + +#include + +#ifdef _MSC_VER +#pragma warning(disable: 4018 4284 4146) +#if _MSC_VER >= 1400 +#pragma warning(disable: 4996) // sprintf is deprecated +#endif +#endif + + +#endif // CPPUNIT_CONFIG_H_INCLUDED diff --git a/UnitTests/cppunit/include/cppunit/config/config-bcb5.h b/UnitTests/cppunit/include/cppunit/config/config-bcb5.h new file mode 100644 index 000000000..d49145206 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/config/config-bcb5.h @@ -0,0 +1,47 @@ +#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 to 1 if the compiler implements namespaces */ +#ifndef CPPUNIT_HAVE_NAMESPACES +#define CPPUNIT_HAVE_NAMESPACES 1 +#endif + +/* define if library uses std::string::compare(string,pos,n) */ +#ifndef CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST +#define CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST 0 +#endif + +/* Define if you have the 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 + +/* _INCLUDE_CPPUNIT_CONFIG_BCB5_H */ +#endif diff --git a/UnitTests/cppunit/include/cppunit/config/config-evc4.h b/UnitTests/cppunit/include/cppunit/config/config-evc4.h new file mode 100644 index 000000000..a79169812 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/config/config-evc4.h @@ -0,0 +1,78 @@ +#ifndef _INCLUDE_CPPUNIT_CONFIG_EVC4_H +#define _INCLUDE_CPPUNIT_CONFIG_EVC4_H 1 + +#if _MSC_VER > 1000 // VC++ +#pragma warning( disable : 4786 ) // disable warning debug symbol > 255... +#endif // _MSC_VER > 1000 + +#define HAVE_CMATH 1 + +/* include/cppunit/config-msvc6.h. Manually adapted from + include/cppunit/config-auto.h */ + +/* define to 1 if the compiler implements namespaces */ +#ifndef CPPUNIT_HAVE_NAMESPACES +#define CPPUNIT_HAVE_NAMESPACES 1 +#endif + +/* 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 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 0 +#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_NO_STREAM 1 +#define CPPUNIT_NO_ASSERT 1 + +#define CPPUNIT_HAVE_SSTREAM 0 + +/* Name of package */ +#ifndef CPPUNIT_PACKAGE +#define CPPUNIT_PACKAGE "cppunit" +#endif + + +// Compiler error location format for CompilerOutputter +// See class CompilerOutputter for format. +#undef CPPUNIT_COMPILER_LOCATION_FORMAT +#if _MSC_VER >= 1300 // VS 7.0 +# define CPPUNIT_COMPILER_LOCATION_FORMAT "%p(%l) : error : " +#else +# define CPPUNIT_COMPILER_LOCATION_FORMAT "%p(%l):" +#endif + +/* define to 1 if the compiler has _finite() */ +#ifndef CPPUNIT_HAVE__FINITE +#define CPPUNIT_HAVE__FINITE 1 +#endif + +// Uncomment to turn on STL wrapping => use this to test compilation. +// This will make CppUnit subclass std::vector & co to provide default +// parameter. +/*#define CPPUNIT_STD_NEED_ALLOCATOR 1 +#define CPPUNIT_STD_ALLOCATOR std::allocator +//#define CPPUNIT_NO_NAMESPACE 1 +*/ + + +/* _INCLUDE_CPPUNIT_CONFIG_EVC4_H */ +#endif diff --git a/UnitTests/cppunit/include/cppunit/config/config-mac.h b/UnitTests/cppunit/include/cppunit/config/config-mac.h new file mode 100644 index 000000000..4ace906cf --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/config/config-mac.h @@ -0,0 +1,58 @@ +#ifndef _INCLUDE_CPPUNIT_CONFIG_MAC_H +#define _INCLUDE_CPPUNIT_CONFIG_MAC_H 1 + +/* MacOS X should be installed using the configure script. + This file is for other macs. + + It is not integrated into because we don't + know a suitable preprocessor symbol that will distinguish MacOS X + from other MacOS versions. Email us if you know the answer. +*/ + +/* 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 the library defines strstream */ +#ifndef CPPUNIT_HAVE_CLASS_STRSTREAM +#define CPPUNIT_HAVE_CLASS_STRSTREAM 1 +#endif + +/* Define if you have the header file. */ +#ifdef CPPUNIT_HAVE_CMATH +#undef CPPUNIT_HAVE_CMATH +#endif + +/* Define if you have the 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 if the compiler has stringstream */ +#ifndef CPPUNIT_HAVE_SSTREAM +#define CPPUNIT_HAVE_SSTREAM 1 +#endif + +/* Define if you have the header file. */ +#ifndef CPPUNIT_HAVE_STRSTREAM +#define CPPUNIT_HAVE_STRSTREAM 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 + +/* _INCLUDE_CPPUNIT_CONFIG_MAC_H */ +#endif diff --git a/UnitTests/cppunit/include/cppunit/config/config-msvc6.h b/UnitTests/cppunit/include/cppunit/config/config-msvc6.h new file mode 100644 index 000000000..54bce8275 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/config/config-msvc6.h @@ -0,0 +1,86 @@ +#ifndef _INCLUDE_CPPUNIT_CONFIG_MSVC6_H +#define _INCLUDE_CPPUNIT_CONFIG_MSVC6_H 1 + +#if _MSC_VER > 1000 // VC++ +#pragma warning( disable : 4786 ) // disable warning debug symbol > 255... +#endif // _MSC_VER > 1000 + +#define HAVE_CMATH 1 + +/* include/cppunit/config-msvc6.h. Manually adapted from + include/cppunit/config-auto.h */ + +/* define to 1 if the compiler implements namespaces */ +#ifndef CPPUNIT_HAVE_NAMESPACES +#define CPPUNIT_HAVE_NAMESPACES 1 +#endif + +/* 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 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 +# ifdef _CPPRTTI // Defined by the compiler option /GR +# define CPPUNIT_HAVE_RTTI 1 +# else +# define CPPUNIT_HAVE_RTTI 0 +# endif +#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 + + +// Compiler error location format for CompilerOutputter +// See class CompilerOutputter for format. +#undef CPPUNIT_COMPILER_LOCATION_FORMAT +#if _MSC_VER >= 1300 // VS 7.0 +# define CPPUNIT_COMPILER_LOCATION_FORMAT "%p(%l) : error : " +#else +# define CPPUNIT_COMPILER_LOCATION_FORMAT "%p(%l):" +#endif + +// Define to 1 if the compiler support C++ style cast. +#define CPPUNIT_HAVE_CPP_CAST 1 + +/* define to 1 if the compiler has _finite() */ +#ifndef CPPUNIT_HAVE__FINITE +#define CPPUNIT_HAVE__FINITE 1 +#endif + + +// Uncomment to turn on STL wrapping => use this to test compilation. +// This will make CppUnit subclass std::vector & co to provide default +// parameter. +/*#define CPPUNIT_STD_NEED_ALLOCATOR 1 +#define CPPUNIT_STD_ALLOCATOR std::allocator +//#define CPPUNIT_NO_NAMESPACE 1 +*/ + +#if _MSC_VER >= 1300 // VS 7.0 +#define CPPUNIT_UNIQUE_COUNTER __COUNTER__ +#endif // if _MSC_VER >= 1300 // VS 7.0 + +/* _INCLUDE_CPPUNIT_CONFIG_MSVC6_H */ +#endif diff --git a/UnitTests/cppunit/include/cppunit/extensions/AutoRegisterSuite.h b/UnitTests/cppunit/include/cppunit/extensions/AutoRegisterSuite.h new file mode 100644 index 000000000..e04adb5d9 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/extensions/AutoRegisterSuite.h @@ -0,0 +1,83 @@ +#ifndef CPPUNIT_EXTENSIONS_AUTOREGISTERSUITE_H +#define CPPUNIT_EXTENSIONS_AUTOREGISTERSUITE_H + +#include +#include +#include + +CPPUNIT_NS_BEGIN + + +/*! \brief (Implementation) Automatically register the test suite of the specified type. + * + * You should not use this class directly. Instead, use the following macros: + * - CPPUNIT_TEST_SUITE_REGISTRATION() + * - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION() + * + * This object will register the test returned by TestCaseType::suite() + * when constructed to the test registry. + * + * This object is intented to be used as a static variable. + * + * + * \param TestCaseType Type of the test case which suite is registered. + * \see CPPUNIT_TEST_SUITE_REGISTRATION, CPPUNIT_TEST_SUITE_NAMED_REGISTRATION + * \see CppUnit::TestFactoryRegistry. + */ +template +class AutoRegisterSuite +{ +public: + /** Auto-register the suite factory in the global registry. + */ + AutoRegisterSuite() + : m_registry( &TestFactoryRegistry::getRegistry() ) + { + m_registry->registerFactory( &m_factory ); + } + + /** Auto-register the suite factory in the specified registry. + * \param name Name of the registry. + */ + AutoRegisterSuite( const std::string &name ) + : m_registry( &TestFactoryRegistry::getRegistry( name ) ) + { + m_registry->registerFactory( &m_factory ); + } + + ~AutoRegisterSuite() + { + if ( TestFactoryRegistry::isValid() ) + m_registry->unregisterFactory( &m_factory ); + } + +private: + TestFactoryRegistry *m_registry; + TestSuiteFactory m_factory; +}; + + +/*! \brief (Implementation) Automatically adds a registry into another registry. + * + * Don't use this class. Use the macros CPPUNIT_REGISTRY_ADD() and + * CPPUNIT_REGISTRY_ADD_TO_DEFAULT() instead. + */ +class AutoRegisterRegistry +{ +public: + AutoRegisterRegistry( const std::string &which, + const std::string &to ) + { + TestFactoryRegistry::getRegistry( to ).addRegistry( which ); + } + + AutoRegisterRegistry( const std::string &which ) + { + TestFactoryRegistry::getRegistry().addRegistry( which ); + } +}; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_EXTENSIONS_AUTOREGISTERSUITE_H diff --git a/UnitTests/cppunit/include/cppunit/extensions/ExceptionTestCaseDecorator.h b/UnitTests/cppunit/include/cppunit/extensions/ExceptionTestCaseDecorator.h new file mode 100644 index 000000000..2929a0095 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/extensions/ExceptionTestCaseDecorator.h @@ -0,0 +1,104 @@ +#ifndef CPPUNIT_EXTENSIONS_EXCEPTIONTESTCASEDECORATOR_H +#define CPPUNIT_EXTENSIONS_EXCEPTIONTESTCASEDECORATOR_H + +#include +#include +#include + +CPPUNIT_NS_BEGIN + + +/*! \brief Expected exception test case decorator. + * + * A decorator used to assert that a specific test case should throw an + * exception of a given type. + * + * You should use this class only if you need to check the exception object + * state (that a specific cause is set for example). If you don't need to + * do that, you might consider using CPPUNIT_TEST_EXCEPTION() instead. + * + * Intended use is to subclass and override checkException(). Example: + * + * \code + * + * class NetworkErrorTestCaseDecorator : + * public ExceptionTestCaseDecorator + * { + * public: + * NetworkErrorTestCaseDecorator( NetworkError::Cause expectedCause ) + * : m_expectedCause( expectedCause ) + * { + * } + * private: + * void checkException( ExpectedExceptionType &e ) + * { + * CPPUNIT_ASSERT_EQUAL( m_expectedCause, e.getCause() ); + * } + * + * NetworkError::Cause m_expectedCause; + * }; + * \endcode + * + */ +template +class ExceptionTestCaseDecorator : public TestCaseDecorator +{ +public: + typedef ExpectedException ExpectedExceptionType; + + /*! \brief Decorates the specified test. + * \param test TestCase to decorate. Assumes ownership of the test. + */ + ExceptionTestCaseDecorator( TestCase *test ) + : TestCaseDecorator( test ) + { + } + + /*! \brief Checks that the expected exception is thrown by the decorated test. + * is thrown. + * + * Calls the decorated test runTest() and checks that an exception of + * type ExpectedException is thrown. Call checkException() passing the + * exception that was caught so that some assertions can be made if + * needed. + */ + void runTest() + { + try + { + TestCaseDecorator::runTest(); + } + catch ( ExpectedExceptionType &e ) + { + checkException( e ); + return; + } + + // Moved outside the try{} statement to handle the case where the + // expected exception type is Exception (expecting assertion failure). +#if CPPUNIT_USE_TYPEINFO_NAME + throw Exception( Message( + "expected exception not thrown", + "Expected exception type: " + + TypeInfoHelper::getClassName( + typeid( ExpectedExceptionType ) ) ) ); +#else + throw Exception( Message("expected exception not thrown") ); +#endif + } + +private: + /*! \brief Called when the exception is caught. + * + * Should be overriden to check the exception. + */ + virtual void checkException( ExpectedExceptionType & ) + { + } +}; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_EXTENSIONS_EXCEPTIONTESTCASEDECORATOR_H + diff --git a/UnitTests/cppunit/include/cppunit/extensions/HelperMacros.h b/UnitTests/cppunit/include/cppunit/extensions/HelperMacros.h new file mode 100644 index 000000000..12431e465 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/extensions/HelperMacros.h @@ -0,0 +1,541 @@ +// ////////////////////////////////////////////////////////////////////////// +// Header file HelperMacros.h +// (c)Copyright 2000, Baptiste Lepilleur. +// Created: 2001/04/15 +// ////////////////////////////////////////////////////////////////////////// +#ifndef CPPUNIT_EXTENSIONS_HELPERMACROS_H +#define CPPUNIT_EXTENSIONS_HELPERMACROS_H + +#include +#include +#include +#include +#include +#include +#include +#include + + +/*! \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 + * 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 + * 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 ); + * CPPUNIT_TEST_SUITE_REGISTRATION( StringTest ); + * \endcode + */ + + +/*! \brief Begin test suite + * + * This macro starts the declaration of a new test suite. + * Use CPPUNIT_TEST_SUB_SUITE() instead, if you wish to include the + * test suite of the parent class. + * + * \param ATestFixtureType Type of the test case class. This type \b MUST + * be derived from TestFixture. + * \see CPPUNIT_TEST_SUB_SUITE, CPPUNIT_TEST, CPPUNIT_TEST_SUITE_END, + * \see CPPUNIT_TEST_SUITE_REGISTRATION, CPPUNIT_TEST_EXCEPTION, CPPUNIT_TEST_FAIL. + */ +#define CPPUNIT_TEST_SUITE( ATestFixtureType ) \ + public: \ + typedef ATestFixtureType TestFixtureType; \ + \ + private: \ + static const CPPUNIT_NS::TestNamer &getTestNamer__() \ + { \ + static CPPUNIT_TESTNAMER_DECL( testNamer, ATestFixtureType ); \ + return testNamer; \ + } \ + \ + public: \ + typedef CPPUNIT_NS::TestSuiteBuilderContext \ + TestSuiteBuilderContextType; \ + \ + static void \ + addTestsToSuite( CPPUNIT_NS::TestSuiteBuilderContextBase &baseContext ) \ + { \ + TestSuiteBuilderContextType context( baseContext ) + + +/*! \brief Begin test suite (includes parent suite) + * + * This macro may only be used in a class whose parent class + * defines a test suite using CPPUNIT_TEST_SUITE() or CPPUNIT_TEST_SUB_SUITE(). + * + * This macro begins the declaration of a test suite, in the same + * manner as CPPUNIT_TEST_SUITE(). In addition, the test suite of the + * parent is automatically inserted in the test suite being + * defined. + * + * Here is an example: + * + * \code + * #include + * class MySubTest : public MyTest { + * CPPUNIT_TEST_SUB_SUITE( MySubTest, MyTest ); + * CPPUNIT_TEST( testAdd ); + * CPPUNIT_TEST( testSub ); + * CPPUNIT_TEST_SUITE_END(); + * public: + * void testAdd(); + * void testSub(); + * }; + * \endcode + * + * \param ATestFixtureType Type of the test case class. This type \b MUST + * be derived from TestFixture. + * \param ASuperClass Type of the parent class. + * \see CPPUNIT_TEST_SUITE. + */ +#define CPPUNIT_TEST_SUB_SUITE( ATestFixtureType, ASuperClass ) \ + public: \ + typedef ASuperClass ParentTestFixtureType; \ + private: \ + CPPUNIT_TEST_SUITE( ATestFixtureType ); \ + ParentTestFixtureType::addTestsToSuite( baseContext ) + + +/*! \brief End declaration of the test suite. + * + * After this macro, member access is set to "private". + * + * \see CPPUNIT_TEST_SUITE. + * \see CPPUNIT_TEST_SUITE_REGISTRATION. + */ +#define CPPUNIT_TEST_SUITE_END() \ + } \ + \ + static CPPUNIT_NS::TestSuite *suite() \ + { \ + const CPPUNIT_NS::TestNamer &namer = getTestNamer__(); \ + std::auto_ptr suite( \ + new CPPUNIT_NS::TestSuite( namer.getFixtureName() )); \ + CPPUNIT_NS::ConcretTestFixtureFactory factory; \ + CPPUNIT_NS::TestSuiteBuilderContextBase context( *suite.get(), \ + namer, \ + factory ); \ + TestFixtureType::addTestsToSuite( context ); \ + return suite.release(); \ + } \ + private: /* dummy typedef so that the macro can still end with ';'*/ \ + typedef int CppUnitDummyTypedefForSemiColonEnding__ + +/*! \brief End declaration of an abstract test suite. + * + * Use this macro to indicate that the %TestFixture is abstract. No + * static suite() method will be declared. + * + * After this macro, member access is set to "private". + * + * Here is an example of usage: + * + * The abstract test fixture: + * \code + * #include + * class AbstractDocument; + * class AbstractDocumentTest : public CppUnit::TestFixture { + * CPPUNIT_TEST_SUITE( AbstractDocumentTest ); + * CPPUNIT_TEST( testInsertText ); + * CPPUNIT_TEST_SUITE_END_ABSTRACT(); + * public: + * void testInsertText(); + * + * void setUp() + * { + * m_document = makeDocument(); + * } + * + * void tearDown() + * { + * delete m_document; + * } + * protected: + * virtual AbstractDocument *makeDocument() =0; + * + * AbstractDocument *m_document; + * };\endcode + * + * The concret test fixture: + * \code + * class RichTextDocumentTest : public AbstractDocumentTest { + * CPPUNIT_TEST_SUB_SUITE( RichTextDocumentTest, AbstractDocumentTest ); + * CPPUNIT_TEST( testInsertFormatedText ); + * CPPUNIT_TEST_SUITE_END(); + * public: + * void testInsertFormatedText(); + * protected: + * AbstractDocument *makeDocument() + * { + * return new RichTextDocument(); + * } + * };\endcode + * + * \see CPPUNIT_TEST_SUB_SUITE. + * \see CPPUNIT_TEST_SUITE_REGISTRATION. + */ +#define CPPUNIT_TEST_SUITE_END_ABSTRACT() \ + } \ + private: /* dummy typedef so that the macro can still end with ';'*/ \ + typedef int CppUnitDummyTypedefForSemiColonEnding__ + + +/*! \brief Add a test to the suite (for custom test macro). + * + * The specified test will be added to the test suite being declared. This macro + * is intended for \e advanced usage, to extend %CppUnit by creating new macro such + * as CPPUNIT_TEST_EXCEPTION()... + * + * Between macro CPPUNIT_TEST_SUITE() and CPPUNIT_TEST_SUITE_END(), you can assume + * that the following variables can be used: + * \code + * typedef TestSuiteBuilder TestSuiteBuilderType; + * TestSuiteBuilderType &context; + * \endcode + * + * \c context can be used to name test case, create new test fixture instance, + * or add test case to the test fixture suite. + * + * Below is an example that show how to use this macro to create new macro to add + * test to the fixture suite. The macro below show how you would add a new type + * of test case which fails if the execution last more than a given time limit. + * It relies on an imaginary TimeOutTestCaller class which has an interface similar + * to TestCaller. + * + * \code + * #define CPPUNITEX_TEST_TIMELIMIT( testMethod, timeLimit ) \ + * CPPUNIT_TEST_SUITE_ADD_TEST( (new TimeOutTestCaller( \ + * namer.getTestNameFor( #testMethod ), \ + * &TestFixtureType::testMethod, \ + * factory.makeFixture(), \ + * timeLimit ) ) ) + * + * class PerformanceTest : CppUnit::TestFixture + * { + * public: + * CPPUNIT_TEST_SUITE( PerformanceTest ); + * CPPUNITEX_TEST_TIMELIMIT( testSortReverseOrder, 5.0 ); + * CPPUNIT_TEST_SUITE_END(); + * + * void testSortReverseOrder(); + * }; + * \endcode + * + * \param test Test to add to the suite. Must be a subclass of Test. The test name + * should have been obtained using TestNamer::getTestNameFor(). + */ +#define CPPUNIT_TEST_SUITE_ADD_TEST( test ) \ + context.addTest( test ) + +/*! \brief Add a method to the suite. + * \param testMethod Name of the method of the test case to add to the + * suite. The signature of the method must be of + * type: void testMethod(); + * \see CPPUNIT_TEST_SUITE. + */ +#define CPPUNIT_TEST( testMethod ) \ + CPPUNIT_TEST_SUITE_ADD_TEST( \ + ( new CPPUNIT_NS::TestCaller( \ + context.getTestNameFor( #testMethod), \ + &TestFixtureType::testMethod, \ + context.makeFixture() ) ) ) + +/*! \brief Add a test which fail if the specified exception is not caught. + * + * Example: + * \code + * #include + * #include + * 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 v; + * v.at( 1 ); // must throw exception std::invalid_argument + * } + * }; + * \endcode + * + * \param testMethod Name of the method of the test case to add to the suite. + * \param ExceptionType Type of the exception that must be thrown by the test + * method. + * \deprecated Use the assertion macro CPPUNIT_ASSERT_THROW instead. + */ +#define CPPUNIT_TEST_EXCEPTION( testMethod, ExceptionType ) \ + CPPUNIT_TEST_SUITE_ADD_TEST( \ + (new CPPUNIT_NS::ExceptionTestCaseDecorator< ExceptionType >( \ + new CPPUNIT_NS::TestCaller< TestFixtureType >( \ + context.getTestNameFor( #testMethod ), \ + &TestFixtureType::testMethod, \ + context.makeFixture() ) ) ) ) + +/*! \brief Adds a test case which is excepted to fail. + * + * The added test case expect an assertion to fail. You usually used that type + * of test case when testing custom assertion macros. + * + * \code + * CPPUNIT_TEST_FAIL( testAssertFalseFail ); + * + * void testAssertFalseFail() + * { + * CPPUNIT_ASSERT( false ); + * } + * \endcode + * \see CreatingNewAssertions. + * \deprecated Use the assertion macro CPPUNIT_ASSERT_ASSERTION_FAIL instead. + */ +#define CPPUNIT_TEST_FAIL( testMethod ) \ + CPPUNIT_TEST_EXCEPTION( testMethod, CPPUNIT_NS::Exception ) + +/*! \brief Adds some custom test cases. + * + * Use this to add one or more test cases to the fixture suite. The specified + * method is called with a context parameter that can be used to name, + * instantiate fixture, and add instantiated test case to the fixture suite. + * The specified method must have the following signature: + * \code + * static void aMethodName( TestSuiteBuilderContextType &context ); + * \endcode + * + * \c TestSuiteBuilderContextType is typedef to + * TestSuiteBuilderContext declared by CPPUNIT_TEST_SUITE(). + * + * Here is an example that add two custom tests: + * + * \code + * #include + * + * class MyTest : public CppUnit::TestFixture { + * CPPUNIT_TEST_SUITE( MyTest ); + * CPPUNIT_TEST_SUITE_ADD_CUSTOM_TESTS( addTimeOutTests ); + * CPPUNIT_TEST_SUITE_END(); + * public: + * static void addTimeOutTests( TestSuiteBuilderContextType &context ) + * { + * context.addTest( new TimeOutTestCaller( context.getTestNameFor( "test1" ) ), + * &MyTest::test1, + * context.makeFixture(), + * 5.0 ); + * context.addTest( new TimeOutTestCaller( context.getTestNameFor( "test2" ) ), + * &MyTest::test2, + * context.makeFixture(), + * 5.0 ); + * } + * + * void test1() + * { + * // Do some test that may never end... + * } + * + * void test2() + * { + * // Do some test that may never end... + * } + * }; + * \endcode + * @param testAdderMethod Name of the method called to add the test cases. + */ +#define CPPUNIT_TEST_SUITE_ADD_CUSTOM_TESTS( testAdderMethod ) \ + testAdderMethod( context ) + +/*! \brief Adds a property to the test suite builder context. + * \param APropertyKey Key of the property to add. + * \param APropertyValue Value for the added property. + * Example: + * \code + * CPPUNIT_TEST_SUITE_PROPERTY("XmlFileName", "paraTest.xml"); \endcode + */ +#define CPPUNIT_TEST_SUITE_PROPERTY( APropertyKey, APropertyValue ) \ + context.addProperty( std::string(APropertyKey), \ + std::string(APropertyValue) ) + +/** @} + */ + + +/*! Adds the specified fixture suite to the unnamed registry. + * \ingroup CreatingTestSuite + * + * This macro declares a static variable whose construction + * causes a test suite factory to be inserted in a global registry + * of such factories. The registry is available by calling + * the static function CppUnit::TestFactoryRegistry::getRegistry(). + * + * \param ATestFixtureType Type of the test case class. + * \warning This macro should be used only once per line of code (the line + * number is used to name a hidden static variable). + * \see CPPUNIT_TEST_SUITE_NAMED_REGISTRATION + * \see CPPUNIT_REGISTRY_ADD_TO_DEFAULT + * \see CPPUNIT_REGISTRY_ADD + * \see CPPUNIT_TEST_SUITE, CppUnit::AutoRegisterSuite, + * CppUnit::TestFactoryRegistry. + */ +#define CPPUNIT_TEST_SUITE_REGISTRATION( ATestFixtureType ) \ + static CPPUNIT_NS::AutoRegisterSuite< ATestFixtureType > \ + CPPUNIT_MAKE_UNIQUE_NAME(autoRegisterRegistry__ ) + + +/** Adds the specified fixture suite to the specified registry suite. + * \ingroup CreatingTestSuite + * + * This macro declares a static variable whose construction + * causes a test suite factory to be inserted in the global registry + * suite of the specified name. The registry is available by calling + * the static function CppUnit::TestFactoryRegistry::getRegistry(). + * + * For the suite name, use a string returned by a static function rather + * than a hardcoded string. That way, you can know what are the name of + * named registry and you don't risk mistyping the registry name. + * + * \code + * // MySuites.h + * namespace MySuites { + * std::string math() { + * return "Math"; + * } + * } + * + * // ComplexNumberTest.cpp + * #include "MySuites.h" + * + * CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ComplexNumberTest, MySuites::math() ); + * \endcode + * + * \param ATestFixtureType Type of the test case class. + * \param suiteName Name of the global registry suite the test suite is + * registered into. + * \warning This macro should be used only once per line of code (the line + * number is used to name a hidden static variable). + * \see CPPUNIT_TEST_SUITE_REGISTRATION + * \see CPPUNIT_REGISTRY_ADD_TO_DEFAULT + * \see CPPUNIT_REGISTRY_ADD + * \see CPPUNIT_TEST_SUITE, CppUnit::AutoRegisterSuite, + * CppUnit::TestFactoryRegistry.. + */ +#define CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ATestFixtureType, suiteName ) \ + static CPPUNIT_NS::AutoRegisterSuite< ATestFixtureType > \ + CPPUNIT_MAKE_UNIQUE_NAME(autoRegisterRegistry__ )(suiteName) + +/*! Adds that the specified registry suite to another registry suite. + * \ingroup CreatingTestSuite + * + * Use this macros to automatically create test registry suite hierarchy. For example, + * if you want to create the following hierarchy: + * - Math + * - IntegerMath + * - FloatMath + * - FastFloat + * - StandardFloat + * + * You can do this automatically with: + * \code + * CPPUNIT_REGISTRY_ADD( "FastFloat", "FloatMath" ); + * CPPUNIT_REGISTRY_ADD( "IntegerMath", "Math" ); + * CPPUNIT_REGISTRY_ADD( "FloatMath", "Math" ); + * CPPUNIT_REGISTRY_ADD( "StandardFloat", "FloatMath" ); + * \endcode + * + * There is no specific order of declaration. Think of it as declaring links. + * + * You register the test in each suite using CPPUNIT_TEST_SUITE_NAMED_REGISTRATION. + * + * \param which Name of the registry suite to add to the registry suite named \a to. + * \param to Name of the registry suite \a which is added to. + * \see CPPUNIT_REGISTRY_ADD_TO_DEFAULT, CPPUNIT_TEST_SUITE_NAMED_REGISTRATION. + */ +#define CPPUNIT_REGISTRY_ADD( which, to ) \ + static CPPUNIT_NS::AutoRegisterRegistry \ + CPPUNIT_MAKE_UNIQUE_NAME( autoRegisterRegistry__ )( which, to ) + +/*! Adds that the specified registry suite to the default registry suite. + * \ingroup CreatingTestSuite + * + * This macro is just like CPPUNIT_REGISTRY_ADD except the specified registry + * suite is added to the default suite (root suite). + * + * \param which Name of the registry suite to add to the default registry suite. + * \see CPPUNIT_REGISTRY_ADD. + */ +#define CPPUNIT_REGISTRY_ADD_TO_DEFAULT( which ) \ + static CPPUNIT_NS::AutoRegisterRegistry \ + CPPUNIT_MAKE_UNIQUE_NAME( autoRegisterRegistry__ )( which ) + +// Backwards compatibility +// (Not tested!) + +#if CPPUNIT_ENABLE_CU_TEST_MACROS + +#define CU_TEST_SUITE(tc) CPPUNIT_TEST_SUITE(tc) +#define CU_TEST_SUB_SUITE(tc,sc) CPPUNIT_TEST_SUB_SUITE(tc,sc) +#define CU_TEST(tm) CPPUNIT_TEST(tm) +#define CU_TEST_SUITE_END() CPPUNIT_TEST_SUITE_END() +#define CU_TEST_SUITE_REGISTRATION(tc) CPPUNIT_TEST_SUITE_REGISTRATION(tc) + +#endif + + +#endif // CPPUNIT_EXTENSIONS_HELPERMACROS_H diff --git a/UnitTests/cppunit/include/cppunit/extensions/Orthodox.h b/UnitTests/cppunit/include/cppunit/extensions/Orthodox.h new file mode 100644 index 000000000..722125937 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/extensions/Orthodox.h @@ -0,0 +1,95 @@ +#ifndef CPPUNIT_EXTENSIONS_ORTHODOX_H +#define CPPUNIT_EXTENSIONS_ORTHODOX_H + +#include + +CPPUNIT_NS_BEGIN + + +/* + * Orthodox performs a simple set of tests on an arbitary + * class to make sure that it supports at least the + * following operations: + * + * default construction - constructor + * equality/inequality - operator== && operator!= + * assignment - operator= + * negation - operator! + * safe passage - copy construction + * + * If operations for each of these are not declared + * the template will not instantiate. If it does + * instantiate, tests are performed to make sure + * that the operations have correct semantics. + * + * Adding an orthodox test to a suite is very + * easy: + * + * public: Test *suite () { + * TestSuite *suiteOfTests = new TestSuite; + * suiteOfTests->addTest (new ComplexNumberTest ("testAdd"); + * suiteOfTests->addTest (new TestCaller > ()); + * return suiteOfTests; + * } + * + * Templated test cases be very useful when you are want to + * make sure that a group of classes have the same form. + * + * see TestSuite + */ + + +template class Orthodox : public TestCase +{ +public: + Orthodox () : TestCase ("Orthodox") {} + +protected: + ClassUnderTest call (ClassUnderTest object); + void runTest (); + + +}; + + +// Run an orthodoxy test +template void Orthodox::runTest () +{ + // make sure we have a default constructor + ClassUnderTest a, b, c; + + // make sure we have an equality operator + CPPUNIT_ASSERT (a == b); + + // check the inverse + b.operator= (a.operator! ()); + CPPUNIT_ASSERT (a != b); + + // double inversion + b = !!a; + CPPUNIT_ASSERT (a == b); + + // invert again + b = !a; + + // check calls + c = a; + CPPUNIT_ASSERT (c == call (a)); + + c = b; + CPPUNIT_ASSERT (c == call (b)); + +} + + +// Exercise a call +template +ClassUnderTest Orthodox::call (ClassUnderTest object) +{ + return object; +} + + +CPPUNIT_NS_END + +#endif diff --git a/UnitTests/cppunit/include/cppunit/extensions/RepeatedTest.h b/UnitTests/cppunit/include/cppunit/extensions/RepeatedTest.h new file mode 100644 index 000000000..390ce4807 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/extensions/RepeatedTest.h @@ -0,0 +1,43 @@ +#ifndef CPPUNIT_EXTENSIONS_REPEATEDTEST_H +#define CPPUNIT_EXTENSIONS_REPEATEDTEST_H + +#include +#include + +CPPUNIT_NS_BEGIN + + +class Test; +class TestResult; + + +/*! \brief Decorator that runs a test repeatedly. + * + * Does not assume ownership of the test it decorates + */ +class CPPUNIT_API RepeatedTest : public TestDecorator +{ +public: + RepeatedTest( Test *test, + int timesRepeat ) : + TestDecorator( test ), + m_timesRepeat(timesRepeat) + { + } + + void run( TestResult *result ); + + int countTestCases() const; + +private: + RepeatedTest( const RepeatedTest & ); + void operator=( const RepeatedTest & ); + + const int m_timesRepeat; +}; + + +CPPUNIT_NS_END + + +#endif // CPPUNIT_EXTENSIONS_REPEATEDTEST_H diff --git a/UnitTests/cppunit/include/cppunit/extensions/TestCaseDecorator.h b/UnitTests/cppunit/include/cppunit/extensions/TestCaseDecorator.h new file mode 100644 index 000000000..3a15ba974 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/extensions/TestCaseDecorator.h @@ -0,0 +1,40 @@ +#ifndef CPPUNIT_EXTENSIONS_TESTCASEDECORATOR_H +#define CPPUNIT_EXTENSIONS_TESTCASEDECORATOR_H + +#include +#include + +CPPUNIT_NS_BEGIN + + +/*! \brief Decorator for Test cases. + * + * TestCaseDecorator provides an alternate means to extend functionality + * of a test class without subclassing the test. Instead, one can + * subclass the decorater and use it to wrap the test class. + * + * Does not assume ownership of the test it decorates + */ +class CPPUNIT_API TestCaseDecorator : public TestCase +{ +public: + TestCaseDecorator( TestCase *test ); + ~TestCaseDecorator(); + + std::string getName() const; + + void setUp(); + + void tearDown(); + + void runTest(); + +protected: + TestCase *m_test; +}; + + +CPPUNIT_NS_END + +#endif + diff --git a/UnitTests/cppunit/include/cppunit/extensions/TestDecorator.h b/UnitTests/cppunit/include/cppunit/extensions/TestDecorator.h new file mode 100644 index 000000000..59d9a302e --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/extensions/TestDecorator.h @@ -0,0 +1,49 @@ +#ifndef CPPUNIT_EXTENSIONS_TESTDECORATOR_H +#define CPPUNIT_EXTENSIONS_TESTDECORATOR_H + +#include +#include + +CPPUNIT_NS_BEGIN + + +class TestResult; + + +/*! \brief Decorator for Tests. + * + * TestDecorator provides an alternate means to extend functionality + * of a test class without subclassing the test. Instead, one can + * subclass the decorater and use it to wrap the test class. + * + * Does not assume ownership of the test it decorates + */ +class CPPUNIT_API TestDecorator : public Test +{ +public: + TestDecorator( Test *test ); + ~TestDecorator(); + + int countTestCases() const; + + std::string getName() const; + + void run( TestResult *result ); + + int getChildTestCount() const; + +protected: + Test *doGetChildTestAt( int index ) const; + + Test *m_test; + +private: + TestDecorator( const TestDecorator &); + void operator =( const TestDecorator & ); +}; + + +CPPUNIT_NS_END + +#endif + diff --git a/UnitTests/cppunit/include/cppunit/extensions/TestFactory.h b/UnitTests/cppunit/include/cppunit/extensions/TestFactory.h new file mode 100644 index 000000000..214d35349 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/extensions/TestFactory.h @@ -0,0 +1,27 @@ +#ifndef CPPUNIT_EXTENSIONS_TESTFACTORY_H +#define CPPUNIT_EXTENSIONS_TESTFACTORY_H + +#include + +CPPUNIT_NS_BEGIN + + +class Test; + +/*! \brief Abstract Test factory. + */ +class CPPUNIT_API TestFactory +{ +public: + virtual ~TestFactory() {} + + /*! Makes a new test. + * \return A new Test. + */ + virtual Test* makeTest() = 0; +}; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_EXTENSIONS_TESTFACTORY_H diff --git a/UnitTests/cppunit/include/cppunit/extensions/TestFactoryRegistry.h b/UnitTests/cppunit/include/cppunit/extensions/TestFactoryRegistry.h new file mode 100644 index 000000000..fc8723e40 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/extensions/TestFactoryRegistry.h @@ -0,0 +1,182 @@ +#ifndef CPPUNIT_EXTENSIONS_TESTFACTORYREGISTRY_H +#define CPPUNIT_EXTENSIONS_TESTFACTORYREGISTRY_H + +#include + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( push ) +#pragma warning( disable: 4251) // X needs to have dll-interface to be used by clients of class Z +#endif + +#include +#include +#include + +CPPUNIT_NS_BEGIN + + +class TestSuite; + +#if CPPUNIT_NEED_DLL_DECL +// template class CPPUNIT_API std::set; +#endif + + +/*! \brief Registry for TestFactory. + * \ingroup CreatingTestSuite + * + * Notes that the registry \b DON'T assumes lifetime control for any registered tests + * anymore. + * + * The default registry is the registry returned by getRegistry() with the + * default name parameter value. + * + * To register tests, use the macros: + * - CPPUNIT_TEST_SUITE_REGISTRATION(): to add tests in the default registry. + * - CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(): to add tests in a named registry. + * + * Example 1: retreiving a suite that contains all the test registered with + * CPPUNIT_TEST_SUITE_REGISTRATION(). + * \code + * CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); + * CppUnit::TestSuite *suite = registry.makeTest(); + * \endcode + * + * Example 2: retreiving a suite that contains all the test registered with + * \link CPPUNIT_TEST_SUITE_NAMED_REGISTRATION() CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ..., "Math" )\endlink. + * \code + * CppUnit::TestFactoryRegistry &mathRegistry = CppUnit::TestFactoryRegistry::getRegistry( "Math" ); + * CppUnit::TestSuite *mathSuite = mathRegistry.makeTest(); + * \endcode + * + * Example 3: creating a test suite hierarchy composed of unnamed registration and + * named registration: + * - All Tests + * - tests registered with CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ..., "Graph" ) + * - tests registered with CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ..., "Math" ) + * - tests registered with CPPUNIT_TEST_SUITE_REGISTRATION + * + * \code + * CppUnit::TestSuite *rootSuite = new CppUnit::TestSuite( "All tests" ); + * rootSuite->addTest( CppUnit::TestFactoryRegistry::getRegistry( "Graph" ).makeTest() ); + * rootSuite->addTest( CppUnit::TestFactoryRegistry::getRegistry( "Math" ).makeTest() ); + * CppUnit::TestFactoryRegistry::getRegistry().addTestToSuite( rootSuite ); + * \endcode + * + * The same result can be obtained with: + * \code + * CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); + * registry.addRegistry( "Graph" ); + * registry.addRegistry( "Math" ); + * CppUnit::TestSuite *suite = registry.makeTest(); + * \endcode + * + * Since a TestFactoryRegistry is a TestFactory, the named registries can be + * registered in the unnamed registry, creating the hierarchy links. + * + * \see TestSuiteFactory, AutoRegisterSuite + * \see CPPUNIT_TEST_SUITE_REGISTRATION, CPPUNIT_TEST_SUITE_NAMED_REGISTRATION + */ +class CPPUNIT_API TestFactoryRegistry : public TestFactory +{ +public: + /** Constructs the registry with the specified name. + * \param name Name of the registry. It is the name of TestSuite returned by + * makeTest(). + */ + TestFactoryRegistry( std::string name ); + + /// Destructor. + virtual ~TestFactoryRegistry(); + + /** Returns a new TestSuite that contains the registered test. + * \return A new TestSuite which contains all the test added using + * registerFactory(TestFactory *). + */ + virtual Test *makeTest(); + + /** Returns a named registry. + * + * If the \a name is left to its default value, then the registry that is returned is + * the one used by CPPUNIT_TEST_SUITE_REGISTRATION(): the 'top' level registry. + * + * \param name Name of the registry to return. + * \return Registry. If the registry does not exist, it is created with the + * specified name. + */ + static TestFactoryRegistry &getRegistry( const std::string &name = "All Tests" ); + + /** Adds the registered tests to the specified suite. + * \param suite Suite the tests are added to. + */ + void addTestToSuite( TestSuite *suite ); + + /** Adds the specified TestFactory to the registry. + * + * \param factory Factory to register. + */ + void registerFactory( TestFactory *factory ); + + /*! Removes the specified TestFactory from the registry. + * + * The specified factory is not destroyed. + * \param factory Factory to remove from the registry. + * \todo Address case when trying to remove a TestRegistryFactory. + */ + void unregisterFactory( TestFactory *factory ); + + /*! Adds a registry to the registry. + * + * Convenience method to help create test hierarchy. See TestFactoryRegistry detail + * for examples of use. Calling this method is equivalent to: + * \code + * this->registerFactory( TestFactoryRegistry::getRegistry( name ) ); + * \endcode + * + * \param name Name of the registry to add. + */ + void addRegistry( const std::string &name ); + + /*! Tests if the registry is valid. + * + * This method should be used when unregistering test factory on static variable + * destruction to ensure that the registry has not been already destroyed (in + * that case there is no need to unregister the test factory). + * + * You should not concern yourself with this method unless you are writing a class + * like AutoRegisterSuite. + * + * \return \c true if the specified registry has not been destroyed, + * otherwise returns \c false. + * \see AutoRegisterSuite. + */ + static bool isValid(); + + /** Adds the specified TestFactory with a specific name (DEPRECATED). + * \param name Name associated to the factory. + * \param factory Factory to register. + * \deprecated Use registerFactory( TestFactory *) instead. + */ + void registerFactory( const std::string &name, + TestFactory *factory ); + +private: + TestFactoryRegistry( const TestFactoryRegistry © ); + void operator =( const TestFactoryRegistry © ); + +private: + typedef CppUnitSet > Factories; + Factories m_factories; + + std::string m_name; +}; + + +CPPUNIT_NS_END + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( pop ) +#endif + + +#endif // CPPUNIT_EXTENSIONS_TESTFACTORYREGISTRY_H diff --git a/UnitTests/cppunit/include/cppunit/extensions/TestFixtureFactory.h b/UnitTests/cppunit/include/cppunit/extensions/TestFixtureFactory.h new file mode 100644 index 000000000..45354c62b --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/extensions/TestFixtureFactory.h @@ -0,0 +1,50 @@ +#ifndef CPPUNIT_EXTENSIONS_TESTFIXTUREFACTORY_H +#define CPPUNIT_EXTENSIONS_TESTFIXTUREFACTORY_H + +#include + + +CPPUNIT_NS_BEGIN + + +class TestFixture; + +/*! \brief Abstract TestFixture factory (Implementation). + * + * Implementation detail. Use by HelperMacros to handle TestFixture hierarchy. + */ +class TestFixtureFactory +{ +public: + //! Creates a new TestFixture instance. + virtual TestFixture *makeFixture() =0; + + virtual ~TestFixtureFactory() {} +}; + + +/*! \brief Concret TestFixture factory (Implementation). + * + * Implementation detail. Use by HelperMacros to handle TestFixture hierarchy. + */ +template +class ConcretTestFixtureFactory : public CPPUNIT_NS::TestFixtureFactory +{ + /*! \brief Returns a new TestFixture instance. + * \return A new fixture instance. The fixture instance is returned by + * the TestFixtureFactory passed on construction. The actual type + * is that of the fixture on which the static method suite() + * was called. + */ + TestFixture *makeFixture() + { + return new TestFixtureType(); + } +}; + + +CPPUNIT_NS_END + + +#endif // CPPUNIT_EXTENSIONS_TESTFIXTUREFACTORY_H + diff --git a/UnitTests/cppunit/include/cppunit/extensions/TestNamer.h b/UnitTests/cppunit/include/cppunit/extensions/TestNamer.h new file mode 100644 index 000000000..5a6471c0c --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/extensions/TestNamer.h @@ -0,0 +1,89 @@ +#ifndef CPPUNIT_EXTENSIONS_TESTNAMER_H +#define CPPUNIT_EXTENSIONS_TESTNAMER_H + +#include +#include + +#if CPPUNIT_HAVE_RTTI +# include +#endif + + + +/*! \def CPPUNIT_TESTNAMER_DECL( variableName, FixtureType ) + * \brief Declares a TestNamer. + * + * Declares a TestNamer for the specified type, using RTTI if enabled, otherwise + * using macro string expansion. + * + * RTTI is used if CPPUNIT_USE_TYPEINFO_NAME is defined and not null. + * + * \code + * void someMethod() + * { + * CPPUNIT_TESTNAMER_DECL( namer, AFixtureType ); + * std::string fixtureName = namer.getFixtureName(); + * ... + * \endcode + * + * \relates TestNamer + * \see TestNamer + */ +#if CPPUNIT_USE_TYPEINFO_NAME +# define CPPUNIT_TESTNAMER_DECL( variableName, FixtureType ) \ + CPPUNIT_NS::TestNamer variableName( typeid(FixtureType) ) +#else +# define CPPUNIT_TESTNAMER_DECL( variableName, FixtureType ) \ + CPPUNIT_NS::TestNamer variableName( std::string(#FixtureType) ) +#endif + + + +CPPUNIT_NS_BEGIN + + +/*! \brief Names a test or a fixture suite. + * + * TestNamer is usually instantiated using CPPUNIT_TESTNAMER_DECL. + * + */ +class CPPUNIT_API TestNamer +{ +public: +#if CPPUNIT_HAVE_RTTI + /*! \brief Constructs a namer using the fixture's type-info. + * \param typeInfo Type-info of the fixture type. Use to name the fixture suite. + */ + TestNamer( const std::type_info &typeInfo ); +#endif + + /*! \brief Constructs a namer using the specified fixture name. + * \param fixtureName Name of the fixture suite. Usually extracted using a macro. + */ + TestNamer( const std::string &fixtureName ); + + virtual ~TestNamer(); + + /*! \brief Returns the name of the fixture. + * \return Name of the fixture. + */ + virtual std::string getFixtureName() const; + + /*! \brief Returns the name of the test for the specified method. + * \param testMethodName Name of the method that implements a test. + * \return A string that is the concatenation of the test fixture name + * (returned by getFixtureName()) and\a testMethodName, + * separated using '::'. This provides a fairly unique name for a given + * test. + */ + virtual std::string getTestNameFor( const std::string &testMethodName ) const; + +protected: + std::string m_fixtureName; +}; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_EXTENSIONS_TESTNAMER_H + diff --git a/UnitTests/cppunit/include/cppunit/extensions/TestSetUp.h b/UnitTests/cppunit/include/cppunit/extensions/TestSetUp.h new file mode 100644 index 000000000..f2128ecd7 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/extensions/TestSetUp.h @@ -0,0 +1,34 @@ +#ifndef CPPUNIT_EXTENSIONS_TESTSETUP_H +#define CPPUNIT_EXTENSIONS_TESTSETUP_H + +#include + +CPPUNIT_NS_BEGIN + + +class Test; +class TestResult; + +/*! \brief Decorates a test by providing a specific setUp() and tearDown(). + */ +class CPPUNIT_API TestSetUp : public TestDecorator +{ +public: + TestSetUp( Test *test ); + + void run( TestResult *result ); + +protected: + virtual void setUp(); + virtual void tearDown(); + +private: + TestSetUp( const TestSetUp & ); + void operator =( const TestSetUp & ); +}; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_EXTENSIONS_TESTSETUP_H + diff --git a/UnitTests/cppunit/include/cppunit/extensions/TestSuiteBuilderContext.h b/UnitTests/cppunit/include/cppunit/extensions/TestSuiteBuilderContext.h new file mode 100644 index 000000000..db26926cd --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/extensions/TestSuiteBuilderContext.h @@ -0,0 +1,131 @@ +#ifndef CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H +#define CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H + +#include +#include +#include + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( push ) +#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z +#endif + + +CPPUNIT_NS_BEGIN + +class TestSuite; +class TestFixture; +class TestFixtureFactory; +class TestNamer; + +/*! \brief Context used when creating test suite in HelperMacros. + * + * Base class for all context used when creating test suite. The + * actual context type during test suite creation is TestSuiteBuilderContext. + * + * \sa CPPUNIT_TEST_SUITE, CPPUNIT_TEST_SUITE_ADD_TEST, + * CPPUNIT_TEST_SUITE_ADD_CUSTOM_TESTS. + */ +class CPPUNIT_API TestSuiteBuilderContextBase +{ +public: + /*! \brief Constructs a new context. + * + * You should not use this. The context is created in + * CPPUNIT_TEST_SUITE(). + */ + TestSuiteBuilderContextBase( TestSuite &suite, + const TestNamer &namer, + TestFixtureFactory &factory ); + + virtual ~TestSuiteBuilderContextBase(); + + /*! \brief Adds a test to the fixture suite. + * + * \param test Test to add to the fixture suite. Must not be \c NULL. + */ + void addTest( Test *test ); + + /*! \brief Returns the fixture name. + * \return Fixture name. It is the name used to name the fixture + * suite. + */ + std::string getFixtureName() const; + + /*! \brief Returns the name of the test for the specified method. + * + * \param testMethodName Name of the method that implements a test. + * \return A string that is the concatenation of the test fixture name + * (returned by getFixtureName()) and\a testMethodName, + * separated using '::'. This provides a fairly unique name for a given + * test. + */ + std::string getTestNameFor( const std::string &testMethodName ) const; + + /*! \brief Adds property pair. + * \param key PropertyKey string to add. + * \param value PropertyValue string to add. + */ + void addProperty( const std::string &key, + const std::string &value ); + + /*! \brief Returns property value assigned to param key. + * \param key PropertyKey string. + */ + const std::string getStringProperty( const std::string &key ) const; + +protected: + TestFixture *makeTestFixture() const; + + // Notes: we use a vector here instead of a map to work-around the + // shared std::map in dll bug in VC6. + // See http://www.dinkumware.com/vc_fixes.html for detail. + typedef std::pair Property; + typedef CppUnitVector Properties; + + TestSuite &m_suite; + const TestNamer &m_namer; + TestFixtureFactory &m_factory; + +private: + Properties m_properties; +}; + + +/*! \brief Type-sage context used when creating test suite in HelperMacros. + * + * \sa TestSuiteBuilderContextBase. + */ +template +class TestSuiteBuilderContext : public TestSuiteBuilderContextBase +{ +public: + typedef Fixture FixtureType; + + TestSuiteBuilderContext( TestSuiteBuilderContextBase &contextBase ) + : TestSuiteBuilderContextBase( contextBase ) + { + } + + /*! \brief Returns a new TestFixture instance. + * \return A new fixture instance. The fixture instance is returned by + * the TestFixtureFactory passed on construction. The actual type + * is that of the fixture on which the static method suite() + * was called. + */ + FixtureType *makeFixture() const + { + return CPPUNIT_STATIC_CAST( FixtureType *, + TestSuiteBuilderContextBase::makeTestFixture() ); + } +}; + + +CPPUNIT_NS_END + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( pop ) +#endif + +#endif // CPPUNIT_HELPER_TESTSUITEBUILDERCONTEXT_H + diff --git a/UnitTests/cppunit/include/cppunit/extensions/TestSuiteFactory.h b/UnitTests/cppunit/include/cppunit/extensions/TestSuiteFactory.h new file mode 100644 index 000000000..260b48315 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/extensions/TestSuiteFactory.h @@ -0,0 +1,27 @@ +#ifndef CPPUNIT_EXTENSIONS_TESTSUITEFACTORY_H +#define CPPUNIT_EXTENSIONS_TESTSUITEFACTORY_H + +#include + +CPPUNIT_NS_BEGIN + + + class Test; + + /*! \brief TestFactory for TestFixture that implements a static suite() method. + * \see AutoRegisterSuite. + */ + template + class TestSuiteFactory : public TestFactory + { + public: + virtual Test *makeTest() + { + return TestCaseType::suite(); + } + }; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_EXTENSIONS_TESTSUITEFACTORY_H diff --git a/UnitTests/cppunit/include/cppunit/extensions/TypeInfoHelper.h b/UnitTests/cppunit/include/cppunit/extensions/TypeInfoHelper.h new file mode 100644 index 000000000..c0ecdbc6e --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/extensions/TypeInfoHelper.h @@ -0,0 +1,33 @@ +#ifndef CPPUNIT_TYPEINFOHELPER_H +#define CPPUNIT_TYPEINFOHELPER_H + +#include + +#if CPPUNIT_HAVE_RTTI + +#include +#include + +CPPUNIT_NS_BEGIN + + + /**! \brief Helper to use type_info. + */ + class CPPUNIT_API TypeInfoHelper + { + public: + /*! \brief Get the class name of the specified type_info. + * \param info Info which the class name is extracted from. + * \return The string returned by type_info::name() without + * the "class" prefix. If the name is not prefixed + * by "class", it is returned as this. + */ + static std::string getClassName( const std::type_info &info ); + }; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_HAVE_RTTI + +#endif // CPPUNIT_TYPEINFOHELPER_H diff --git a/UnitTests/cppunit/include/cppunit/extensions/XmlInputHelper.h b/UnitTests/cppunit/include/cppunit/extensions/XmlInputHelper.h new file mode 100644 index 000000000..4f06e5be6 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/extensions/XmlInputHelper.h @@ -0,0 +1,23 @@ +#ifndef CPPUNIT_EXTENSIONS_XMLINPUTHELPER_H +#define CPPUNIT_EXTENSIONS_XMLINPUTHELPER_H + +#include + + +/*! \brief Adds a parameterized test 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(std::istream& param_in, std::istream& exp_in); + * \see CPPUNIT_TEST_SUITE. + */ +#define CPPUNIT_TEST_XML( testMethod) \ + CPPUNIT_TEST_ADD( new CppUnit::ParameterizedTestCase( \ + context.getTestNameFor( #testMethod ), \ + #testMethod, \ + &TestFixtureType::testMethod, \ + context.makeFixture(), \ + context.getStringProperty( std::string("XmlFileName") ) ) ) + + + +#endif // CPPUNIT_EXTENSIONS_XMLINPUTHELPER_H \ No newline at end of file diff --git a/UnitTests/cppunit/include/cppunit/plugin/DynamicLibraryManager.h b/UnitTests/cppunit/include/cppunit/plugin/DynamicLibraryManager.h new file mode 100644 index 000000000..d70ccde46 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/plugin/DynamicLibraryManager.h @@ -0,0 +1,121 @@ +#ifndef CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGER_H +#define CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGER_H + +#include +#include + +#if !defined(CPPUNIT_NO_TESTPLUGIN) + +CPPUNIT_NS_BEGIN + + +/*! \brief Manages dynamic libraries. + * + * The Dynamic Library Manager provides a platform independent way to work with + * dynamic library. It load a specific dynamic library, and can returns specific + * symbol exported by the dynamic library. + * + * If an error occurs, a DynamicLibraryManagerException is thrown. + * + * \internal Implementation of the OS independent methods is in + * DynamicLibraryManager.cpp. + * + * \internal Porting to a new platform: + * - Adds platform detection in config/SelectDllLoader.h. Should define a specific + * macro for that platform of the form: CPPUNIT_HAVE_XYZ_DLL_LOADER, where + * XYZ is the platform. + * - Makes a copy of UnixDynamicLibraryManager.cpp and named it after the platform. + * - Updated the 'guard' in your file (CPPUNIT_HAVE_XYZ_DLL_LOADER) so that it is + * only processed if the matching platform has been detected. + * - Change the implementation of methods doLoadLibrary(), doReleaseLibrary(), + * doFindSymbol() in your copy. Those methods usually maps directly to OS calls. + * - Adds the file to the project. + */ +class DynamicLibraryManager +{ +public: + typedef void *Symbol; + typedef void *LibraryHandle; + + /*! \brief Loads the specified library. + * \param libraryFileName Name of the library to load. + * \exception DynamicLibraryManagerException if a failure occurs while loading + * the library (fail to found or load the library). + */ + DynamicLibraryManager( const std::string &libraryFileName ); + + /// Releases the loaded library.. + ~DynamicLibraryManager(); + + /*! \brief Returns a pointer on the specified symbol exported by the library. + * \param symbol Name of the symbol exported by the library. + * \return Pointer on the symbol. Should be casted to the actual type. Never \c NULL. + * \exception DynamicLibraryManagerException if the symbol is not found. + */ + Symbol findSymbol( const std::string &symbol ); + +private: + /*! Loads the specified library. + * \param libraryName Name of the library to load. + * \exception DynamicLibraryManagerException if a failure occurs while loading + * the library (fail to found or load the library). + */ + void loadLibrary( const std::string &libraryName ); + + /*! Releases the loaded library. + * + * \warning Must NOT throw any exceptions (called from destructor). + */ + void releaseLibrary(); + + /*! Loads the specified library. + * + * May throw any exceptions (indicates failure). + * \param libraryName Name of the library to load. + * \return Handle of the loaded library. \c NULL indicates failure. + */ + LibraryHandle doLoadLibrary( const std::string &libraryName ); + + /*! Releases the loaded library. + * + * The handle of the library to free is in \c m_libraryHandle. It is never + * \c NULL. + * \warning Must NOT throw any exceptions (called from destructor). + */ + void doReleaseLibrary(); + + /*! Returns a pointer on the specified symbol exported by the library. + * + * May throw any exceptions (indicates failure). + * \param symbol Name of the symbol exported by the library. + * \return Pointer on the symbol. \c NULL indicates failure. + */ + Symbol doFindSymbol( const std::string &symbol ); + + /*! Returns detailed information about doLoadLibrary() failure. + * + * Called just after a failed call to doLoadLibrary() to get extra + * error information. + * + * \return Detailed information about the failure of the call to + * doLoadLibrary() that just failed. + */ + std::string getLastErrorDetail() const; + + /// Prevents the use of the copy constructor. + DynamicLibraryManager( const DynamicLibraryManager © ); + + /// Prevents the use of the copy operator. + void operator =( const DynamicLibraryManager © ); + +private: + LibraryHandle m_libraryHandle; + std::string m_libraryName; +}; + + +CPPUNIT_NS_END + +#endif // !defined(CPPUNIT_NO_TESTPLUGIN) + +#endif // CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGER_H diff --git a/UnitTests/cppunit/include/cppunit/plugin/DynamicLibraryManagerException.h b/UnitTests/cppunit/include/cppunit/plugin/DynamicLibraryManagerException.h new file mode 100644 index 000000000..11ebbd9da --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/plugin/DynamicLibraryManagerException.h @@ -0,0 +1,53 @@ +#ifndef CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGEREXCEPTION_H +#define CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGEREXCEPTION_H + +#include + +#if !defined(CPPUNIT_NO_TESTPLUGIN) +#include +#include + + +CPPUNIT_NS_BEGIN + + +/*! \brief Exception thrown by DynamicLibraryManager when a failure occurs. + * + * Use getCause() to know what function caused the failure. + * + */ +class DynamicLibraryManagerException : public std::runtime_error +{ +public: + enum Cause + { + /// Failed to load the dynamic library + loadingFailed =0, + /// Symbol not found in the dynamic library + symbolNotFound + }; + + /// Failed to load the dynamic library or Symbol not found in the dynamic library. + DynamicLibraryManagerException( const std::string &libraryName, + const std::string &errorDetail, + Cause cause ); + + ~DynamicLibraryManagerException() throw() + { + } + + Cause getCause() const; + + const char *what() const throw(); + +private: + std::string m_message; + Cause m_cause; +}; + + +CPPUNIT_NS_END + +#endif // !defined(CPPUNIT_NO_TESTPLUGIN) + +#endif // CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGEREXCEPTION_H diff --git a/UnitTests/cppunit/include/cppunit/plugin/PlugInManager.h b/UnitTests/cppunit/include/cppunit/plugin/PlugInManager.h new file mode 100644 index 000000000..6ecedc89b --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/plugin/PlugInManager.h @@ -0,0 +1,113 @@ +#ifndef CPPUNIT_PLUGIN_PLUGINMANAGER_H +#define CPPUNIT_PLUGIN_PLUGINMANAGER_H + +#include + +#if !defined(CPPUNIT_NO_TESTPLUGIN) + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( push ) +#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z +#endif + +#include +struct CppUnitTestPlugIn; + +CPPUNIT_NS_BEGIN + + +class DynamicLibraryManager; +class TestResult; +class XmlOutputter; + + +/*! \brief Manges TestPlugIn. + */ +class CPPUNIT_API PlugInManager +{ +public: + /*! Constructs a PlugInManager object. + */ + PlugInManager(); + + /// Destructor. + virtual ~PlugInManager(); + + /*! \brief Loads the specified plug-in. + * + * After being loaded, the CppUnitTestPlugIn::initialize() is called. + * + * \param libraryFileName Name of the file that contains the TestPlugIn. + * \param parameters List of string passed to the plug-in. + * \return Pointer on the DynamicLibraryManager associated to the library. + * Valid until the library is unloaded. Never \c NULL. + * \exception DynamicLibraryManagerException is thrown if an error occurs during loading. + */ + void load( const std::string &libraryFileName, + const PlugInParameters ¶meters = PlugInParameters() ); + + /*! \brief Unloads the specified plug-in. + * \param libraryFileName Name of the file that contains the TestPlugIn passed + * to a previous call to load(). + */ + void unload( const std::string &libraryFileName ); + + /*! \brief Gives a chance to each loaded plug-in to register TestListener. + * + * For each plug-in, call CppUnitTestPlugIn::addListener(). + */ + void addListener( TestResult *eventManager ); + + /*! \brief Gives a chance to each loaded plug-in to unregister TestListener. + * For each plug-in, call CppUnitTestPlugIn::removeListener(). + */ + void removeListener( TestResult *eventManager ); + + /*! \brief Provides a way for the plug-in to register some XmlOutputterHook. + */ + void addXmlOutputterHooks( XmlOutputter *outputter ); + + /*! \brief Called when the XmlOutputter is destroyed. + * + * Can be used to free some resources allocated by addXmlOutputterHooks(). + */ + void removeXmlOutputterHooks(); + +protected: + /*! \brief (INTERNAL) Information about a specific plug-in. + */ + struct PlugInInfo + { + std::string m_fileName; + DynamicLibraryManager *m_manager; + CppUnitTestPlugIn *m_interface; + }; + + /*! Unloads the specified plug-in. + * \param plugIn Information about the plug-in. + */ + void unload( PlugInInfo &plugIn ); + +private: + /// Prevents the use of the copy constructor. + PlugInManager( const PlugInManager © ); + + /// Prevents the use of the copy operator. + void operator =( const PlugInManager © ); + +private: + typedef CppUnitDeque PlugIns; + PlugIns m_plugIns; +}; + + +CPPUNIT_NS_END + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( pop ) +#endif + +#endif // !defined(CPPUNIT_NO_TESTPLUGIN) + + +#endif // CPPUNIT_PLUGIN_PLUGINMANAGER_H diff --git a/UnitTests/cppunit/include/cppunit/plugin/PlugInParameters.h b/UnitTests/cppunit/include/cppunit/plugin/PlugInParameters.h new file mode 100644 index 000000000..c67d0f1d2 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/plugin/PlugInParameters.h @@ -0,0 +1,36 @@ +#ifndef CPPUNIT_PLUGIN_PARAMETERS +#define CPPUNIT_PLUGIN_PARAMETERS + +#include + +#if !defined(CPPUNIT_NO_TESTPLUGIN) + +#include +#include + +CPPUNIT_NS_BEGIN + +/*! \brief Test plug-ins parameters. + */ +class CPPUNIT_API PlugInParameters +{ +public: + /// Constructs plug-in parameters from the specified command-line. + PlugInParameters( const std::string &commandLine = "" ); + + virtual ~PlugInParameters(); + + /// Returns the command line that was passed on construction. + std::string getCommandLine() const; + +private: + std::string m_commandLine; +}; + + +CPPUNIT_NS_END + +#endif // !defined(CPPUNIT_NO_TESTPLUGIN) + + +#endif // CPPUNIT_PLUGIN_PARAMETERS diff --git a/UnitTests/cppunit/include/cppunit/plugin/TestPlugIn.h b/UnitTests/cppunit/include/cppunit/plugin/TestPlugIn.h new file mode 100644 index 000000000..bd0565c0d --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/plugin/TestPlugIn.h @@ -0,0 +1,200 @@ +#ifndef CPPUNIT_PLUGIN_TESTPLUGIN +#define CPPUNIT_PLUGIN_TESTPLUGIN + +#include + +#if !defined(CPPUNIT_NO_TESTPLUGIN) + +#include + +CPPUNIT_NS_BEGIN + + +class Test; +class TestFactoryRegistry; +class TestResult; +class XmlOutputter; + +CPPUNIT_NS_END + +/*! \file + */ + + +/*! \brief Test plug-in interface. + * \ingroup WritingTestPlugIn + * + * This class define the interface implemented by test plug-in. A pointer to that + * interface is returned by the function exported by the test plug-in. + * + * Plug-in are loaded/unloaded by PlugInManager. When a plug-in is loaded, + * initialize() is called. Before unloading the plug-in, the PlugInManager + * call uninitialize(). + * + * addListener() and removeListener() are called respectively before and after + * the test run. + * + * addXmlOutputterHooks() and removeXmlOutputterHooks() are called respectively + * before and after writing the XML output using a XmlOutputter. + * + * \see CPPUNIT_PLUGIN_IMPLEMENT, CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL + * \see CppUnit::TestPlugInDefaultImpl, CppUnit::XmlOutputter. + */ +struct CPPUNIT_API CppUnitTestPlugIn +{ + /*! \brief Called just after loading the dynamic library. + * + * Override this method to add additional suite to the registry, though this + * is preferably done using the macros (CPPUNIT_TEST_SUITE_REGISTRATION...). + * If you are creating a custom listener to extends the plug-in runner, + * you can use this to configure the listener using the \a parameters. + * + * You could also use the parameters to specify some global parameter, such + * as test datas location, database name... + * + * N.B.: Parameters interface is not define yet, and the plug-in runner does + * not yet support plug-in parameter. + */ + virtual void initialize( CPPUNIT_NS::TestFactoryRegistry *registry, + const CPPUNIT_NS::PlugInParameters ¶meters ) =0; + + /*! \brief Gives a chance to the plug-in to register TestListener. + * + * Override this method to add a TestListener for the test run. This is useful + * if you are writing a custom TestListener, but also if you need to + * setUp some global resource: listen to TestListener::startTestRun(), + * and TestListener::endTestRun(). + */ + virtual void addListener( CPPUNIT_NS::TestResult *eventManager ) =0; + + /*! \brief Gives a chance to the plug-in to remove its registered TestListener. + * + * Override this method to remove a TestListener that has been added. + */ + virtual void removeListener( CPPUNIT_NS::TestResult *eventManager ) =0; + + /*! \brief Provides a way for the plug-in to register some XmlOutputterHook. + */ + virtual void addXmlOutputterHooks( CPPUNIT_NS::XmlOutputter *outputter ) =0; + + /*! \brief Called when the XmlOutputter is destroyed. + * + * Can be used to free some resources allocated by addXmlOutputterHooks(). + */ + virtual void removeXmlOutputterHooks() = 0; + + /*! \brief Called just before unloading the dynamic library. + * + * Override this method to unregister test factory added in initialize(). + * This is necessary to keep the TestFactoryRegistry 'clean'. When + * the plug-in is unloaded from memory, the TestFactoryRegistry will hold + * reference on test that are no longer available if they are not + * unregistered. + */ + virtual void uninitialize( CPPUNIT_NS::TestFactoryRegistry *registry ) =0; + + virtual ~CppUnitTestPlugIn() {} +}; + + + +/*! \brief Name of the function exported by a test plug-in. + * \ingroup WritingTestPlugIn + * + * The signature of the exported function is: + * \code + * CppUnitTestPlugIn *CPPUNIT_PLUGIN_EXPORTED_NAME(void); + * \endcode + */ +#define CPPUNIT_PLUGIN_EXPORTED_NAME cppunitTestPlugIn + +/*! \brief Type of the function exported by a plug-in. + * \ingroup WritingTestPlugIn + */ +typedef CppUnitTestPlugIn *(*TestPlugInSignature)(); + + +/*! \brief Implements the function exported by the test plug-in + * \ingroup WritingTestPlugIn + */ +#define CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL( TestPlugInInterfaceType ) \ + CPPUNIT_PLUGIN_EXPORT CppUnitTestPlugIn *CPPUNIT_PLUGIN_EXPORTED_NAME(void) \ + { \ + static TestPlugInInterfaceType plugIn; \ + return &plugIn; \ + } \ + typedef char __CppUnitPlugInExportFunctionDummyTypeDef // dummy typedef so it can end with ';' + + +// Note: This include should remain after definition of CppUnitTestPlugIn +#include + + +/*! \def CPPUNIT_PLUGIN_IMPLEMENT_MAIN() + * \brief Implements the 'main' function for the plug-in. + * + * This macros implements the main() function for dynamic library. + * For example, WIN32 requires a DllMain function, while some Unix + * requires a main() function. This macros takes care of the implementation. + */ + +// Win32 +#if defined(CPPUNIT_HAVE_WIN32_DLL_LOADER) +#if !defined(APIENTRY) +#define WIN32_LEAN_AND_MEAN +#define NOGDI +#define NOUSER +#define NOKERNEL +#define NOSOUND +#define NOMINMAX +#define BLENDFUNCTION void // for mingw & gcc +#include +#endif +#define CPPUNIT_PLUGIN_IMPLEMENT_MAIN() \ + BOOL APIENTRY DllMain( HANDLE hModule, \ + DWORD ul_reason_for_call, \ + LPVOID lpReserved ) \ + { \ + return TRUE; \ + } \ + typedef char __CppUnitPlugInImplementMainDummyTypeDef + +// Unix +#elif defined(CPPUNIT_HAVE_UNIX_DLL_LOADER) || defined(CPPUNIT_HAVE_UNIX_SHL_LOADER) +#define CPPUNIT_PLUGIN_IMPLEMENT_MAIN() \ + int main( int argc, char *argv[] ) \ + { \ + return 0; \ + } \ + typedef char __CppUnitPlugInImplementMainDummyTypeDef + + +// Other +#else // other platforms don't require anything specifics +#endif + + + +/*! \brief Implements and exports the test plug-in interface. + * \ingroup WritingTestPlugIn + * + * This macro exports the test plug-in function using the subclass, + * and implements the 'main' function for the plug-in using + * CPPUNIT_PLUGIN_IMPLEMENT_MAIN(). + * + * When using this macro, CppUnit must be linked as a DLL (shared library). + * Otherwise, tests registered to the TestFactoryRegistry in the DLL will + * not be visible to the DllPlugInTester. + * + * \see CppUnitTestPlugIn + * \see CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL(), CPPUNIT_PLUGIN_IMPLEMENT_MAIN(). + */ +#define CPPUNIT_PLUGIN_IMPLEMENT() \ + CPPUNIT_PLUGIN_EXPORTED_FUNCTION_IMPL( CPPUNIT_NS::TestPlugInDefaultImpl ); \ + CPPUNIT_PLUGIN_IMPLEMENT_MAIN() + + +#endif // !defined(CPPUNIT_NO_TESTPLUGIN) + + +#endif // CPPUNIT_PLUGIN_TESTPLUGIN diff --git a/UnitTests/cppunit/include/cppunit/plugin/TestPlugInDefaultImpl.h b/UnitTests/cppunit/include/cppunit/plugin/TestPlugInDefaultImpl.h new file mode 100644 index 000000000..8040b793d --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/plugin/TestPlugInDefaultImpl.h @@ -0,0 +1,61 @@ +#ifndef CPPUNIT_PLUGIN_TESTPLUGINADAPTER +#define CPPUNIT_PLUGIN_TESTPLUGINADAPTER + +#include + +#if !defined(CPPUNIT_NO_TESTPLUGIN) + +#include + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( push ) +#pragma warning( disable: 4251 4660 ) // X needs to have dll-interface to be used by clients of class Z +#endif + +CPPUNIT_NS_BEGIN + + +class TestSuite; + + +/*! \brief Default implementation of test plug-in interface. + * \ingroup WritingTestPlugIn + * + * Override getSuiteName() to specify the suite name. Default is "All Tests". + * + * CppUnitTestPlugIn::getTestSuite() returns a suite that contains + * all the test registered to the default test factory registry + * ( TestFactoryRegistry::getRegistry() ). + * + */ +class CPPUNIT_API TestPlugInDefaultImpl : public CppUnitTestPlugIn +{ +public: + TestPlugInDefaultImpl(); + + virtual ~TestPlugInDefaultImpl(); + + void initialize( TestFactoryRegistry *registry, + const PlugInParameters ¶meters ); + + void addListener( TestResult *eventManager ); + + void removeListener( TestResult *eventManager ); + + void addXmlOutputterHooks( XmlOutputter *outputter ); + + void removeXmlOutputterHooks(); + + void uninitialize( TestFactoryRegistry *registry ); +}; + + +CPPUNIT_NS_END + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( pop ) +#endif + +#endif // !defined(CPPUNIT_NO_TESTPLUGIN) + +#endif // CPPUNIT_PLUGIN_TESTPLUGINADAPTER diff --git a/UnitTests/cppunit/include/cppunit/portability/CppUnitDeque.h b/UnitTests/cppunit/include/cppunit/portability/CppUnitDeque.h new file mode 100644 index 000000000..bbab21f56 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/portability/CppUnitDeque.h @@ -0,0 +1,25 @@ +#ifndef CPPUNIT_PORTABILITY_CPPUNITDEQUE_H +#define CPPUNIT_PORTABILITY_CPPUNITDEQUE_H + +// The technic used is similar to the wrapper of STLPort. + +#include +#include + + +#if CPPUNIT_STD_NEED_ALLOCATOR + +template +class CppUnitDeque : public std::deque +{ +public: +}; + +#else // CPPUNIT_STD_NEED_ALLOCATOR + +#define CppUnitDeque std::deque + +#endif + +#endif // CPPUNIT_PORTABILITY_CPPUNITDEQUE_H + diff --git a/UnitTests/cppunit/include/cppunit/portability/CppUnitMap.h b/UnitTests/cppunit/include/cppunit/portability/CppUnitMap.h new file mode 100644 index 000000000..0cdc723a2 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/portability/CppUnitMap.h @@ -0,0 +1,29 @@ +#ifndef CPPUNIT_PORTABILITY_CPPUNITMAP_H +#define CPPUNIT_PORTABILITY_CPPUNITMAP_H + +// The technic used is similar to the wrapper of STLPort. + +#include +#include +#include + + +#if CPPUNIT_STD_NEED_ALLOCATOR + +template +class CppUnitMap : public std::map + ,CPPUNIT_STD_ALLOCATOR> +{ +public: +}; + +#else // CPPUNIT_STD_NEED_ALLOCATOR + +#define CppUnitMap std::map + +#endif + +#endif // CPPUNIT_PORTABILITY_CPPUNITMAP_H + diff --git a/UnitTests/cppunit/include/cppunit/portability/CppUnitSet.h b/UnitTests/cppunit/include/cppunit/portability/CppUnitSet.h new file mode 100644 index 000000000..18b8662eb --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/portability/CppUnitSet.h @@ -0,0 +1,28 @@ +#ifndef CPPUNIT_PORTABILITY_CPPUNITSET_H +#define CPPUNIT_PORTABILITY_CPPUNITSET_H + +// The technic used is similar to the wrapper of STLPort. + +#include +#include +#include + + +#if CPPUNIT_STD_NEED_ALLOCATOR + +template +class CppUnitSet : public std::set + ,CPPUNIT_STD_ALLOCATOR> +{ +public: +}; + +#else // CPPUNIT_STD_NEED_ALLOCATOR + +#define CppUnitSet std::set + +#endif + +#endif // CPPUNIT_PORTABILITY_CPPUNITSET_H + diff --git a/UnitTests/cppunit/include/cppunit/portability/CppUnitStack.h b/UnitTests/cppunit/include/cppunit/portability/CppUnitStack.h new file mode 100644 index 000000000..bc7785b03 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/portability/CppUnitStack.h @@ -0,0 +1,26 @@ +#ifndef CPPUNIT_PORTABILITY_CPPUNITSTACK_H +#define CPPUNIT_PORTABILITY_CPPUNITSTACK_H + +// The technic used is similar to the wrapper of STLPort. + +#include +#include +#include + + +#if CPPUNIT_STD_NEED_ALLOCATOR + +template +class CppUnitStack : public std::stack > +{ +public: +}; + +#else // CPPUNIT_STD_NEED_ALLOCATOR + +#define CppUnitStack std::stack + +#endif + +#endif // CPPUNIT_PORTABILITY_CPPUNITSTACK_H \ No newline at end of file diff --git a/UnitTests/cppunit/include/cppunit/portability/CppUnitVector.h b/UnitTests/cppunit/include/cppunit/portability/CppUnitVector.h new file mode 100644 index 000000000..6666a63b0 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/portability/CppUnitVector.h @@ -0,0 +1,25 @@ +#ifndef CPPUNIT_PORTABILITY_CPPUNITVECTOR_H +#define CPPUNIT_PORTABILITY_CPPUNITVECTOR_H + +// The technic used is similar to the wrapper of STLPort. + +#include +#include + + +#if CPPUNIT_STD_NEED_ALLOCATOR + +template +class CppUnitVector : public std::vector +{ +public: +}; + +#else // CPPUNIT_STD_NEED_ALLOCATOR + +#define CppUnitVector std::vector + +#endif + +#endif // CPPUNIT_PORTABILITY_CPPUNITVECTOR_H + diff --git a/UnitTests/cppunit/include/cppunit/portability/FloatingPoint.h b/UnitTests/cppunit/include/cppunit/portability/FloatingPoint.h new file mode 100644 index 000000000..e8c91b3f5 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/portability/FloatingPoint.h @@ -0,0 +1,54 @@ +#ifndef CPPUNIT_PORTABILITY_FLOATINGPOINT_H_INCLUDED +#define CPPUNIT_PORTABILITY_FLOATINGPOINT_H_INCLUDED + +#include +#include + +CPPUNIT_NS_BEGIN + +/// \brief Tests if a floating-point is a NaN. +// According to IEEE-754 floating point standard, +// (see e.g. page 8 of +// http://www.cs.berkeley.edu/~wkahan/ieee754status/ieee754.ps) +// all comparisons with NaN are false except "x != x", which is true. +// +// At least Microsoft Visual Studio 6 is known not to implement this test correctly. +// It emits the following code to test equality: +// fcomp qword ptr [nan] +// fnstsw ax // copie fp (floating-point) status register to ax +// test ah,40h // test bit 14 of ax (0x4000) => C3 of fp status register +// According to the following documentation on the x86 floating point status register, +// the C2 bit should be tested to test for NaN value. +// http://webster.cs.ucr.edu/AoA/Windows/HTML/RealArithmetic.html#1000117 +// In Microsoft Visual Studio 2003 & 2005, the test is implemented with: +// test ah,44h // Visual Studio 2005 test both C2 & C3... +// +// To work around this, a NaN is assumed to be detected if no strict ordering is found. +inline bool floatingPointIsUnordered( double x ) +{ + // x != x will detect a NaN on conformant platform + // (2.0 < x && x < 1.0) will detect a NaN on non conformant platform: + // => no ordering can be found for x. + return (x != x) || (2.0 < x && x < 1.0); +} + + +/// \brief Tests if a floating-point is finite. +/// @return \c true if x is neither a NaN, nor +inf, nor -inf, \c false otherwise. +inline int floatingPointIsFinite( double x ) +{ +#if defined(CPPUNIT_HAVE_ISFINITE) + return isfinite( x ); +#elif defined(CPPUNIT_HAVE_FINITE) + return finite( x ); +#elif defined(CPPUNIT_HAVE__FINITE) + return _finite(x); +#else + double testInf = x * 0.0; // Produce 0.0 if x is finite, a NaN otherwise. + return testInf == 0.0 && !floatingPointIsUnordered(testInf); +#endif +} + +CPPUNIT_NS_END + +#endif // CPPUNIT_PORTABILITY_FLOATINGPOINT_H_INCLUDED diff --git a/UnitTests/cppunit/include/cppunit/portability/Stream.h b/UnitTests/cppunit/include/cppunit/portability/Stream.h new file mode 100644 index 000000000..e9beb8c1b --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/portability/Stream.h @@ -0,0 +1,347 @@ +#ifndef CPPUNIT_PORTABILITY_STREAM_H_INCLUDED +#define CPPUNIT_PORTABILITY_STREAM_H_INCLUDED + +// This module define: +// Type CppUT::Stream (either std::stream or a custom type) +// Type CppUT::OStringStream (eitjer std::ostringstream, older alternate or a custom type) +// Functions stdCOut() & stdCErr() which returns a reference on cout & cerr stream (or our +// custom stream). + +#include + + +#if defined( CPPUNIT_NO_STREAM ) + +#include +#include +#include + +CPPUNIT_NS_BEGIN + +class StreamBuffer +{ +public: + virtual ~StreamBuffer() {} + + virtual void write( const char *text, unsigned int length ) = 0; + + virtual void flush() {} +}; + + +class StringStreamBuffer : public StreamBuffer +{ +public: + std::string str() const + { + return str_; + } + +public: // overridden from StreamBuffer + void write( const char *text, unsigned int length ) + { + str_.append( text, length ); + } + +private: + std::string str_; +}; + + +class FileStreamBuffer : public StreamBuffer +{ +public: + FileStreamBuffer( FILE *file ) + : file_( file ) + { + } + + FILE *file() const + { + return file_; + } + +public: // overridden from StreamBuffer + void write( const char *text, unsigned int length ) + { + if ( file_ ) + fwrite( text, sizeof(char), length, file_ ); + } + + void flush() + { + if ( file_ ) + fflush( file_ ); + } + +private: + FILE *file_; +}; + + +class OStream +{ +public: + OStream() + : buffer_( 0 ) + { + } + + OStream( StreamBuffer *buffer ) + : buffer_( buffer ) + { + } + + virtual ~OStream() + { + flush(); + } + + OStream &flush() + { + if ( buffer_ ) + buffer_->flush(); + return *this; + } + + void setBuffer( StreamBuffer *buffer ) + { + buffer_ = buffer; + } + + OStream &write( const char *text, unsigned int length ) + { + if ( buffer_ ) + buffer_->write( text, length ); + return *this; + } + + OStream &write( const char *text ) + { + return write( text, strlen(text) ); + } + + OStream &operator <<( bool v ) + { + const char *out = v ? "true" : "false"; + return write( out ); + } + + OStream &operator <<( short v ) + { + char buffer[64]; + sprintf( buffer, "%hd", v ); + return write( buffer ); + } + + OStream &operator <<( unsigned short v ) + { + char buffer[64]; + sprintf( buffer, "%hu", v ); + return write( buffer ); + } + + OStream &operator <<( int v ) + { + char buffer[64]; + sprintf( buffer, "%d", v ); + return write( buffer ); + } + + OStream &operator <<( unsigned int v ) + { + char buffer[64]; + sprintf( buffer, "%u", v ); + return write( buffer ); + } + + OStream &operator <<( long v ) + { + char buffer[64]; + sprintf( buffer, "%ld", v ); + return write( buffer ); + } + + OStream &operator <<( unsigned long v ) + { + char buffer[64]; + sprintf( buffer, "%lu", v ); + return write( buffer ); + } + + OStream &operator <<( float v ) + { + char buffer[128]; + sprintf( buffer, "%.16g", double(v) ); + return write( buffer ); + } + + OStream &operator <<( double v ) + { + char buffer[128]; + sprintf( buffer, "%.16g", v ); + return write( buffer ); + } + + OStream &operator <<( long double v ) + { + char buffer[128]; + sprintf( buffer, "%.16g", double(v) ); + return write( buffer ); + } + + OStream &operator <<( const void *v ) + { + char buffer[64]; + sprintf( buffer, "%p", v ); + return write( buffer ); + } + + OStream &operator <<( const char *v ) + { + return write( v ? v : "NULL" ); + } + + OStream &operator <<( char c ) + { + char buffer[16]; + sprintf( buffer, "%c", c ); + return write( buffer ); + } + + OStream &operator <<( const std::string &s ) + { + return write( s.c_str(), s.length() ); + } + +private: + StreamBuffer *buffer_; +}; + + +class OStringStream : public OStream +{ +public: + OStringStream() + : OStream( &buffer_ ) + { + } + + std::string str() const + { + return buffer_.str(); + } + +private: + StringStreamBuffer buffer_; +}; + + +class OFileStream : public OStream +{ +public: + OFileStream( FILE *file ) + : OStream( &buffer_ ) + , buffer_( file ) + , ownFile_( false ) + { + } + + OFileStream( const char *path ) + : OStream( &buffer_ ) + , buffer_( fopen( path, "wt" ) ) + , ownFile_( true ) + { + } + + virtual ~OFileStream() + { + if ( ownFile_ && buffer_.file() ) + fclose( buffer_.file() ); + } + +private: + FileStreamBuffer buffer_; + bool ownFile_; +}; + +inline OStream &stdCOut() +{ + static OFileStream stream( stdout ); + return stream; +} + +inline OStream &stdCErr() +{ + static OFileStream stream( stderr ); + return stream; +} + +CPPUNIT_NS_END + +#elif CPPUNIT_HAVE_SSTREAM // #if defined( CPPUNIT_NO_STREAM ) +# include +# include + + CPPUNIT_NS_BEGIN + typedef std::ostringstream OStringStream; // The standard C++ way + typedef std::ofstream OFileStream; + CPPUNIT_NS_END + + +#elif CPPUNIT_HAVE_CLASS_STRSTREAM +# include +# if CPPUNIT_HAVE_STRSTREAM +# include +# else // CPPUNIT_HAVE_STRSTREAM +# include +# endif // CPPUNIT_HAVE_CLASS_STRSTREAM + + CPPUNIT_NS_BEGIN + + class OStringStream : public std::ostrstream + { + public: + std::string str() + { +// (*this) << '\0'; +// std::string msg(std::ostrstream::str()); +// std::ostrstream::freeze(false); +// return msg; +// Alternative implementation that don't rely on freeze which is not +// available on some platforms: + return std::string( std::ostrstream::str(), pcount() ); + } + }; + + CPPUNIT_NS_END +#else // CPPUNIT_HAVE_CLASS_STRSTREAM +# error Cannot define CppUnit::OStringStream. +#endif // #if defined( CPPUNIT_NO_STREAM ) + + + +#if !defined( CPPUNIT_NO_STREAM ) + +#include + + CPPUNIT_NS_BEGIN + + typedef std::ostream OStream; + + inline OStream &stdCOut() + { + return std::cout; + } + + inline OStream &stdCErr() + { + return std::cerr; + } + + CPPUNIT_NS_END + +#endif // #if !defined( CPPUNIT_NO_STREAM ) + +#endif // CPPUNIT_PORTABILITY_STREAM_H_INCLUDED + diff --git a/UnitTests/cppunit/include/cppunit/tools/Algorithm.h b/UnitTests/cppunit/include/cppunit/tools/Algorithm.h new file mode 100644 index 000000000..e5746a2bf --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/tools/Algorithm.h @@ -0,0 +1,23 @@ +#ifndef CPPUNIT_TOOLS_ALGORITHM_H_INCLUDED +#define CPPUNIT_TOOLS_ALGORITHM_H_INCLUDED + +#include + +CPPUNIT_NS_BEGIN + +template +void +removeFromSequence( SequenceType &sequence, + const ValueType &valueToRemove ) +{ + for ( unsigned int index =0; index < sequence.size(); ++index ) + { + if ( sequence[ index ] == valueToRemove ) + sequence.erase( sequence.begin() + index ); + } +} + +CPPUNIT_NS_END + + +#endif // CPPUNIT_TOOLS_ALGORITHM_H_INCLUDED diff --git a/UnitTests/cppunit/include/cppunit/tools/StringTools.h b/UnitTests/cppunit/include/cppunit/tools/StringTools.h new file mode 100644 index 000000000..7a6b6d710 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/tools/StringTools.h @@ -0,0 +1,34 @@ +#ifndef CPPUNIT_TOOLS_STRINGTOOLS_H +#define CPPUNIT_TOOLS_STRINGTOOLS_H + +#include +#include +#include + + +CPPUNIT_NS_BEGIN + + +/*! \brief Tool functions to manipulate string. + */ +struct StringTools +{ + + typedef CppUnitVector Strings; + + static std::string CPPUNIT_API toString( int value ); + + static std::string CPPUNIT_API toString( double value ); + + static Strings CPPUNIT_API split( const std::string &text, + char separator ); + + static std::string CPPUNIT_API wrap( const std::string &text, + int wrapColumn = CPPUNIT_WRAP_COLUMN ); + +}; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_TOOLS_STRINGTOOLS_H diff --git a/UnitTests/cppunit/include/cppunit/tools/XmlDocument.h b/UnitTests/cppunit/include/cppunit/tools/XmlDocument.h new file mode 100644 index 000000000..4ee73257a --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/tools/XmlDocument.h @@ -0,0 +1,86 @@ +#ifndef CPPUNIT_TOOLS_XMLDOCUMENT_H +#define CPPUNIT_TOOLS_XMLDOCUMENT_H + +#include + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( push ) +#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z +#endif + +#include + + +CPPUNIT_NS_BEGIN + + +class XmlElement; + + +/*! \brief A XML Document. + * + * A XmlDocument represents a XML file. It holds a pointer on the root XmlElement + * of the document. It also holds the encoding and style sheet used. + * + * By default, the XML document is stand-alone and tagged with enconding "ISO-8859-1". + */ +class CPPUNIT_API XmlDocument +{ +public: + /*! \brief Constructs a XmlDocument object. + * \param encoding Encoding used in the XML file (default is Latin-1, ISO-8859-1 ). + * \param styleSheet Name of the XSL style sheet file used. If empty then no + * style sheet will be specified in the output. + */ + XmlDocument( const std::string &encoding = "", + const std::string &styleSheet = "" ); + + /// Destructor. + virtual ~XmlDocument(); + + std::string encoding() const; + void setEncoding( const std::string &encoding = "" ); + + std::string styleSheet() const; + void setStyleSheet( const std::string &styleSheet = "" ); + + bool standalone() const; + + /*! \brief set the output document as standalone or not. + * + * For the output document, specify wether it's a standalone XML + * document, or not. + * + * \param standalone if true, the output will be specified as standalone. + * if false, it will be not. + */ + void setStandalone( bool standalone ); + + void setRootElement( XmlElement *rootElement ); + XmlElement &rootElement() const; + + std::string toString() const; + +private: + /// Prevents the use of the copy constructor. + XmlDocument( const XmlDocument © ); + + /// Prevents the use of the copy operator. + void operator =( const XmlDocument © ); + +protected: + std::string m_encoding; + std::string m_styleSheet; + XmlElement *m_rootElement; + bool m_standalone; +}; + + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( pop ) +#endif + + +CPPUNIT_NS_END + +#endif // CPPUNIT_TOOLS_XMLDOCUMENT_H diff --git a/UnitTests/cppunit/include/cppunit/tools/XmlElement.h b/UnitTests/cppunit/include/cppunit/tools/XmlElement.h new file mode 100644 index 000000000..0b36bd238 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/tools/XmlElement.h @@ -0,0 +1,149 @@ +#ifndef CPPUNIT_TOOLS_XMLELEMENT_H +#define CPPUNIT_TOOLS_XMLELEMENT_H + +#include + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( push ) +#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z +#endif + +#include +#include + + +CPPUNIT_NS_BEGIN + + +class XmlElement; + +#if CPPUNIT_NEED_DLL_DECL +// template class CPPUNIT_API std::deque; +#endif + + +/*! \brief A XML Element. + * + * A XML element has: + * - a name, specified on construction, + * - a content, specified on construction (may be empty), + * - zero or more attributes, added with addAttribute(), + * - zero or more child elements, added with addElement(). + */ +class CPPUNIT_API XmlElement +{ +public: + /*! \brief Constructs an element with the specified name and string content. + * \param elementName Name of the element. Must not be empty. + * \param content Content of the element. + */ + XmlElement( std::string elementName, + std::string content ="" ); + + /*! \brief Constructs an element with the specified name and numeric content. + * \param elementName Name of the element. Must not be empty. + * \param numericContent Content of the element. + */ + XmlElement( std::string elementName, + int numericContent ); + + /*! \brief Destructs the element and its child elements. + */ + virtual ~XmlElement(); + + /*! \brief Returns the name of the element. + * \return Name of the element. + */ + std::string name() const; + + /*! \brief Returns the content of the element. + * \return Content of the element. + */ + std::string content() const; + + /*! \brief Sets the name of the element. + * \param name New name for the element. + */ + void setName( const std::string &name ); + + /*! \brief Sets the content of the element. + * \param content New content for the element. + */ + void setContent( const std::string &content ); + + /*! \overload void setContent( const std::string &content ) + */ + void setContent( int numericContent ); + + /*! \brief Adds an attribute with the specified string value. + * \param attributeName Name of the attribute. Must not be an empty. + * \param value Value of the attribute. + */ + void addAttribute( std::string attributeName, + std::string value ); + + /*! \brief Adds an attribute with the specified numeric value. + * \param attributeName Name of the attribute. Must not be empty. + * \param numericValue Numeric value of the attribute. + */ + void addAttribute( std::string attributeName, + int numericValue ); + + /*! \brief Adds a child element to the element. + * \param element Child element to add. Must not be \c NULL. + */ + void addElement( XmlElement *element ); + + /*! \brief Returns the number of child elements. + * \return Number of child elements (element added with addElement()). + */ + int elementCount() const; + + /*! \brief Returns the child element at the specified index. + * \param index Zero based index of the element to return. + * \returns Element at the specified index. Never \c NULL. + * \exception std::invalid_argument if \a index < 0 or index >= elementCount(). + */ + XmlElement *elementAt( int index ) const; + + /*! \brief Returns the first child element with the specified name. + * \param name Name of the child element to return. + * \return First child element found which is named \a name. + * \exception std::invalid_argument if there is no child element with the specified + * name. + */ + XmlElement *elementFor( const std::string &name ) const; + + /*! \brief Returns a XML string that represents the element. + * \param indent String of spaces representing the amount of 'indent'. + * \return XML string that represents the element, its attributes and its + * child elements. + */ + std::string toString( const std::string &indent = "" ) const; + +private: + typedef std::pair Attribute; + + std::string attributesAsString() const; + std::string escape( std::string value ) const; + +private: + std::string m_name; + std::string m_content; + + typedef CppUnitDeque Attributes; + Attributes m_attributes; + + typedef CppUnitDeque Elements; + Elements m_elements; +}; + + +CPPUNIT_NS_END + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( pop ) +#endif + + +#endif // CPPUNIT_TOOLS_XMLELEMENT_H diff --git a/UnitTests/cppunit/include/cppunit/ui/text/TestRunner.h b/UnitTests/cppunit/include/cppunit/ui/text/TestRunner.h new file mode 100644 index 000000000..023eb8348 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/ui/text/TestRunner.h @@ -0,0 +1,24 @@ +#ifndef CPPUNIT_UI_TEXT_TESTRUNNER_H +#define CPPUNIT_UI_TEXT_TESTRUNNER_H + +#include + + +#if defined(CPPUNIT_HAVE_NAMESPACES) + +CPPUNIT_NS_BEGIN +namespace TextUi +{ + + /*! Text TestRunner (DEPRECATED). + * \deprecated Use TextTestRunner instead. + */ + typedef TextTestRunner TestRunner; + +} +CPPUNIT_NS_END + +#endif // defined(CPPUNIT_HAVE_NAMESPACES) + + +#endif // CPPUNIT_UI_TEXT_TESTRUNNER_H diff --git a/UnitTests/cppunit/include/cppunit/ui/text/TextTestRunner.h b/UnitTests/cppunit/include/cppunit/ui/text/TextTestRunner.h new file mode 100644 index 000000000..86da4d4b3 --- /dev/null +++ b/UnitTests/cppunit/include/cppunit/ui/text/TextTestRunner.h @@ -0,0 +1,97 @@ +#ifndef CPPUNIT_UI_TEXT_TEXTTESTRUNNER_H +#define CPPUNIT_UI_TEXT_TEXTTESTRUNNER_H + + +#include +#include +#include + +CPPUNIT_NS_BEGIN + + +class Outputter; +class Test; +class TestSuite; +class TextOutputter; +class TestResult; +class TestResultCollector; + + + +/*! + * \brief A text mode test runner. + * \ingroup WritingTestResult + * \ingroup ExecutingTest + * + * The test runner manage the life cycle of the added tests. + * + * The test runner can run only one of the added tests or all the tests. + * + * TestRunner prints out a trace as the tests are executed followed by a + * summary at the end. The trace and summary print are optional. + * + * Here is an example of use: + * + * \code + * CppUnit::TextTestRunner runner; + * runner.addTest( ExampleTestCase::suite() ); + * runner.run( "", true ); // Run all tests and wait + * \endcode + * + * The trace is printed using a TextTestProgressListener. The summary is printed + * using a TextOutputter. + * + * You can specify an alternate Outputter at construction + * or later with setOutputter(). + * + * After construction, you can register additional TestListener to eventManager(), + * for a custom progress trace, for example. + * + * \code + * CppUnit::TextTestRunner runner; + * runner.addTest( ExampleTestCase::suite() ); + * runner.setOutputter( CppUnit::CompilerOutputter::defaultOutputter( + * &runner.result(), + * std::cerr ) ); + * MyCustomProgressTestListener progress; + * runner.eventManager().addListener( &progress ); + * runner.run( "", true ); // Run all tests and wait + * \endcode + * + * \see CompilerOutputter, XmlOutputter, TextOutputter. + */ +class CPPUNIT_API TextTestRunner : public CPPUNIT_NS::TestRunner +{ +public: + TextTestRunner( Outputter *outputter =NULL ); + + virtual ~TextTestRunner(); + + bool run( std::string testPath ="", + bool doWait = false, + bool doPrintResult = true, + bool doPrintProgress = true ); + + void setOutputter( Outputter *outputter ); + + TestResultCollector &result() const; + + TestResult &eventManager() const; + +public: // overridden from TestRunner (to avoid hidden virtual function warning) + virtual void run( TestResult &controller, + const std::string &testPath = "" ); + +protected: + virtual void wait( bool doWait ); + virtual void printResult( bool doPrintResult ); + + TestResultCollector *m_result; + TestResult *m_eventManager; + Outputter *m_outputter; +}; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_UI_TEXT_TEXTTESTRUNNER_H diff --git a/UnitTests/cppunit/src/cppunit/AdditionalMessage.cpp b/UnitTests/cppunit/src/cppunit/AdditionalMessage.cpp new file mode 100644 index 000000000..9f3da1392 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/AdditionalMessage.cpp @@ -0,0 +1,41 @@ +#include + + +CPPUNIT_NS_BEGIN + + +AdditionalMessage::AdditionalMessage() +{ +} + + +AdditionalMessage::AdditionalMessage( const std::string &detail1 ) +{ + if ( !detail1.empty() ) + addDetail( detail1 ); +} + + +AdditionalMessage::AdditionalMessage( const char *detail1 ) +{ + if ( detail1 && !std::string( detail1 ).empty() ) + addDetail( std::string(detail1) ); +} + + +AdditionalMessage::AdditionalMessage( const Message &other ) + : SuperClass( other ) +{ +} + + +AdditionalMessage & +AdditionalMessage::operator =( const Message &other ) +{ + SuperClass::operator =( other ); + + return *this; +} + + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/Asserter.cpp b/UnitTests/cppunit/src/cppunit/Asserter.cpp new file mode 100644 index 000000000..a9cf95cb4 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/Asserter.cpp @@ -0,0 +1,101 @@ +#include +#include +#include + + +CPPUNIT_NS_BEGIN + + +void +Asserter::fail( std::string message, + const SourceLine &sourceLine ) +{ + fail( Message( "assertion failed", message ), sourceLine ); +} + + +void +Asserter::fail( const Message &message, + const SourceLine &sourceLine ) +{ + throw Exception( message, sourceLine ); +} + + +void +Asserter::failIf( bool shouldFail, + const Message &message, + const SourceLine &sourceLine ) +{ + if ( shouldFail ) + fail( message, sourceLine ); +} + + +void +Asserter::failIf( bool shouldFail, + std::string message, + const SourceLine &sourceLine ) +{ + failIf( shouldFail, Message( "assertion failed", message ), sourceLine ); +} + + +std::string +Asserter::makeExpected( const std::string &expectedValue ) +{ + return "Expected: " + expectedValue; +} + + +std::string +Asserter::makeActual( const std::string &actualValue ) +{ + return "Actual : " + actualValue; +} + + +Message +Asserter::makeNotEqualMessage( const std::string &expectedValue, + const std::string &actualValue, + const AdditionalMessage &additionalMessage, + const std::string &shortDescription ) +{ + Message message( shortDescription, + makeExpected( expectedValue ), + makeActual( actualValue ) ); + message.addDetail( additionalMessage ); + + return message; +} + + +void +Asserter::failNotEqual( std::string expected, + std::string actual, + const SourceLine &sourceLine, + const AdditionalMessage &additionalMessage, + std::string shortDescription ) +{ + fail( makeNotEqualMessage( expected, + actual, + additionalMessage, + shortDescription ), + sourceLine ); +} + + +void +Asserter::failNotEqualIf( bool shouldFail, + std::string expected, + std::string actual, + const SourceLine &sourceLine, + const AdditionalMessage &additionalMessage, + std::string shortDescription ) +{ + if ( shouldFail ) + failNotEqual( expected, actual, sourceLine, additionalMessage, shortDescription ); +} + + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/BeOsDynamicLibraryManager.cpp b/UnitTests/cppunit/src/cppunit/BeOsDynamicLibraryManager.cpp new file mode 100644 index 000000000..b8568be0c --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/BeOsDynamicLibraryManager.cpp @@ -0,0 +1,49 @@ +#include + +#if defined(CPPUNIT_HAVE_BEOS_DLL_LOADER) +#include + +#include + + +CPPUNIT_NS_BEGIN + + +DynamicLibraryManager::LibraryHandle +DynamicLibraryManager::doLoadLibrary( const std::string &libraryName ) +{ + return (LibraryHandle)::load_add_on( libraryName.c_str() ); +} + + +void +DynamicLibraryManager::doReleaseLibrary() +{ + ::unload_add_on( (image_id)m_libraryHandle ); +} + + +DynamicLibraryManager::Symbol +DynamicLibraryManager::doFindSymbol( const std::string &symbol ) +{ + void *symbolPointer; + if ( ::get_image_symbol( (image_id)m_libraryHandle, + symbol.c_str(), + B_SYMBOL_TYPE_TEXT, + &symbolPointer ) == B_OK ) + return symnolPointer; + return NULL; +} + + +std::string +DynamicLibraryManager::getLastErrorDetail() const +{ + return ""; +} + + +CPPUNIT_NS_END + + +#endif // defined(CPPUNIT_HAVE_BEOS_DLL_LOADER) diff --git a/UnitTests/cppunit/src/cppunit/BriefTestProgressListener.cpp b/UnitTests/cppunit/src/cppunit/BriefTestProgressListener.cpp new file mode 100644 index 000000000..4ea8d35da --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/BriefTestProgressListener.cpp @@ -0,0 +1,49 @@ +#include +#include +#include +#include + + +CPPUNIT_NS_BEGIN + + +BriefTestProgressListener::BriefTestProgressListener() + : m_lastTestFailed( false ) +{ +} + + +BriefTestProgressListener::~BriefTestProgressListener() +{ +} + + +void +BriefTestProgressListener::startTest( Test *test ) +{ + stdCOut() << test->getName(); + stdCOut().flush(); + + m_lastTestFailed = false; +} + + +void +BriefTestProgressListener::addFailure( const TestFailure &failure ) +{ + stdCOut() << " : " << (failure.isError() ? "error" : "assertion"); + m_lastTestFailed = true; +} + + +void +BriefTestProgressListener::endTest( Test * ) +{ + if ( !m_lastTestFailed ) + stdCOut() << " : OK"; + stdCOut() << "\n"; +} + + +CPPUNIT_NS_END + diff --git a/UnitTests/cppunit/src/cppunit/CompilerOutputter.cpp b/UnitTests/cppunit/src/cppunit/CompilerOutputter.cpp new file mode 100644 index 000000000..8196a5f87 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/CompilerOutputter.cpp @@ -0,0 +1,216 @@ +#include +#include +#include +#include +#include +#include +#include +#include + + +CPPUNIT_NS_BEGIN + + +CompilerOutputter::CompilerOutputter( TestResultCollector *result, + OStream &stream, + const std::string &locationFormat ) + : m_result( result ) + , m_stream( stream ) + , m_locationFormat( locationFormat ) + , m_wrapColumn( CPPUNIT_WRAP_COLUMN ) +{ +} + + +CompilerOutputter::~CompilerOutputter() +{ +} + + +void +CompilerOutputter::setLocationFormat( const std::string &locationFormat ) +{ + m_locationFormat = locationFormat; +} + + +CompilerOutputter * +CompilerOutputter::defaultOutputter( TestResultCollector *result, + OStream &stream ) +{ + return new CompilerOutputter( result, stream ); +} + + +void +CompilerOutputter::write() +{ + if ( m_result->wasSuccessful() ) + printSuccess(); + else + printFailureReport(); +} + + +void +CompilerOutputter::printSuccess() +{ + m_stream << "OK (" << m_result->runTests() << ")\n"; +} + + +void +CompilerOutputter::printFailureReport() +{ + printFailuresList(); + printStatistics(); +} + + +void +CompilerOutputter::printFailuresList() +{ + for ( int index =0; index < m_result->testFailuresTotal(); ++index) + { + printFailureDetail( m_result->failures()[ index ] ); + } +} + + +void +CompilerOutputter::printFailureDetail( TestFailure *failure ) +{ + printFailureLocation( failure->sourceLine() ); + printFailureType( failure ); + printFailedTestName( failure ); + printFailureMessage( failure ); +} + + +void +CompilerOutputter::printFailureLocation( SourceLine sourceLine ) +{ + if ( !sourceLine.isValid() ) + { + m_stream << "##Failure Location unknown## : "; + return; + } + + std::string location; + for ( unsigned int index = 0; index < m_locationFormat.length(); ++index ) + { + char c = m_locationFormat[ index ]; + if ( c == '%' && ( index+1 < m_locationFormat.length() ) ) + { + char command = m_locationFormat[index+1]; + if ( processLocationFormatCommand( command, sourceLine ) ) + { + ++index; + continue; + } + } + + m_stream << c; + } +} + + +bool +CompilerOutputter::processLocationFormatCommand( char command, + const SourceLine &sourceLine ) +{ + switch ( command ) + { + case 'p': + m_stream << sourceLine.fileName(); + return true; + case 'l': + m_stream << sourceLine.lineNumber(); + return true; + case 'f': + m_stream << extractBaseName( sourceLine.fileName() ); + return true; + } + + return false; +} + + +std::string +CompilerOutputter::extractBaseName( const std::string &fileName ) const +{ + int indexLastDirectorySeparator = fileName.find_last_of( '/' ); + + if ( indexLastDirectorySeparator < 0 ) + indexLastDirectorySeparator = fileName.find_last_of( '\\' ); + + if ( indexLastDirectorySeparator < 0 ) + return fileName; + + return fileName.substr( indexLastDirectorySeparator +1 ); +} + + +void +CompilerOutputter::printFailureType( TestFailure *failure ) +{ + m_stream << (failure->isError() ? "Error" : "Assertion"); +} + + +void +CompilerOutputter::printFailedTestName( TestFailure *failure ) +{ + m_stream << "\nTest name: " << failure->failedTestName(); +} + + +void +CompilerOutputter::printFailureMessage( TestFailure *failure ) +{ + m_stream << "\n"; + Exception *thrownException = failure->thrownException(); + m_stream << thrownException->message().shortDescription() << "\n"; + + std::string message = thrownException->message().details(); + if ( m_wrapColumn > 0 ) + message = StringTools::wrap( message, m_wrapColumn ); + + m_stream << message << "\n"; +} + + +void +CompilerOutputter::printStatistics() +{ + m_stream << "Failures !!!\n"; + m_stream << "Run: " << m_result->runTests() << " " + << "Failure total: " << m_result->testFailuresTotal() << " " + << "Failures: " << m_result->testFailures() << " " + << "Errors: " << m_result->testErrors() + << "\n"; +} + + +void +CompilerOutputter::setWrapColumn( int wrapColumn ) +{ + m_wrapColumn = wrapColumn; +} + + +void +CompilerOutputter::setNoWrap() +{ + m_wrapColumn = 0; +} + + +int +CompilerOutputter::wrapColumn() const +{ + return m_wrapColumn; +} + + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/DefaultProtector.cpp b/UnitTests/cppunit/src/cppunit/DefaultProtector.cpp new file mode 100644 index 000000000..6fb306b25 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/DefaultProtector.cpp @@ -0,0 +1,42 @@ +#include +#include +#include "DefaultProtector.h" + + +CPPUNIT_NS_BEGIN + + +bool +DefaultProtector::protect( const Functor &functor, + const ProtectorContext &context ) +{ + try + { + return functor(); + } + catch ( Exception &failure ) + { + reportFailure( context, failure ); + } + catch ( std::exception &e ) + { + std::string shortDescription( "uncaught exception of type " ); +#if CPPUNIT_USE_TYPEINFO_NAME + shortDescription += TypeInfoHelper::getClassName( typeid(e) ); +#else + shortDescription += "std::exception (or derived)."; +#endif + Message message( shortDescription, e.what() ); + reportError( context, message ); + } + catch ( ... ) + { + reportError( context, + Message( "uncaught exception of unknown type") ); + } + + return false; +} + + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/DefaultProtector.h b/UnitTests/cppunit/src/cppunit/DefaultProtector.h new file mode 100644 index 000000000..4a76ea013 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/DefaultProtector.h @@ -0,0 +1,27 @@ +#ifndef CPPUNIT_DEFAULTPROTECTOR_H +#define CPPUNIT_DEFAULTPROTECTOR_H + +#include + +CPPUNIT_NS_BEGIN + +/*! \brief Default protector that catch all exceptions (Implementation). + * + * Implementation detail. + * \internal This protector catch and generate a failure for the following + * exception types: + * - Exception + * - std::exception + * - ... + */ +class DefaultProtector : public Protector +{ +public: + bool protect( const Functor &functor, + const ProtectorContext &context ); +}; + +CPPUNIT_NS_END + +#endif // CPPUNIT_DEFAULTPROTECTOR_H + diff --git a/UnitTests/cppunit/src/cppunit/DllMain.cpp b/UnitTests/cppunit/src/cppunit/DllMain.cpp new file mode 100644 index 000000000..51fe31ece --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/DllMain.cpp @@ -0,0 +1,16 @@ +#define WIN32_LEAN_AND_MEAN +#define NOGDI +#define NOUSER +#define NOKERNEL +#define NOSOUND +#define BLENDFUNCTION void // for mingw & gcc + +#include + +BOOL APIENTRY +DllMain( HANDLE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved ) +{ + return TRUE; +} diff --git a/UnitTests/cppunit/src/cppunit/DynamicLibraryManager.cpp b/UnitTests/cppunit/src/cppunit/DynamicLibraryManager.cpp new file mode 100644 index 000000000..e6f629455 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/DynamicLibraryManager.cpp @@ -0,0 +1,77 @@ +#include + +#if !defined(CPPUNIT_NO_TESTPLUGIN) +#include + +CPPUNIT_NS_BEGIN + + +DynamicLibraryManager::DynamicLibraryManager( const std::string &libraryFileName ) + : m_libraryHandle( NULL ) + , m_libraryName( libraryFileName ) +{ + loadLibrary( libraryFileName ); +} + + +DynamicLibraryManager::~DynamicLibraryManager() +{ + releaseLibrary(); +} + + +DynamicLibraryManager::Symbol +DynamicLibraryManager::findSymbol( const std::string &symbol ) +{ + try + { + Symbol symbolPointer = doFindSymbol( symbol ); + if ( symbolPointer != NULL ) + return symbolPointer; + } + catch ( ... ) + { + } + + throw DynamicLibraryManagerException( m_libraryName, + symbol, + DynamicLibraryManagerException::symbolNotFound ); + return NULL; // keep compiler happy +} + + +void +DynamicLibraryManager::loadLibrary( const std::string &libraryName ) +{ + try + { + releaseLibrary(); + m_libraryHandle = doLoadLibrary( libraryName ); + if ( m_libraryHandle != NULL ) + return; + } + catch (...) + { + } + + throw DynamicLibraryManagerException( m_libraryName, + getLastErrorDetail(), + DynamicLibraryManagerException::loadingFailed ); +} + + +void +DynamicLibraryManager::releaseLibrary() +{ + if ( m_libraryHandle != NULL ) + { + doReleaseLibrary(); + m_libraryHandle = NULL; + } +} + + +CPPUNIT_NS_END + + +#endif // !defined(CPPUNIT_NO_TESTPLUGIN) diff --git a/UnitTests/cppunit/src/cppunit/DynamicLibraryManagerException.cpp b/UnitTests/cppunit/src/cppunit/DynamicLibraryManagerException.cpp new file mode 100644 index 000000000..8498652e0 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/DynamicLibraryManagerException.cpp @@ -0,0 +1,41 @@ +#include + +#if !defined(CPPUNIT_NO_TESTPLUGIN) + +CPPUNIT_NS_BEGIN + + +DynamicLibraryManagerException::DynamicLibraryManagerException( + const std::string &libraryName, + const std::string &errorDetail, + Cause cause ) + : std::runtime_error( "" ), + m_cause( cause ) +{ + if ( cause == loadingFailed ) + m_message = "Failed to load dynamic library: " + libraryName + "\n" + + errorDetail; + else + m_message = "Symbol [" + errorDetail + "] not found in dynamic libary:" + + libraryName; +} + + +DynamicLibraryManagerException::Cause +DynamicLibraryManagerException::getCause() const +{ + return m_cause; +} + + +const char * +DynamicLibraryManagerException::what() const throw() +{ + return m_message.c_str(); +} + + +CPPUNIT_NS_END + + +#endif // !defined(CPPUNIT_NO_TESTPLUGIN) diff --git a/UnitTests/cppunit/src/cppunit/Exception.cpp b/UnitTests/cppunit/src/cppunit/Exception.cpp new file mode 100644 index 000000000..3bbe24b9b --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/Exception.cpp @@ -0,0 +1,126 @@ +#include + + +CPPUNIT_NS_BEGIN + + +#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED +/*! + * \deprecated Use SourceLine::isValid() instead. + */ +const std::string Exception::UNKNOWNFILENAME = ""; + +/*! + * \deprecated Use SourceLine::isValid() instead. + */ +const long Exception::UNKNOWNLINENUMBER = -1; +#endif + + +Exception::Exception( const Exception &other ) + : std::exception( other ) +{ + m_message = other.m_message; + m_sourceLine = other.m_sourceLine; +} + + +Exception::Exception( const Message &message, + const SourceLine &sourceLine ) + : m_message( message ) + , m_sourceLine( sourceLine ) +{ +} + + +#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED +Exception::Exception( std::string message, + long lineNumber, + std::string fileName ) + : m_message( message ) + , m_sourceLine( fileName, lineNumber ) +{ +} +#endif + + +Exception::~Exception() throw() +{ +} + + +Exception & +Exception::operator =( const Exception& other ) +{ +// Don't call superclass operator =(). VC++ STL implementation +// has a bug. It calls the destructor and copy constructor of +// std::exception() which reset the virtual table to std::exception. +// SuperClass::operator =(other); + + if ( &other != this ) + { + m_message = other.m_message; + m_sourceLine = other.m_sourceLine; + } + + return *this; +} + + +const char* +Exception::what() const throw() +{ + Exception *mutableThis = CPPUNIT_CONST_CAST( Exception *, this ); + mutableThis->m_whatMessage = m_message.shortDescription() + "\n" + + m_message.details(); + return m_whatMessage.c_str(); +} + + +SourceLine +Exception::sourceLine() const +{ + return m_sourceLine; +} + + +Message +Exception::message() const +{ + return m_message; +} + + +void +Exception::setMessage( const Message &message ) +{ + m_message = message; +} + + +#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED +long +Exception::lineNumber() const +{ + return m_sourceLine.isValid() ? m_sourceLine.lineNumber() : + UNKNOWNLINENUMBER; +} + + +std::string +Exception::fileName() const +{ + return m_sourceLine.isValid() ? m_sourceLine.fileName() : + UNKNOWNFILENAME; +} +#endif + + +Exception * +Exception::clone() const +{ + return new Exception( *this ); +} + + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/Message.cpp b/UnitTests/cppunit/src/cppunit/Message.cpp new file mode 100644 index 000000000..9d6a0e92b --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/Message.cpp @@ -0,0 +1,170 @@ +#include +#include + + +CPPUNIT_NS_BEGIN + + +Message::Message() +{ +} + +Message::Message( const Message &other ) +{ + *this = other; +} + + +Message::Message( const std::string &shortDescription ) + : m_shortDescription( shortDescription ) +{ +} + + +Message::Message( const std::string &shortDescription, + const std::string &detail1 ) + : m_shortDescription( shortDescription ) +{ + addDetail( detail1 ); +} + + +Message::Message( const std::string &shortDescription, + const std::string &detail1, + const std::string &detail2 ) + : m_shortDescription( shortDescription ) +{ + addDetail( detail1, detail2 ); +} + + +Message::Message( const std::string &shortDescription, + const std::string &detail1, + const std::string &detail2, + const std::string &detail3 ) + : m_shortDescription( shortDescription ) +{ + addDetail( detail1, detail2, detail3 ); +} + +Message & +Message::operator =( const Message &other ) +{ + if ( this != &other ) + { + m_shortDescription = other.m_shortDescription.c_str(); + m_details.clear(); + Details::const_iterator it = other.m_details.begin(); + Details::const_iterator itEnd = other.m_details.end(); + while ( it != itEnd ) + m_details.push_back( (*it++).c_str() ); + } + + return *this; +} + + +const std::string & +Message::shortDescription() const +{ + return m_shortDescription; +} + + +int +Message::detailCount() const +{ + return m_details.size(); +} + + +std::string +Message::detailAt( int index ) const +{ + if ( index < 0 || index >= detailCount() ) + throw std::invalid_argument( "Message::detailAt() : invalid index" ); + + return m_details[ index ]; +} + + +std::string +Message::details() const +{ + std::string details; + for ( Details::const_iterator it = m_details.begin(); it != m_details.end(); ++it ) + { + details += "- "; + details += *it; + details += '\n'; + } + return details; +} + + +void +Message::clearDetails() +{ + m_details.clear(); +} + + +void +Message::addDetail( const std::string &detail ) +{ + m_details.push_back( detail ); +} + + +void +Message::addDetail( const std::string &detail1, + const std::string &detail2 ) +{ + addDetail( detail1 ); + addDetail( detail2 ); +} + + +void +Message::addDetail( const std::string &detail1, + const std::string &detail2, + const std::string &detail3 ) +{ + addDetail( detail1, detail2 ); + addDetail( detail3 ); +} + + +void +Message::addDetail( const Message &message ) +{ + m_details.insert( m_details.end(), + message.m_details.begin(), + message.m_details.end() ); +} + + +void +Message::setShortDescription( const std::string &shortDescription ) +{ + m_shortDescription = shortDescription; +} + + +bool +Message::operator ==( const Message &other ) const +{ + return m_shortDescription == other.m_shortDescription && + m_details == other.m_details; +} + + +bool +Message::operator !=( const Message &other ) const +{ + return !( *this == other ); +} + + +CPPUNIT_NS_END + diff --git a/UnitTests/cppunit/src/cppunit/PlugInManager.cpp b/UnitTests/cppunit/src/cppunit/PlugInManager.cpp new file mode 100644 index 000000000..b595deefb --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/PlugInManager.cpp @@ -0,0 +1,110 @@ +#include +#include + +#if !defined(CPPUNIT_NO_TESTPLUGIN) +#include +#include +#include +#include + + +CPPUNIT_NS_BEGIN + + +PlugInManager::PlugInManager() +{ +} + + +PlugInManager::~PlugInManager() +{ + for ( PlugIns::iterator it = m_plugIns.begin(); it != m_plugIns.end(); ++it ) + unload( *it ); +} + + +void +PlugInManager::load( const std::string &libraryFileName, + const PlugInParameters ¶meters ) +{ + PlugInInfo info; + info.m_fileName = libraryFileName; + info.m_manager = new DynamicLibraryManager( libraryFileName ); + + TestPlugInSignature plug = (TestPlugInSignature)info.m_manager->findSymbol( + CPPUNIT_STRINGIZE( CPPUNIT_PLUGIN_EXPORTED_NAME ) ); + info.m_interface = (*plug)(); + + m_plugIns.push_back( info ); + + info.m_interface->initialize( &TestFactoryRegistry::getRegistry(), parameters ); +} + + +void +PlugInManager::unload( const std::string &libraryFileName ) +{ + for ( PlugIns::iterator it = m_plugIns.begin(); it != m_plugIns.end(); ++it ) + { + if ( (*it).m_fileName == libraryFileName ) + { + unload( *it ); + m_plugIns.erase( it ); + break; + } + } +} + + +void +PlugInManager::addListener( TestResult *eventManager ) +{ + for ( PlugIns::iterator it = m_plugIns.begin(); it != m_plugIns.end(); ++it ) + (*it).m_interface->addListener( eventManager ); +} + + +void +PlugInManager::removeListener( TestResult *eventManager ) +{ + for ( PlugIns::iterator it = m_plugIns.begin(); it != m_plugIns.end(); ++it ) + (*it).m_interface->removeListener( eventManager ); +} + + +void +PlugInManager::unload( PlugInInfo &plugIn ) +{ + try + { + plugIn.m_interface->uninitialize( &TestFactoryRegistry::getRegistry() ); + delete plugIn.m_manager; + } + catch (...) + { + delete plugIn.m_manager; + plugIn.m_manager = NULL; + throw; + } +} + + +void +PlugInManager::addXmlOutputterHooks( XmlOutputter *outputter ) +{ + for ( PlugIns::iterator it = m_plugIns.begin(); it != m_plugIns.end(); ++it ) + (*it).m_interface->addXmlOutputterHooks( outputter ); +} + + +void +PlugInManager::removeXmlOutputterHooks() +{ + for ( PlugIns::iterator it = m_plugIns.begin(); it != m_plugIns.end(); ++it ) + (*it).m_interface->removeXmlOutputterHooks(); +} + + +CPPUNIT_NS_END + +#endif // !defined(CPPUNIT_NO_TESTPLUGIN) diff --git a/UnitTests/cppunit/src/cppunit/PlugInParameters.cpp b/UnitTests/cppunit/src/cppunit/PlugInParameters.cpp new file mode 100644 index 000000000..1b532f9fa --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/PlugInParameters.cpp @@ -0,0 +1,28 @@ +#include + +#if !defined(CPPUNIT_NO_TESTPLUGIN) + +CPPUNIT_NS_BEGIN + + +PlugInParameters::PlugInParameters( const std::string &commandLine ) + : m_commandLine( commandLine ) +{ +} + + +PlugInParameters::~PlugInParameters() +{ +} + + +std::string +PlugInParameters::getCommandLine() const +{ + return m_commandLine; +} + + +CPPUNIT_NS_END + +#endif // !defined(CPPUNIT_NO_TESTPLUGIN) diff --git a/UnitTests/cppunit/src/cppunit/Protector.cpp b/UnitTests/cppunit/src/cppunit/Protector.cpp new file mode 100644 index 000000000..5c171ec46 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/Protector.cpp @@ -0,0 +1,86 @@ +#include +#include +#include +#include +#include "ProtectorContext.h" +#include + +CPPUNIT_NS_BEGIN + +Functor::~Functor() +{ +} + + +Protector::~Protector() +{ +} + + +void +Protector::reportError( const ProtectorContext &context, + const Exception &error ) const +{ + std::auto_ptr actualError( error.clone() ); + actualError->setMessage( actualMessage( actualError->message(), context ) ); + context.m_result->addError( context.m_test, + actualError.release() ); +} + + + +void +Protector::reportError( const ProtectorContext &context, + const Message &message, + const SourceLine &sourceLine ) const +{ + reportError( context, Exception( message, sourceLine ) ); +} + + +void +Protector::reportFailure( const ProtectorContext &context, + const Exception &failure ) const +{ + std::auto_ptr actualFailure( failure.clone() ); + actualFailure->setMessage( actualMessage( actualFailure->message(), context ) ); + context.m_result->addFailure( context.m_test, + actualFailure.release() ); +} + + +Message +Protector::actualMessage( const Message &message, + const ProtectorContext &context ) const +{ + Message theActualMessage; + if ( context.m_shortDescription.empty() ) + theActualMessage = message; + else + { + theActualMessage = Message( context.m_shortDescription, + message.shortDescription() ); + theActualMessage.addDetail( message ); + } + + return theActualMessage; +} + + + + +ProtectorGuard::ProtectorGuard( TestResult *result, + Protector *protector ) + : m_result( result ) +{ + m_result->pushProtector( protector ); +} + + +ProtectorGuard::~ProtectorGuard() +{ + m_result->popProtector(); +} + + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/ProtectorChain.cpp b/UnitTests/cppunit/src/cppunit/ProtectorChain.cpp new file mode 100644 index 000000000..f528341eb --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/ProtectorChain.cpp @@ -0,0 +1,86 @@ +#include "ProtectorChain.h" + +CPPUNIT_NS_BEGIN + + +class ProtectorChain::ProtectFunctor : public Functor +{ +public: + ProtectFunctor( Protector *protector, + const Functor &functor, + const ProtectorContext &context ) + : m_protector( protector ) + , m_functor( functor ) + , m_context( context ) + { + } + + bool operator()() const + { + return m_protector->protect( m_functor, m_context ); + } + +private: + Protector *m_protector; + const Functor &m_functor; + const ProtectorContext &m_context; +}; + + +ProtectorChain::~ProtectorChain() +{ + while ( count() > 0 ) + pop(); +} + + +void +ProtectorChain::push( Protector *protector ) +{ + m_protectors.push_back( protector ); +} + + +void +ProtectorChain::pop() +{ + delete m_protectors.back(); + m_protectors.pop_back(); +} + +int +ProtectorChain::count() const +{ + return m_protectors.size(); +} + + +bool +ProtectorChain::protect( const Functor &functor, + const ProtectorContext &context ) +{ + if ( m_protectors.empty() ) + return functor(); + + Functors functors; + for ( int index = m_protectors.size()-1; index >= 0; --index ) + { + const Functor &protectedFunctor = + functors.empty() ? functor : *functors.back(); + + functors.push_back( new ProtectFunctor( m_protectors[index], + protectedFunctor, + context ) ); + } + + const Functor &outermostFunctor = *functors.back(); + bool succeed = outermostFunctor(); + + for ( unsigned int deletingIndex = 0; deletingIndex < m_protectors.size(); ++deletingIndex ) + delete functors[deletingIndex]; + + return succeed; +} + + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/ProtectorChain.h b/UnitTests/cppunit/src/cppunit/ProtectorChain.h new file mode 100644 index 000000000..711b56fbc --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/ProtectorChain.h @@ -0,0 +1,51 @@ +#ifndef CPPUNIT_PROTECTORCHAIN_H +#define CPPUNIT_PROTECTORCHAIN_H + +#include +#include + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( push ) +#pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z +#endif + + +CPPUNIT_NS_BEGIN + +/*! \brief Protector chain (Implementation). + * Implementation detail. + * \internal Protector that protect a Functor using a chain of nested Protector. + */ +class CPPUNIT_API ProtectorChain : public Protector +{ +public: + ~ProtectorChain(); + + void push( Protector *protector ); + + void pop(); + + int count() const; + + bool protect( const Functor &functor, + const ProtectorContext &context ); + +private: + class ProtectFunctor; + +private: + typedef CppUnitDeque Protectors; + Protectors m_protectors; + + typedef CppUnitDeque Functors; +}; + + +CPPUNIT_NS_END + +#if CPPUNIT_NEED_DLL_DECL +#pragma warning( pop ) +#endif + +#endif // CPPUNIT_PROTECTORCHAIN_H + diff --git a/UnitTests/cppunit/src/cppunit/ProtectorContext.h b/UnitTests/cppunit/src/cppunit/ProtectorContext.h new file mode 100644 index 000000000..c3d496c49 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/ProtectorContext.h @@ -0,0 +1,38 @@ +#ifndef CPPUNIT_PROTECTORCONTEXT_H +#define CPPUNIT_PROTECTORCONTEXT_H + +#include +#include + +CPPUNIT_NS_BEGIN + +class Test; +class TestResult; + + +/*! \brief Protector context (Implementation). + * Implementation detail. + * \internal Context use to report failure in Protector. + */ +class CPPUNIT_API ProtectorContext +{ +public: + ProtectorContext( Test *test, + TestResult *result, + const std::string &shortDescription ) + : m_test( test ) + , m_result( result ) + , m_shortDescription( shortDescription ) + { + } + + Test *m_test; + TestResult *m_result; + std::string m_shortDescription; +}; + + +CPPUNIT_NS_END + +#endif // CPPUNIT_PROTECTORCONTEXT_H + diff --git a/UnitTests/cppunit/src/cppunit/RepeatedTest.cpp b/UnitTests/cppunit/src/cppunit/RepeatedTest.cpp new file mode 100644 index 000000000..2533ca1d9 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/RepeatedTest.cpp @@ -0,0 +1,29 @@ +#include +#include + +CPPUNIT_NS_BEGIN + + +// Counts the number of test cases that will be run by this test. +int +RepeatedTest::countTestCases() const +{ + return TestDecorator::countTestCases() * m_timesRepeat; +} + + +// Runs a repeated test +void +RepeatedTest::run( TestResult *result ) +{ + for ( int n = 0; n < m_timesRepeat; n++ ) + { + if ( result->shouldStop() ) + break; + + TestDecorator::run( result ); + } +} + + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/ShlDynamicLibraryManager.cpp b/UnitTests/cppunit/src/cppunit/ShlDynamicLibraryManager.cpp new file mode 100644 index 000000000..9f4be2277 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/ShlDynamicLibraryManager.cpp @@ -0,0 +1,53 @@ +#include + +#if defined(CPPUNIT_HAVE_UNIX_SHL_LOADER) +#include + +#include +#include + + +CPPUNIT_NS_BEGIN + + +DynamicLibraryManager::LibraryHandle +DynamicLibraryManager::doLoadLibrary( const std::string &libraryName ) +{ + return ::shl_load(libraryName.c_str(), BIND_IMMEDIATE, 0L); +} + + +void +DynamicLibraryManager::doReleaseLibrary() +{ + ::shl_unload( (shl_t)m_libraryHandle); +} + + +DynamicLibraryManager::Symbol +DynamicLibraryManager::doFindSymbol( const std::string &symbol ) +{ + DynamicLibraryManager::Symbol L_symaddr = 0; + if ( ::shl_findsym( (shl_t*)(&m_libraryHandle), + symbol.c_str(), + TYPE_UNDEFINED, + &L_symaddr ) == 0 ) + { + return L_symaddr; + } + + return 0; +} + + +std::string +DynamicLibraryManager::getLastErrorDetail() const +{ + return ""; +} + + +CPPUNIT_NS_END + + +#endif // defined(CPPUNIT_HAVE_UNIX_SHL_LOADER) diff --git a/UnitTests/cppunit/src/cppunit/SourceLine.cpp b/UnitTests/cppunit/src/cppunit/SourceLine.cpp new file mode 100644 index 000000000..dfadae3f0 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/SourceLine.cpp @@ -0,0 +1,81 @@ +#include + + +CPPUNIT_NS_BEGIN + + +SourceLine::SourceLine() : + m_lineNumber( -1 ) +{ +} + + +SourceLine::SourceLine( const SourceLine &other ) + : m_fileName( other.m_fileName.c_str() ) + , m_lineNumber( other.m_lineNumber ) +{ +} + + +SourceLine::SourceLine( const std::string &fileName, + int lineNumber ) + : m_fileName( fileName.c_str() ) + , m_lineNumber( lineNumber ) +{ +} + + +SourceLine & +SourceLine::operator =( const SourceLine &other ) +{ + if ( this != &other ) + { + m_fileName = other.m_fileName.c_str(); + m_lineNumber = other.m_lineNumber; + } + return *this; +} + + +SourceLine::~SourceLine() +{ +} + + +bool +SourceLine::isValid() const +{ + return !m_fileName.empty(); +} + + +int +SourceLine::lineNumber() const +{ + return m_lineNumber; +} + + +std::string +SourceLine::fileName() const +{ + return m_fileName; +} + + +bool +SourceLine::operator ==( const SourceLine &other ) const +{ + return m_fileName == other.m_fileName && + m_lineNumber == other.m_lineNumber; +} + + +bool +SourceLine::operator !=( const SourceLine &other ) const +{ + return !( *this == other ); +} + + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/StringTools.cpp b/UnitTests/cppunit/src/cppunit/StringTools.cpp new file mode 100644 index 000000000..dc995d8b2 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/StringTools.cpp @@ -0,0 +1,80 @@ +#include +#include +#include + + +CPPUNIT_NS_BEGIN + + +std::string +StringTools::toString( int value ) +{ + OStringStream stream; + stream << value; + return stream.str(); +} + + +std::string +StringTools::toString( double value ) +{ + OStringStream stream; + stream << value; + return stream.str(); +} + + +StringTools::Strings +StringTools::split( const std::string &text, + char separator ) +{ + Strings splittedText; + + std::string::const_iterator itStart = text.begin(); + while ( !text.empty() ) + { + std::string::const_iterator itSeparator = std::find( itStart, + text.end(), + separator ); + splittedText.push_back( text.substr( itStart - text.begin(), + itSeparator - itStart ) ); + if ( itSeparator == text.end() ) + break; + itStart = itSeparator +1; + } + + return splittedText; +} + + +std::string +StringTools::wrap( const std::string &text, + int wrapColumn ) +{ + const char lineBreak = '\n'; + Strings lines = split( text, lineBreak ); + + std::string wrapped; + for ( Strings::const_iterator it = lines.begin(); it != lines.end(); ++it ) + { + if ( it != lines.begin() ) + wrapped += lineBreak; + + const std::string &line = *it; + unsigned int index =0; + while ( index < line.length() ) + { + std::string lineSlice( line.substr( index, wrapColumn ) ); + wrapped += lineSlice; + index += wrapColumn; + if ( index < line.length() ) + wrapped += lineBreak; + } + } + + return wrapped; +} + + +CPPUNIT_NS_END + diff --git a/UnitTests/cppunit/src/cppunit/SynchronizedObject.cpp b/UnitTests/cppunit/src/cppunit/SynchronizedObject.cpp new file mode 100644 index 000000000..1764538e5 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/SynchronizedObject.cpp @@ -0,0 +1,32 @@ +#include + + +CPPUNIT_NS_BEGIN + + +SynchronizedObject::SynchronizedObject( SynchronizationObject *syncObject ) + : m_syncObject( syncObject == 0 ? new SynchronizationObject() : + syncObject ) +{ +} + + +SynchronizedObject::~SynchronizedObject() +{ + delete m_syncObject; +} + + +/** Accept a new synchronization object for protection of this instance + * TestResult assumes ownership of the object + */ +void +SynchronizedObject::setSynchronizationObject( SynchronizationObject *syncObject ) +{ + delete m_syncObject; + m_syncObject = syncObject; +} + + +CPPUNIT_NS_END + diff --git a/UnitTests/cppunit/src/cppunit/Test.cpp b/UnitTests/cppunit/src/cppunit/Test.cpp new file mode 100644 index 000000000..fef8be793 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/Test.cpp @@ -0,0 +1,97 @@ +#include +#include +#include +#include + + +CPPUNIT_NS_BEGIN + + +Test * +Test::getChildTestAt( int index ) const +{ + checkIsValidIndex( index ); + return doGetChildTestAt( index ); +} + + +Test * +Test::findTest( const std::string &testName ) const +{ + TestPath path; + Test *mutableThis = CPPUNIT_CONST_CAST( Test *, this ); + mutableThis->findTestPath( testName, path ); + if ( !path.isValid() ) + throw std::invalid_argument( "No test named <" + testName + "> found in test <" + + getName() + ">." ); + return path.getChildTest(); +} + + +bool +Test::findTestPath( const std::string &testName, + TestPath &testPath ) const +{ + Test *mutableThis = CPPUNIT_CONST_CAST( Test *, this ); + if ( getName() == testName ) + { + testPath.add( mutableThis ); + return true; + } + + int childCount = getChildTestCount(); + for ( int childIndex =0; childIndex < childCount; ++childIndex ) + { + if ( getChildTestAt( childIndex )->findTestPath( testName, testPath ) ) + { + testPath.insert( mutableThis, 0 ); + return true; + } + } + + return false; +} + + +bool +Test::findTestPath( const Test *test, + TestPath &testPath ) const +{ + Test *mutableThis = CPPUNIT_CONST_CAST( Test *, this ); + if ( this == test ) + { + testPath.add( mutableThis ); + return true; + } + + int childCount = getChildTestCount(); + for ( int childIndex =0; childIndex < childCount; ++childIndex ) + { + if ( getChildTestAt( childIndex )->findTestPath( test, testPath ) ) + { + testPath.insert( mutableThis, 0 ); + return true; + } + } + + return false; +} + + +TestPath +Test::resolveTestPath( const std::string &testPath ) const +{ + Test *mutableThis = CPPUNIT_CONST_CAST( Test *, this ); + return TestPath( mutableThis, testPath ); +} + + +void +Test::checkIsValidIndex( int index ) const +{ + if ( index < 0 || index >= getChildTestCount() ) + throw std::out_of_range( "Test::checkValidIndex(): invalid index" ); +} + + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/TestAssert.cpp b/UnitTests/cppunit/src/cppunit/TestAssert.cpp new file mode 100644 index 000000000..6e4e794b2 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/TestAssert.cpp @@ -0,0 +1,46 @@ +#include +#include + +CPPUNIT_NS_BEGIN + + +void +assertDoubleEquals( double expected, + double actual, + double delta, + SourceLine sourceLine, + const std::string &message ) +{ + AdditionalMessage msg( "Delta : " + + assertion_traits::toString(delta) ); + msg.addDetail( AdditionalMessage(message) ); + + bool equal; + if ( floatingPointIsFinite(expected) && floatingPointIsFinite(actual) ) + equal = fabs( expected - actual ) <= delta; + else + { + // If expected or actual is not finite, it may be +inf, -inf or NaN (Not a Number). + // Value of +inf or -inf leads to a true equality regardless of delta if both + // expected and actual have the same value (infinity sign). + // NaN Value should always lead to a failed equality. + if ( floatingPointIsUnordered(expected) || floatingPointIsUnordered(actual) ) + { + equal = false; // expected or actual is a NaN + } + else // ordered values, +inf or -inf comparison + { + equal = expected == actual; + } + } + + Asserter::failNotEqualIf( !equal, + assertion_traits::toString(expected), + assertion_traits::toString(actual), + sourceLine, + msg, + "double equality assertion failed" ); +} + + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/TestCase.cpp b/UnitTests/cppunit/src/cppunit/TestCase.cpp new file mode 100644 index 000000000..13c05257f --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/TestCase.cpp @@ -0,0 +1,137 @@ +#include +#include +#include +#include +#include +#include + +#if CPPUNIT_USE_TYPEINFO_NAME +# include +#endif + +CPPUNIT_NS_BEGIN + +/*! \brief Functor to call test case method (Implementation). + * + * Implementation detail. + */ +class TestCaseMethodFunctor : public Functor +{ +public: + typedef void (TestCase::*Method)(); + + TestCaseMethodFunctor( TestCase *target, + Method method ) + : m_target( target ) + , m_method( method ) + { + } + + bool operator()() const + { + (m_target->*m_method)(); + return true; + } + +private: + TestCase *m_target; + Method m_method; +}; + + +/** Constructs a test case. + * \param name the name of the TestCase. + **/ +TestCase::TestCase( const std::string &name ) + : m_name(name) +{ +} + + +/// Run the test and catch any exceptions that are triggered by it +void +TestCase::run( TestResult *result ) +{ + result->startTest(this); +/* + try { + setUp(); + + try { + runTest(); + } + catch ( Exception &e ) { + Exception *copy = e.clone(); + result->addFailure( this, copy ); + } + catch ( std::exception &e ) { + result->addError( this, new Exception( Message( "uncaught std::exception", + e.what() ) ) ); + } + catch (...) { + Exception *e = new Exception( Message( "uncaught unknown exception" ) ); + result->addError( this, e ); + } + + try { + tearDown(); + } + catch (...) { + result->addError( this, new Exception( Message( "tearDown() failed" ) ) ); + } + } + catch (...) { + result->addError( this, new Exception( Message( "setUp() failed" ) ) ); + } +*/ + if ( result->protect( TestCaseMethodFunctor( this, &TestCase::setUp ), + this, + "setUp() failed" ) ) + { + result->protect( TestCaseMethodFunctor( this, &TestCase::runTest ), + this ); + } + + result->protect( TestCaseMethodFunctor( this, &TestCase::tearDown ), + this, + "tearDown() failed" ); + + result->endTest( this ); +} + + +/// All the work for runTest is deferred to subclasses +void +TestCase::runTest() +{ +} + + +/** Constructs a test case for a suite. + * \deprecated This constructor was used by fixture when TestFixture did not exist. + * Have your fixture inherits TestFixture instead of TestCase. + * \internal + * This TestCase was intended for use by the TestCaller and should not + * be used by a test case for which run() is called. + **/ +TestCase::TestCase() + : m_name( "" ) +{ +} + + +/// Destructs a test case +TestCase::~TestCase() +{ +} + + +/// Returns the name of the test case +std::string +TestCase::getName() const +{ + return m_name; +} + + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/TestCaseDecorator.cpp b/UnitTests/cppunit/src/cppunit/TestCaseDecorator.cpp new file mode 100644 index 000000000..a7229f4b2 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/TestCaseDecorator.cpp @@ -0,0 +1,47 @@ +#include + +CPPUNIT_NS_BEGIN + + +TestCaseDecorator::TestCaseDecorator( TestCase *test ) + : TestCase( test->getName() ), + m_test( test ) +{ +} + + +TestCaseDecorator::~TestCaseDecorator() +{ + delete m_test; +} + + +std::string +TestCaseDecorator::getName() const +{ + return m_test->getName(); +} + + +void +TestCaseDecorator::setUp() +{ + m_test->setUp(); +} + + +void +TestCaseDecorator::tearDown() +{ + m_test->tearDown(); +} + + +void +TestCaseDecorator::runTest() +{ + m_test->runTest(); +} + + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/TestComposite.cpp b/UnitTests/cppunit/src/cppunit/TestComposite.cpp new file mode 100644 index 000000000..4768791b5 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/TestComposite.cpp @@ -0,0 +1,77 @@ +#include +#include + + +CPPUNIT_NS_BEGIN + + +TestComposite::TestComposite( const std::string &name ) + : m_name( name ) +{ +} + + +TestComposite::~TestComposite() +{ +} + + +void +TestComposite::run( TestResult *result ) +{ + doStartSuite( result ); + doRunChildTests( result ); + doEndSuite( result ); +} + + +int +TestComposite::countTestCases() const +{ + int count = 0; + + int childCount = getChildTestCount(); + for ( int index =0; index < childCount; ++index ) + count += getChildTestAt( index )->countTestCases(); + + return count; +} + + +std::string +TestComposite::getName() const +{ + return m_name; +} + + +void +TestComposite::doStartSuite( TestResult *controller ) +{ + controller->startSuite( this ); +} + + +void +TestComposite::doRunChildTests( TestResult *controller ) +{ + int childCount = getChildTestCount(); + for ( int index =0; index < childCount; ++index ) + { + if ( controller->shouldStop() ) + break; + + getChildTestAt( index )->run( controller ); + } +} + + +void +TestComposite::doEndSuite( TestResult *controller ) +{ + controller->endSuite( this ); +} + + +CPPUNIT_NS_END + diff --git a/UnitTests/cppunit/src/cppunit/TestDecorator.cpp b/UnitTests/cppunit/src/cppunit/TestDecorator.cpp new file mode 100644 index 000000000..4e25a6af9 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/TestDecorator.cpp @@ -0,0 +1,53 @@ +#include + +CPPUNIT_NS_BEGIN + + +TestDecorator::TestDecorator( Test *test ) + : m_test( test) +{ +} + + +TestDecorator::~TestDecorator() +{ + delete m_test; +} + + +int +TestDecorator::countTestCases() const +{ + return m_test->countTestCases(); +} + + +void +TestDecorator::run( TestResult *result ) +{ + m_test->run(result); +} + + +std::string +TestDecorator::getName() const +{ + return m_test->getName(); +} + + +int +TestDecorator::getChildTestCount() const +{ + return m_test->getChildTestCount(); +} + + +Test * +TestDecorator::doGetChildTestAt( int index ) const +{ + return m_test->getChildTestAt( index ); +} + + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/TestFactoryRegistry.cpp b/UnitTests/cppunit/src/cppunit/TestFactoryRegistry.cpp new file mode 100644 index 000000000..3457da39c --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/TestFactoryRegistry.cpp @@ -0,0 +1,161 @@ +#include +#include +#include +#include +#include + + +CPPUNIT_NS_BEGIN + +/*! \brief (INTERNAL) List of all TestFactoryRegistry. + */ +class TestFactoryRegistryList +{ +private: + typedef CppUnitMap > Registries; + Registries m_registries; + + enum State { + doNotChange =0, + notCreated, + exist, + destroyed + }; + + static State stateFlag( State newState = doNotChange ) + { + static State state = notCreated; + if ( newState != doNotChange ) + state = newState; + return state; + } + + static TestFactoryRegistryList *getInstance() + { + static TestFactoryRegistryList list; + return &list; + } + + TestFactoryRegistry *getInternalRegistry( const std::string &name ) + { + Registries::const_iterator foundIt = m_registries.find( name ); + if ( foundIt == m_registries.end() ) + { + TestFactoryRegistry *factory = new TestFactoryRegistry( name ); + m_registries.insert( std::pair( name, factory ) ); + return factory; + } + return (*foundIt).second; + } + +public: + TestFactoryRegistryList() + { + stateFlag( exist ); + } + + ~TestFactoryRegistryList() + { + for ( Registries::iterator it = m_registries.begin(); it != m_registries.end(); ++it ) + delete (*it).second; + + stateFlag( destroyed ); + } + + static TestFactoryRegistry *getRegistry( const std::string &name ) + { + // If the following assertion failed, then TestFactoryRegistry::getRegistry() + // was called during static variable destruction without checking the registry + // validity beforehand using TestFactoryRegistry::isValid() beforehand. + assert( isValid() ); + if ( !isValid() ) // release mode + return NULL; // => force CRASH + + return getInstance()->getInternalRegistry( name ); + } + + static bool isValid() + { + return stateFlag() != destroyed; + } +}; + + + +TestFactoryRegistry::TestFactoryRegistry( std::string name ) : + m_name( name ) +{ +} + + +TestFactoryRegistry::~TestFactoryRegistry() +{ +} + + +TestFactoryRegistry & +TestFactoryRegistry::getRegistry( const std::string &name ) +{ + return *TestFactoryRegistryList::getRegistry( name ); +} + + +void +TestFactoryRegistry::registerFactory( const std::string &, + TestFactory *factory ) +{ + registerFactory( factory ); +} + + +void +TestFactoryRegistry::registerFactory( TestFactory *factory ) +{ + m_factories.insert( factory ); +} + + +void +TestFactoryRegistry::unregisterFactory( TestFactory *factory ) +{ + m_factories.erase( factory ); +} + + +void +TestFactoryRegistry::addRegistry( const std::string &name ) +{ + registerFactory( &getRegistry( name ) ); +} + + +Test * +TestFactoryRegistry::makeTest() +{ + TestSuite *suite = new TestSuite( m_name ); + addTestToSuite( suite ); + return suite; +} + + +void +TestFactoryRegistry::addTestToSuite( TestSuite *suite ) +{ + for ( Factories::iterator it = m_factories.begin(); + it != m_factories.end(); + ++it ) + { + TestFactory *factory = *it; + suite->addTest( factory->makeTest() ); + } +} + + +bool +TestFactoryRegistry::isValid() +{ + return TestFactoryRegistryList::isValid(); +} + + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/TestFailure.cpp b/UnitTests/cppunit/src/cppunit/TestFailure.cpp new file mode 100644 index 000000000..e31e13893 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/TestFailure.cpp @@ -0,0 +1,71 @@ +#include +#include +#include + +CPPUNIT_NS_BEGIN + + +/// Constructs a TestFailure with the given test and exception. +TestFailure::TestFailure( Test *failedTest, + Exception *thrownException, + bool isError ) : + m_failedTest( failedTest ), + m_thrownException( thrownException ), + m_isError( isError ) +{ +} + +/// Deletes the owned exception. +TestFailure::~TestFailure() +{ + delete m_thrownException; +} + +/// Gets the failed test. +Test * +TestFailure::failedTest() const +{ + return m_failedTest; +} + + +/// Gets the thrown exception. Never \c NULL. +Exception * +TestFailure::thrownException() const +{ + return m_thrownException; +} + + +/// Gets the failure location. +SourceLine +TestFailure::sourceLine() const +{ + return m_thrownException->sourceLine(); +} + + +/// Indicates if the failure is a failed assertion or an error. +bool +TestFailure::isError() const +{ + return m_isError; +} + + +/// Gets the name of the failed test. +std::string +TestFailure::failedTestName() const +{ + return m_failedTest->getName(); +} + + +TestFailure * +TestFailure::clone() const +{ + return new TestFailure( m_failedTest, m_thrownException->clone(), m_isError ); +} + + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/TestLeaf.cpp b/UnitTests/cppunit/src/cppunit/TestLeaf.cpp new file mode 100644 index 000000000..3d8767cf5 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/TestLeaf.cpp @@ -0,0 +1,28 @@ +#include + + +CPPUNIT_NS_BEGIN + + +int +TestLeaf::countTestCases() const +{ + return 1; +} + + +int +TestLeaf::getChildTestCount() const +{ + return 0; +} + + +Test * +TestLeaf::doGetChildTestAt( int index ) const +{ + checkIsValidIndex( index ); + return NULL; // never called, checkIsValidIndex() always throw. +} + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/TestNamer.cpp b/UnitTests/cppunit/src/cppunit/TestNamer.cpp new file mode 100644 index 000000000..eec9be973 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/TestNamer.cpp @@ -0,0 +1,44 @@ +#include +#include +#include + + +CPPUNIT_NS_BEGIN + + +#if CPPUNIT_HAVE_RTTI +TestNamer::TestNamer( const std::type_info &typeInfo ) +{ + m_fixtureName = TypeInfoHelper::getClassName( typeInfo ); +} +#endif + + +TestNamer::TestNamer( const std::string &fixtureName ) + : m_fixtureName( fixtureName ) +{ +} + + +TestNamer::~TestNamer() +{ +} + + +std::string +TestNamer::getFixtureName() const +{ + return m_fixtureName; +} + + +std::string +TestNamer::getTestNameFor( const std::string &testMethodName ) const +{ + return getFixtureName() + "::" + testMethodName; +} + + + + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/TestPath.cpp b/UnitTests/cppunit/src/cppunit/TestPath.cpp new file mode 100644 index 000000000..a2783a293 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/TestPath.cpp @@ -0,0 +1,254 @@ +#include +#include +#include +#include + + +CPPUNIT_NS_BEGIN + + +TestPath::TestPath() +{ +} + + +TestPath::TestPath( Test *root ) +{ + add( root ); +} + + +TestPath::TestPath( const TestPath &other, + int indexFirst, + int count ) +{ + int countAdjustment = 0; + if ( indexFirst < 0 ) + { + countAdjustment = indexFirst; + indexFirst = 0; + } + + if ( count < 0 ) + count = other.getTestCount(); + else + count += countAdjustment; + + int index = indexFirst; + while ( count-- > 0 && index < other.getTestCount() ) + add( other.getTestAt( index++ ) ); +} + + +TestPath::TestPath( Test *searchRoot, + const std::string &pathAsString ) +{ + PathTestNames testNames; + + Test *parentTest = findActualRoot( searchRoot, pathAsString, testNames ); + add( parentTest ); + + for ( unsigned int index = 1; index < testNames.size(); ++index ) + { + bool childFound = false; + for ( int childIndex =0; childIndex < parentTest->getChildTestCount(); ++childIndex ) + { + if ( parentTest->getChildTestAt( childIndex )->getName() == testNames[index] ) + { + childFound = true; + parentTest = parentTest->getChildTestAt( childIndex ); + break; + } + } + + if ( !childFound ) + throw std::invalid_argument( "TestPath::TestPath(): failed to resolve test name <"+ + testNames[index] + "> of path <" + pathAsString + ">" ); + + add( parentTest ); + } +} + + +TestPath::TestPath( const TestPath &other ) + : m_tests( other.m_tests ) +{ +} + + +TestPath::~TestPath() +{ +} + + +TestPath & +TestPath::operator =( const TestPath &other ) +{ + if ( &other != this ) + m_tests = other.m_tests; + return *this; +} + + +bool +TestPath::isValid() const +{ + return getTestCount() > 0; +} + + +void +TestPath::add( Test *test ) +{ + m_tests.push_back( test ); +} + + +void +TestPath::add( const TestPath &path ) +{ + for ( int index =0; index < path.getTestCount(); ++index ) + add( path.getTestAt( index ) ); +} + + +void +TestPath::insert( Test *test, + int index ) +{ + if ( index < 0 || index > getTestCount() ) + throw std::out_of_range( "TestPath::insert(): index out of range" ); + m_tests.insert( m_tests.begin() + index, test ); +} + +void +TestPath::insert( const TestPath &path, + int index ) +{ + int itemIndex = path.getTestCount() -1; + while ( itemIndex >= 0 ) + insert( path.getTestAt( itemIndex-- ), index ); +} + + +void +TestPath::removeTests() +{ + while ( isValid() ) + removeTest( 0 ); +} + + +void +TestPath::removeTest( int index ) +{ + checkIndexValid( index ); + m_tests.erase( m_tests.begin() + index ); +} + + +void +TestPath::up() +{ + checkIndexValid( 0 ); + removeTest( getTestCount() -1 ); +} + + +int +TestPath::getTestCount() const +{ + return m_tests.size(); +} + + +Test * +TestPath::getTestAt( int index ) const +{ + checkIndexValid( index ); + return m_tests[index]; +} + + +Test * +TestPath::getChildTest() const +{ + return getTestAt( getTestCount() -1 ); +} + + +void +TestPath::checkIndexValid( int index ) const +{ + if ( index < 0 || index >= getTestCount() ) + throw std::out_of_range( "TestPath::checkIndexValid(): index out of range" ); +} + + +std::string +TestPath::toString() const +{ + std::string asString( "/" ); + for ( int index =0; index < getTestCount(); ++index ) + { + if ( index > 0 ) + asString += '/'; + asString += getTestAt(index)->getName(); + } + + return asString; +} + + +Test * +TestPath::findActualRoot( Test *searchRoot, + const std::string &pathAsString, + PathTestNames &testNames ) +{ + bool isRelative = splitPathString( pathAsString, testNames ); + + if ( isRelative && pathAsString.empty() ) + return searchRoot; + + if ( testNames.empty() ) + throw std::invalid_argument( "TestPath::TestPath(): invalid root or root name in absolute path" ); + + Test *root = isRelative ? searchRoot->findTest( testNames[0] ) // throw if bad test name + : searchRoot; + if ( root->getName() != testNames[0] ) + throw std::invalid_argument( "TestPath::TestPath(): searchRoot does not match path root name" ); + + return root; +} + + +bool +TestPath::splitPathString( const std::string &pathAsString, + PathTestNames &testNames ) +{ + if ( pathAsString.empty() ) + return true; + + bool isRelative = pathAsString[0] != '/'; + + int index = (isRelative ? 0 : 1); + while ( true ) + { + int separatorIndex = pathAsString.find( '/', index ); + if ( separatorIndex >= 0 ) + { + testNames.push_back( pathAsString.substr( index, separatorIndex - index ) ); + index = separatorIndex + 1; + } + else + { + testNames.push_back( pathAsString.substr( index ) ); + break; + } + } + + return isRelative; +} + + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/TestPlugInDefaultImpl.cpp b/UnitTests/cppunit/src/cppunit/TestPlugInDefaultImpl.cpp new file mode 100644 index 000000000..086dea047 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/TestPlugInDefaultImpl.cpp @@ -0,0 +1,63 @@ +#include + +#if !defined(CPPUNIT_NO_TESTPLUGIN) + +#include +#include +#include + + +CPPUNIT_NS_BEGIN + + +TestPlugInDefaultImpl::TestPlugInDefaultImpl() +{ +} + + +TestPlugInDefaultImpl::~TestPlugInDefaultImpl() +{ +} + + +void +TestPlugInDefaultImpl::initialize( TestFactoryRegistry *, + const PlugInParameters & ) +{ +} + + +void +TestPlugInDefaultImpl::addListener( TestResult * ) +{ +} + + +void +TestPlugInDefaultImpl::removeListener( TestResult * ) +{ +} + + +void +TestPlugInDefaultImpl::addXmlOutputterHooks( XmlOutputter * ) +{ +} + + +void +TestPlugInDefaultImpl::removeXmlOutputterHooks() +{ +} + + +void +TestPlugInDefaultImpl::uninitialize( TestFactoryRegistry * ) +{ +} + + +CPPUNIT_NS_END + + +#endif // !defined(CPPUNIT_NO_TESTPLUGIN) diff --git a/UnitTests/cppunit/src/cppunit/TestResult.cpp b/UnitTests/cppunit/src/cppunit/TestResult.cpp new file mode 100644 index 000000000..4b02c30de --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/TestResult.cpp @@ -0,0 +1,199 @@ +#include +#include +#include +#include +#include +#include +#include +#include "DefaultProtector.h" +#include "ProtectorChain.h" +#include "ProtectorContext.h" + +CPPUNIT_NS_BEGIN + + +TestResult::TestResult( SynchronizationObject *syncObject ) + : SynchronizedObject( syncObject ) + , m_protectorChain( new ProtectorChain() ) + , m_stop( false ) +{ + m_protectorChain->push( new DefaultProtector() ); +} + + +TestResult::~TestResult() +{ + stdCOut().flush(); + stdCErr().flush(); + delete m_protectorChain; +} + + +void +TestResult::reset() +{ + ExclusiveZone zone( m_syncObject ); + m_stop = false; +} + + +void +TestResult::addError( Test *test, + Exception *e ) +{ + TestFailure failure( test, e, true ); + addFailure( failure ); +} + + +void +TestResult::addFailure( Test *test, Exception *e ) +{ + TestFailure failure( test, e, false ); + addFailure( failure ); +} + + +void +TestResult::addFailure( const TestFailure &failure ) +{ + ExclusiveZone zone( m_syncObject ); + for ( TestListeners::iterator it = m_listeners.begin(); + it != m_listeners.end(); + ++it ) + (*it)->addFailure( failure ); +} + + +void +TestResult::startTest( Test *test ) +{ + ExclusiveZone zone( m_syncObject ); + for ( TestListeners::iterator it = m_listeners.begin(); + it != m_listeners.end(); + ++it ) + (*it)->startTest( test ); +} + + +void +TestResult::endTest( Test *test ) +{ + ExclusiveZone zone( m_syncObject ); + for ( TestListeners::iterator it = m_listeners.begin(); + it != m_listeners.end(); + ++it ) + (*it)->endTest( test ); +} + + +void +TestResult::startSuite( Test *test ) +{ + ExclusiveZone zone( m_syncObject ); + for ( TestListeners::iterator it = m_listeners.begin(); + it != m_listeners.end(); + ++it ) + (*it)->startSuite( test ); +} + + +void +TestResult::endSuite( Test *test ) +{ + ExclusiveZone zone( m_syncObject ); + for ( TestListeners::iterator it = m_listeners.begin(); + it != m_listeners.end(); + ++it ) + (*it)->endSuite( test ); +} + + +bool +TestResult::shouldStop() const +{ + ExclusiveZone zone( m_syncObject ); + return m_stop; +} + + +void +TestResult::stop() +{ + ExclusiveZone zone( m_syncObject ); + m_stop = true; +} + + +void +TestResult::addListener( TestListener *listener ) +{ + ExclusiveZone zone( m_syncObject ); + m_listeners.push_back( listener ); +} + + +void +TestResult::removeListener ( TestListener *listener ) +{ + ExclusiveZone zone( m_syncObject ); + removeFromSequence( m_listeners, listener ); +} + + +void +TestResult::runTest( Test *test ) +{ + startTestRun( test ); + test->run( this ); + endTestRun( test ); +} + + +void +TestResult::startTestRun( Test *test ) +{ + ExclusiveZone zone( m_syncObject ); + for ( TestListeners::iterator it = m_listeners.begin(); + it != m_listeners.end(); + ++it ) + (*it)->startTestRun( test, this ); +} + + +void +TestResult::endTestRun( Test *test ) +{ + ExclusiveZone zone( m_syncObject ); + for ( TestListeners::iterator it = m_listeners.begin(); + it != m_listeners.end(); + ++it ) + (*it)->endTestRun( test, this ); +} + + +bool +TestResult::protect( const Functor &functor, + Test *test, + const std::string &shortDescription ) +{ + ProtectorContext context( test, this, shortDescription ); + return m_protectorChain->protect( functor, context ); +} + + +void +TestResult::pushProtector( Protector *protector ) +{ + m_protectorChain->push( protector ); +} + + +void +TestResult::popProtector() +{ + m_protectorChain->pop(); +} + + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/TestResultCollector.cpp b/UnitTests/cppunit/src/cppunit/TestResultCollector.cpp new file mode 100644 index 000000000..4371c5030 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/TestResultCollector.cpp @@ -0,0 +1,117 @@ +#include +#include + + +CPPUNIT_NS_BEGIN + + +TestResultCollector::TestResultCollector( SynchronizationObject *syncObject ) + : TestSuccessListener( syncObject ) +{ + reset(); +} + + +TestResultCollector::~TestResultCollector() +{ + freeFailures(); +} + + +void +TestResultCollector::freeFailures() +{ + TestFailures::iterator itFailure = m_failures.begin(); + while ( itFailure != m_failures.end() ) + delete *itFailure++; + m_failures.clear(); +} + + +void +TestResultCollector::reset() +{ + TestSuccessListener::reset(); + + ExclusiveZone zone( m_syncObject ); + freeFailures(); + m_testErrors = 0; + m_tests.clear(); +} + + +void +TestResultCollector::startTest( Test *test ) +{ + ExclusiveZone zone (m_syncObject); + m_tests.push_back( test ); +} + + +void +TestResultCollector::addFailure( const TestFailure &failure ) +{ + TestSuccessListener::addFailure( failure ); + + ExclusiveZone zone( m_syncObject ); + if ( failure.isError() ) + ++m_testErrors; + m_failures.push_back( failure.clone() ); +} + + +/// Gets the number of run tests. +int +TestResultCollector::runTests() const +{ + ExclusiveZone zone( m_syncObject ); + return m_tests.size(); +} + + +/// Gets the number of detected errors (uncaught exception). +int +TestResultCollector::testErrors() const +{ + ExclusiveZone zone( m_syncObject ); + return m_testErrors; +} + + +/// Gets the number of detected failures (failed assertion). +int +TestResultCollector::testFailures() const +{ + ExclusiveZone zone( m_syncObject ); + return m_failures.size() - m_testErrors; +} + + +/// Gets the total number of detected failures. +int +TestResultCollector::testFailuresTotal() const +{ + ExclusiveZone zone( m_syncObject ); + return m_failures.size(); +} + + +/// Returns a the list failures (random access collection). +const TestResultCollector::TestFailures & +TestResultCollector::failures() const +{ + ExclusiveZone zone( m_syncObject ); + return m_failures; +} + + +const TestResultCollector::Tests & +TestResultCollector::tests() const +{ + ExclusiveZone zone( m_syncObject ); + return m_tests; +} + + +CPPUNIT_NS_END + diff --git a/UnitTests/cppunit/src/cppunit/TestRunner.cpp b/UnitTests/cppunit/src/cppunit/TestRunner.cpp new file mode 100644 index 000000000..8d95a6308 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/TestRunner.cpp @@ -0,0 +1,101 @@ +#include +#include +#include +#include + + +CPPUNIT_NS_BEGIN + + +TestRunner::WrappingSuite::WrappingSuite( const std::string &name ) + : TestSuite( name ) +{ +} + + +int +TestRunner::WrappingSuite::getChildTestCount() const +{ + if ( hasOnlyOneTest() ) + return getUniqueChildTest()->getChildTestCount(); + return TestSuite::getChildTestCount(); +} + + +std::string +TestRunner::WrappingSuite::getName() const +{ + if ( hasOnlyOneTest() ) + return getUniqueChildTest()->getName(); + return TestSuite::getName(); +} + + +Test * +TestRunner::WrappingSuite::doGetChildTestAt( int index ) const +{ + if ( hasOnlyOneTest() ) + return getUniqueChildTest()->getChildTestAt( index ); + return TestSuite::doGetChildTestAt( index ); +} + + +void +TestRunner::WrappingSuite::run( TestResult *result ) +{ + if ( hasOnlyOneTest() ) + getUniqueChildTest()->run( result ); + else + TestSuite::run( result ); +} + + +bool +TestRunner::WrappingSuite::hasOnlyOneTest() const +{ + return TestSuite::getChildTestCount() == 1; +} + + +Test * +TestRunner::WrappingSuite::getUniqueChildTest() const +{ + return TestSuite::doGetChildTestAt( 0 ); +} + + + + + +TestRunner::TestRunner() + : m_suite( new WrappingSuite() ) +{ +} + + +TestRunner::~TestRunner() +{ + delete m_suite; +} + + +void +TestRunner::addTest( Test *test ) +{ + m_suite->addTest( test ); +} + + +void +TestRunner::run( TestResult &controller, + const std::string &testPath ) +{ + TestPath path = m_suite->resolveTestPath( testPath ); + Test *testToRun = path.getChildTest(); + + controller.runTest( testToRun ); +} + + +CPPUNIT_NS_END + diff --git a/UnitTests/cppunit/src/cppunit/TestSetUp.cpp b/UnitTests/cppunit/src/cppunit/TestSetUp.cpp new file mode 100644 index 000000000..d4d853089 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/TestSetUp.cpp @@ -0,0 +1,32 @@ +#include + +CPPUNIT_NS_BEGIN + + +TestSetUp::TestSetUp( Test *test ) : TestDecorator( test ) +{ +} + + +void +TestSetUp::setUp() +{ +} + + +void +TestSetUp::tearDown() +{ +} + + +void +TestSetUp::run( TestResult *result ) +{ + setUp(); + TestDecorator::run(result); + tearDown(); +} + + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/TestSuccessListener.cpp b/UnitTests/cppunit/src/cppunit/TestSuccessListener.cpp new file mode 100644 index 000000000..a5572a934 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/TestSuccessListener.cpp @@ -0,0 +1,44 @@ +#include + + +CPPUNIT_NS_BEGIN + + +TestSuccessListener::TestSuccessListener( SynchronizationObject *syncObject ) + : SynchronizedObject( syncObject ) + , m_success( true ) +{ +} + + +TestSuccessListener::~TestSuccessListener() +{ +} + + +void +TestSuccessListener::reset() +{ + ExclusiveZone zone( m_syncObject ); + m_success = true; +} + + +void +TestSuccessListener::addFailure( const TestFailure & ) +{ + ExclusiveZone zone( m_syncObject ); + m_success = false; +} + + +bool +TestSuccessListener::wasSuccessful() const +{ + ExclusiveZone zone( m_syncObject ); + return m_success; +} + + +CPPUNIT_NS_END + diff --git a/UnitTests/cppunit/src/cppunit/TestSuite.cpp b/UnitTests/cppunit/src/cppunit/TestSuite.cpp new file mode 100644 index 000000000..8dd2ea6e7 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/TestSuite.cpp @@ -0,0 +1,64 @@ +#include +#include +#include + +CPPUNIT_NS_BEGIN + + +/// Default constructor +TestSuite::TestSuite( std::string name ) + : TestComposite( name ) +{ +} + + +/// Destructor +TestSuite::~TestSuite() +{ + deleteContents(); +} + + +/// Deletes all tests in the suite. +void +TestSuite::deleteContents() +{ + int childCount = getChildTestCount(); + for ( int index =0; index < childCount; ++index ) + delete getChildTestAt( index ); + + m_tests.clear(); +} + + +/// Adds a test to the suite. +void +TestSuite::addTest( Test *test ) +{ + m_tests.push_back( test ); +} + + +const CppUnitVector & +TestSuite::getTests() const +{ + return m_tests; +} + + +int +TestSuite::getChildTestCount() const +{ + return m_tests.size(); +} + + +Test * +TestSuite::doGetChildTestAt( int index ) const +{ + return m_tests[index]; +} + + +CPPUNIT_NS_END + diff --git a/UnitTests/cppunit/src/cppunit/TestSuiteBuilderContext.cpp b/UnitTests/cppunit/src/cppunit/TestSuiteBuilderContext.cpp new file mode 100644 index 000000000..ff71b52c1 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/TestSuiteBuilderContext.cpp @@ -0,0 +1,85 @@ +#include +#include +#include +#include + + +CPPUNIT_NS_BEGIN + +TestSuiteBuilderContextBase::TestSuiteBuilderContextBase( + TestSuite &suite, + const TestNamer &namer, + TestFixtureFactory &factory ) + : m_suite( suite ) + , m_namer( namer ) + , m_factory( factory ) +{ +} + + +TestSuiteBuilderContextBase::~TestSuiteBuilderContextBase() +{ +} + + +void +TestSuiteBuilderContextBase::addTest( Test *test ) +{ + m_suite.addTest( test ); +} + + +std::string +TestSuiteBuilderContextBase::getFixtureName() const +{ + return m_namer.getFixtureName(); +} + + +std::string +TestSuiteBuilderContextBase::getTestNameFor( + const std::string &testMethodName ) const +{ + return m_namer.getTestNameFor( testMethodName ); +} + + +TestFixture * +TestSuiteBuilderContextBase::makeTestFixture() const +{ + return m_factory.makeFixture(); +} + + +void +TestSuiteBuilderContextBase::addProperty( const std::string &key, + const std::string &value ) +{ + Properties::iterator it = m_properties.begin(); + for ( ; it != m_properties.end(); ++it ) + { + if ( (*it).first == key ) + { + (*it).second = value; + return; + } + } + + Property property( key, value ); + m_properties.push_back( property ); +} + +const std::string +TestSuiteBuilderContextBase::getStringProperty( const std::string &key ) const +{ + Properties::const_iterator it = m_properties.begin(); + for ( ; it != m_properties.end(); ++it ) + { + if ( (*it).first == key ) + return (*it).second; + } + return ""; +} + + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/TextOutputter.cpp b/UnitTests/cppunit/src/cppunit/TextOutputter.cpp new file mode 100644 index 000000000..f74214fc6 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/TextOutputter.cpp @@ -0,0 +1,140 @@ +#include +#include +#include +#include +#include + + +CPPUNIT_NS_BEGIN + + +TextOutputter::TextOutputter( TestResultCollector *result, + OStream &stream ) + : m_result( result ) + , m_stream( stream ) +{ +} + + +TextOutputter::~TextOutputter() +{ +} + + +void +TextOutputter::write() +{ + printHeader(); + m_stream << "\n"; + printFailures(); + m_stream << "\n"; +} + + +void +TextOutputter::printFailures() +{ + TestResultCollector::TestFailures::const_iterator itFailure = m_result->failures().begin(); + int failureNumber = 1; + while ( itFailure != m_result->failures().end() ) + { + m_stream << "\n"; + printFailure( *itFailure++, failureNumber++ ); + } +} + + +void +TextOutputter::printFailure( TestFailure *failure, + int failureNumber ) +{ + printFailureListMark( failureNumber ); + m_stream << ' '; + printFailureTestName( failure ); + m_stream << ' '; + printFailureType( failure ); + m_stream << ' '; + printFailureLocation( failure->sourceLine() ); + m_stream << "\n"; + printFailureDetail( failure->thrownException() ); + m_stream << "\n"; +} + + +void +TextOutputter::printFailureListMark( int failureNumber ) +{ + m_stream << failureNumber << ")"; +} + + +void +TextOutputter::printFailureTestName( TestFailure *failure ) +{ + m_stream << "test: " << failure->failedTestName(); +} + + +void +TextOutputter::printFailureType( TestFailure *failure ) +{ + m_stream << "(" + << (failure->isError() ? "E" : "F") + << ")"; +} + + +void +TextOutputter::printFailureLocation( SourceLine sourceLine ) +{ + if ( !sourceLine.isValid() ) + return; + + m_stream << "line: " << sourceLine.lineNumber() + << ' ' << sourceLine.fileName(); +} + + +void +TextOutputter::printFailureDetail( Exception *thrownException ) +{ + m_stream << thrownException->message().shortDescription() << "\n"; + m_stream << thrownException->message().details(); +} + + +void +TextOutputter::printHeader() +{ + if ( m_result->wasSuccessful() ) + m_stream << "\nOK (" << m_result->runTests () << " tests)\n" ; + else + { + m_stream << "\n"; + printFailureWarning(); + printStatistics(); + } +} + + +void +TextOutputter::printFailureWarning() +{ + m_stream << "!!!FAILURES!!!\n"; +} + + +void +TextOutputter::printStatistics() +{ + m_stream << "Test Results:\n"; + + m_stream << "Run: " << m_result->runTests() + << " Failures: " << m_result->testFailures() + << " Errors: " << m_result->testErrors() + << "\n"; +} + + +CPPUNIT_NS_END + diff --git a/UnitTests/cppunit/src/cppunit/TextTestProgressListener.cpp b/UnitTests/cppunit/src/cppunit/TextTestProgressListener.cpp new file mode 100644 index 000000000..ea4fb17c9 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/TextTestProgressListener.cpp @@ -0,0 +1,45 @@ +#include +#include +#include + + +CPPUNIT_NS_BEGIN + + +TextTestProgressListener::TextTestProgressListener() +{ +} + + +TextTestProgressListener::~TextTestProgressListener() +{ +} + + +void +TextTestProgressListener::startTest( Test * ) +{ + stdCOut() << "."; + stdCOut().flush(); +} + + +void +TextTestProgressListener::addFailure( const TestFailure &failure ) +{ + stdCOut() << ( failure.isError() ? "E" : "F" ); + stdCOut().flush(); +} + + +void +TextTestProgressListener::endTestRun( Test *, + TestResult * ) +{ + stdCOut() << "\n"; + stdCOut().flush(); +} + + +CPPUNIT_NS_END + diff --git a/UnitTests/cppunit/src/cppunit/TextTestResult.cpp b/UnitTests/cppunit/src/cppunit/TextTestResult.cpp new file mode 100644 index 000000000..871eb6da3 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/TextTestResult.cpp @@ -0,0 +1,50 @@ +#include +#include +#include +#include +#include +#include + + +CPPUNIT_NS_BEGIN + + +TextTestResult::TextTestResult() +{ + addListener( this ); +} + + +void +TextTestResult::addFailure( const TestFailure &failure ) +{ + TestResultCollector::addFailure( failure ); + stdCOut() << ( failure.isError() ? "E" : "F" ); +} + + +void +TextTestResult::startTest( Test *test ) +{ + TestResultCollector::startTest (test); + stdCOut() << "."; +} + + +void +TextTestResult::print( OStream &stream ) +{ + TextOutputter outputter( this, stream ); + outputter.write(); +} + + +OStream & +operator <<( OStream &stream, + TextTestResult &result ) +{ + result.print (stream); return stream; +} + + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/TextTestRunner.cpp b/UnitTests/cppunit/src/cppunit/TextTestRunner.cpp new file mode 100644 index 000000000..1534ec0cc --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/TextTestRunner.cpp @@ -0,0 +1,144 @@ +// ==> Implementation of cppunit/ui/text/TestRunner.h + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +CPPUNIT_NS_BEGIN + + +/*! Constructs a new text runner. + * \param outputter used to print text result. Owned by the runner. + */ +TextTestRunner::TextTestRunner( Outputter *outputter ) + : m_result( new TestResultCollector() ) + , m_eventManager( new TestResult() ) + , m_outputter( outputter ) +{ + if ( !m_outputter ) + m_outputter = new TextOutputter( m_result, stdCOut() ); + m_eventManager->addListener( m_result ); +} + + +TextTestRunner::~TextTestRunner() +{ + delete m_eventManager; + delete m_outputter; + delete m_result; +} + + +/*! Runs the named test case. + * + * \param testName Name of the test case to run. If an empty is given, then + * all added tests are run. The name can be the name of any + * test in the hierarchy. + * \param doWait if \c true then the user must press the RETURN key + * before the run() method exit. + * \param doPrintResult if \c true (default) then the test result are printed + * on the standard output. + * \param doPrintProgress if \c true (default) then TextTestProgressListener is + * used to show the progress. + * \return \c true is the test was successful, \c false if the test + * failed or was not found. + */ +bool +TextTestRunner::run( std::string testName, + bool doWait, + bool doPrintResult, + bool doPrintProgress ) +{ + TextTestProgressListener progress; + if ( doPrintProgress ) + m_eventManager->addListener( &progress ); + + TestRunner *pThis = this; + pThis->run( *m_eventManager, testName ); + + if ( doPrintProgress ) + m_eventManager->removeListener( &progress ); + + printResult( doPrintResult ); + wait( doWait ); + + return m_result->wasSuccessful(); +} + + +void +TextTestRunner::wait( bool doWait ) +{ +#if !defined( CPPUNIT_NO_STREAM ) + if ( doWait ) + { + stdCOut() << " to continue\n"; + stdCOut().flush(); + std::cin.get (); + } +#endif +} + + +void +TextTestRunner::printResult( bool doPrintResult ) +{ + stdCOut() << "\n"; + if ( doPrintResult ) + m_outputter->write(); +} + + +/*! Returns the result of the test run. + * Use this after calling run() to access the result of the test run. + */ +TestResultCollector & +TextTestRunner::result() const +{ + return *m_result; +} + + +/*! Returns the event manager. + * The instance of TestResult results returned is the one that is used to run the + * test. Use this to register additional TestListener before running the tests. + */ +TestResult & +TextTestRunner::eventManager() const +{ + return *m_eventManager; +} + + +/*! Specifies an alternate outputter. + * + * Notes that the outputter will be use after the test run only if \a printResult was + * \c true. + * \param outputter New outputter to use. The previous outputter is destroyed. + * The TextTestRunner assumes ownership of the outputter. + * \see CompilerOutputter, XmlOutputter, TextOutputter. + */ +void +TextTestRunner::setOutputter( Outputter *outputter ) +{ + delete m_outputter; + m_outputter = outputter; +} + + +void +TextTestRunner::run( TestResult &controller, + const std::string &testPath ) +{ + TestRunner::run( controller, testPath ); +} + + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/TypeInfoHelper.cpp b/UnitTests/cppunit/src/cppunit/TypeInfoHelper.cpp new file mode 100644 index 000000000..ff1d66272 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/TypeInfoHelper.cpp @@ -0,0 +1,54 @@ +#include +#include + +#if CPPUNIT_HAVE_RTTI + +#include + +#if CPPUNIT_HAVE_GCC_ABI_DEMANGLE +#include +#include +#endif + + +CPPUNIT_NS_BEGIN + + +std::string +TypeInfoHelper::getClassName( const std::type_info &info ) +{ +#if defined(CPPUNIT_HAVE_GCC_ABI_DEMANGLE) && CPPUNIT_HAVE_GCC_ABI_DEMANGLE + + int status = 0; + char* c_name = 0; + + c_name = abi::__cxa_demangle( info.name(), 0, 0, &status ); + + std::string name( c_name ); + free( c_name ); + +#else // CPPUNIT_HAVE_GCC_ABI_DEMANGLE + + static std::string classPrefix( "class " ); + std::string name( info.name() ); + + // Work around gcc 3.0 bug: strip number before type name. + unsigned int firstNotDigitIndex = 0; + while ( firstNotDigitIndex < name.length() && + name[firstNotDigitIndex] >= '0' && + name[firstNotDigitIndex] <= '9' ) + ++firstNotDigitIndex; + name = name.substr( firstNotDigitIndex ); + + if ( name.substr( 0, classPrefix.length() ) == classPrefix ) + return name.substr( classPrefix.length() ); + +#endif // CPPUNIT_HAVE_GCC_ABI_DEMANGLE + + return name; +} + + +CPPUNIT_NS_END + +#endif // CPPUNIT_HAVE_RTTI diff --git a/UnitTests/cppunit/src/cppunit/UnixDynamicLibraryManager.cpp b/UnitTests/cppunit/src/cppunit/UnixDynamicLibraryManager.cpp new file mode 100644 index 000000000..f235cce5a --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/UnixDynamicLibraryManager.cpp @@ -0,0 +1,44 @@ +#include + +#if defined(CPPUNIT_HAVE_UNIX_DLL_LOADER) +#include + +#include +#include + + +CPPUNIT_NS_BEGIN + + +DynamicLibraryManager::LibraryHandle +DynamicLibraryManager::doLoadLibrary( const std::string &libraryName ) +{ + return ::dlopen( libraryName.c_str(), RTLD_NOW | RTLD_GLOBAL ); +} + + +void +DynamicLibraryManager::doReleaseLibrary() +{ + ::dlclose( m_libraryHandle); +} + + +DynamicLibraryManager::Symbol +DynamicLibraryManager::doFindSymbol( const std::string &symbol ) +{ + return ::dlsym ( m_libraryHandle, symbol.c_str() ); +} + + +std::string +DynamicLibraryManager::getLastErrorDetail() const +{ + return ""; +} + + +CPPUNIT_NS_END + + +#endif // defined(CPPUNIT_HAVE_UNIX_DLL_LOADER) diff --git a/UnitTests/cppunit/src/cppunit/Win32DynamicLibraryManager.cpp b/UnitTests/cppunit/src/cppunit/Win32DynamicLibraryManager.cpp new file mode 100644 index 000000000..acadf4627 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/Win32DynamicLibraryManager.cpp @@ -0,0 +1,73 @@ +#include + +#if defined(CPPUNIT_HAVE_WIN32_DLL_LOADER) +#include + +#define WIN32_LEAN_AND_MEAN +#define NOGDI +#define NOUSER +#define NOKERNEL +#define NOSOUND +#define NOMINMAX +#define BLENDFUNCTION void // for mingw & gcc +#include + + +CPPUNIT_NS_BEGIN + + +DynamicLibraryManager::LibraryHandle +DynamicLibraryManager::doLoadLibrary( const std::string &libraryName ) +{ + return ::LoadLibraryA( libraryName.c_str() ); +} + + +void +DynamicLibraryManager::doReleaseLibrary() +{ + ::FreeLibrary( (HINSTANCE)m_libraryHandle ); +} + + +DynamicLibraryManager::Symbol +DynamicLibraryManager::doFindSymbol( const std::string &symbol ) +{ + return (DynamicLibraryManager::Symbol)::GetProcAddress( + (HINSTANCE)m_libraryHandle, + symbol.c_str() ); +} + + +std::string +DynamicLibraryManager::getLastErrorDetail() const +{ + LPVOID lpMsgBuf; + ::FormatMessageA( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPSTR) &lpMsgBuf, + 0, + NULL + ); + + std::string message = (LPCSTR)lpMsgBuf; + + // Display the string. +// ::MessageBoxA( NULL, (LPCSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION ); + + // Free the buffer. + ::LocalFree( lpMsgBuf ); + + return message; +} + + +CPPUNIT_NS_END + + +#endif // defined(CPPUNIT_HAVE_WIN32_DLL_LOADER) diff --git a/UnitTests/cppunit/src/cppunit/XmlDocument.cpp b/UnitTests/cppunit/src/cppunit/XmlDocument.cpp new file mode 100644 index 000000000..31f9115a7 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/XmlDocument.cpp @@ -0,0 +1,106 @@ +#include +#include +#include + + +CPPUNIT_NS_BEGIN + + +XmlDocument::XmlDocument( const std::string &encoding, + const std::string &styleSheet ) + : m_styleSheet( styleSheet ) + , m_rootElement( new XmlElement( "DummyRoot" ) ) + , m_standalone( true ) +{ + setEncoding( encoding ); +} + + +XmlDocument::~XmlDocument() +{ + delete m_rootElement; +} + + + +std::string +XmlDocument::encoding() const +{ + return m_encoding; +} + + +void +XmlDocument::setEncoding( const std::string &encoding ) +{ + m_encoding = encoding.empty() ? std::string("ISO-8859-1") : encoding; +} + + +std::string +XmlDocument::styleSheet() const +{ + return m_styleSheet; +} + + +void +XmlDocument::setStyleSheet( const std::string &styleSheet ) +{ + m_styleSheet = styleSheet; +} + + +bool +XmlDocument::standalone() const +{ + return m_standalone; +} + + +void +XmlDocument::setStandalone( bool standalone ) +{ + m_standalone = standalone; +} + + +void +XmlDocument::setRootElement( XmlElement *rootElement ) +{ + if ( rootElement == m_rootElement ) + return; + + delete m_rootElement; + m_rootElement = rootElement; +} + + +XmlElement & +XmlDocument::rootElement() const +{ + return *m_rootElement; +} + + +std::string +XmlDocument::toString() const +{ + std::string asString = "\n"; + + if ( !m_styleSheet.empty() ) + asString += "\n"; + + asString += m_rootElement->toString(); + + return asString; +} + + +CPPUNIT_NS_END + diff --git a/UnitTests/cppunit/src/cppunit/XmlElement.cpp b/UnitTests/cppunit/src/cppunit/XmlElement.cpp new file mode 100644 index 000000000..f930ad4e9 --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/XmlElement.cpp @@ -0,0 +1,226 @@ +#include +#include +#include + + +CPPUNIT_NS_BEGIN + + +XmlElement::XmlElement( std::string elementName, + std::string content ) + : m_name( elementName ) + , m_content( content ) +{ +} + + +XmlElement::XmlElement( std::string elementName, + int numericContent ) + : m_name( elementName ) +{ + setContent( numericContent ); +} + + +XmlElement::~XmlElement() +{ + Elements::iterator itNode = m_elements.begin(); + while ( itNode != m_elements.end() ) + { + XmlElement *element = *itNode++; + delete element; + } +} + + +std::string +XmlElement::name() const +{ + return m_name; +} + + +std::string +XmlElement::content() const +{ + return m_content; +} + + +void +XmlElement::setName( const std::string &name ) +{ + m_name = name; +} + + +void +XmlElement::setContent( const std::string &content ) +{ + m_content = content; +} + + +void +XmlElement::setContent( int numericContent ) +{ + m_content = StringTools::toString( numericContent ); +} + + +void +XmlElement::addAttribute( std::string attributeName, + std::string value ) +{ + m_attributes.push_back( Attribute( attributeName, value ) ); +} + + +void +XmlElement::addAttribute( std::string attributeName, + int numericValue ) +{ + addAttribute( attributeName, StringTools::toString( numericValue ) ); +} + + +void +XmlElement::addElement( XmlElement *node ) +{ + m_elements.push_back( node ); +} + + +int +XmlElement::elementCount() const +{ + return m_elements.size(); +} + + +XmlElement * +XmlElement::elementAt( int index ) const +{ + if ( index < 0 || index >= elementCount() ) + throw std::invalid_argument( "XmlElement::elementAt(), out of range index" ); + + return m_elements[ index ]; +} + + +XmlElement * +XmlElement::elementFor( const std::string &name ) const +{ + Elements::const_iterator itElement = m_elements.begin(); + for ( ; itElement != m_elements.end(); ++itElement ) + { + if ( (*itElement)->name() == name ) + return *itElement; + } + + throw std::invalid_argument( "XmlElement::elementFor(), not matching child element found" ); + return NULL; // make some compilers happy. +} + + +std::string +XmlElement::toString( const std::string &indent ) const +{ + std::string element( indent ); + element += "<"; + element += m_name; + if ( !m_attributes.empty() ) + { + element += " "; + element += attributesAsString(); + } + element += ">"; + + if ( !m_elements.empty() ) + { + element += "\n"; + + std::string subNodeIndent( indent + " " ); + Elements::const_iterator itNode = m_elements.begin(); + while ( itNode != m_elements.end() ) + { + const XmlElement *node = *itNode++; + element += node->toString( subNodeIndent ); + } + + element += indent; + } + + if ( !m_content.empty() ) + { + element += escape( m_content ); + if ( !m_elements.empty() ) + { + element += "\n"; + element += indent; + } + } + + element += "\n"; + + return element; +} + + +std::string +XmlElement::attributesAsString() const +{ + std::string attributes; + Attributes::const_iterator itAttribute = m_attributes.begin(); + while ( itAttribute != m_attributes.end() ) + { + if ( !attributes.empty() ) + attributes += " "; + + const Attribute &attribute = *itAttribute++; + attributes += attribute.first; + attributes += "=\""; + attributes += escape( attribute.second ); + attributes += "\""; + } + return attributes; +} + + +std::string +XmlElement::escape( std::string value ) const +{ + std::string escaped; + for ( unsigned int index =0; index < value.length(); ++index ) + { + char c = value[index ]; + switch ( c ) // escape all predefined XML entity (safe?) + { + case '<': + escaped += "<"; + break; + case '>': + escaped += ">"; + break; + case '&': + escaped += "&"; + break; + case '\'': + escaped += "'"; + break; + case '"': + escaped += """; + break; + default: + escaped += c; + } + } + + return escaped; +} + + +CPPUNIT_NS_END + diff --git a/UnitTests/cppunit/src/cppunit/XmlOutputter.cpp b/UnitTests/cppunit/src/cppunit/XmlOutputter.cpp new file mode 100644 index 000000000..c605e335c --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/XmlOutputter.cpp @@ -0,0 +1,205 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +CPPUNIT_NS_BEGIN + + +XmlOutputter::XmlOutputter( TestResultCollector *result, + OStream &stream, + std::string encoding ) + : m_result( result ) + , m_stream( stream ) + , m_xml( new XmlDocument( encoding ) ) +{ +} + + +XmlOutputter::~XmlOutputter() +{ + delete m_xml; +} + + +void +XmlOutputter::addHook( XmlOutputterHook *hook ) +{ + m_hooks.push_back( hook ); +} + + +void +XmlOutputter::removeHook( XmlOutputterHook *hook ) +{ + m_hooks.erase( std::find( m_hooks.begin(), m_hooks.end(), hook ) ); +} + + +void +XmlOutputter::write() +{ + setRootNode(); + m_stream << m_xml->toString(); +} + + +void +XmlOutputter::setStyleSheet( const std::string &styleSheet ) +{ + m_xml->setStyleSheet( styleSheet ); +} + + +void +XmlOutputter::setStandalone( bool standalone ) +{ + m_xml->setStandalone( standalone ); +} + + +void +XmlOutputter::setRootNode() +{ + XmlElement *rootNode = new XmlElement( "TestRun" ); + m_xml->setRootElement( rootNode ); + + for ( Hooks::iterator it = m_hooks.begin(); it != m_hooks.end(); ++it ) + (*it)->beginDocument( m_xml ); + + FailedTests failedTests; + fillFailedTestsMap( failedTests ); + + addFailedTests( failedTests, rootNode ); + addSuccessfulTests( failedTests, rootNode ); + addStatistics( rootNode ); + + for ( Hooks::iterator itEnd = m_hooks.begin(); itEnd != m_hooks.end(); ++itEnd ) + (*itEnd)->endDocument( m_xml ); +} + + +void +XmlOutputter::fillFailedTestsMap( FailedTests &failedTests ) +{ + const TestResultCollector::TestFailures &failures = m_result->failures(); + TestResultCollector::TestFailures::const_iterator itFailure = failures.begin(); + while ( itFailure != failures.end() ) + { + TestFailure *failure = *itFailure++; + failedTests.insert( std::pair(failure->failedTest(), failure ) ); + } +} + + +void +XmlOutputter::addFailedTests( FailedTests &failedTests, + XmlElement *rootNode ) +{ + XmlElement *testsNode = new XmlElement( "FailedTests" ); + rootNode->addElement( testsNode ); + + const TestResultCollector::Tests &tests = m_result->tests(); + for ( unsigned int testNumber = 0; testNumber < tests.size(); ++testNumber ) + { + Test *test = tests[testNumber]; + if ( failedTests.find( test ) != failedTests.end() ) + addFailedTest( test, failedTests[test], testNumber+1, testsNode ); + } +} + + +void +XmlOutputter::addSuccessfulTests( FailedTests &failedTests, + XmlElement *rootNode ) +{ + XmlElement *testsNode = new XmlElement( "SuccessfulTests" ); + rootNode->addElement( testsNode ); + + const TestResultCollector::Tests &tests = m_result->tests(); + for ( unsigned int testNumber = 0; testNumber < tests.size(); ++testNumber ) + { + Test *test = tests[testNumber]; + if ( failedTests.find( test ) == failedTests.end() ) + addSuccessfulTest( test, testNumber+1, testsNode ); + } +} + + +void +XmlOutputter::addStatistics( XmlElement *rootNode ) +{ + XmlElement *statisticsElement = new XmlElement( "Statistics" ); + rootNode->addElement( statisticsElement ); + statisticsElement->addElement( new XmlElement( "Tests", m_result->runTests() ) ); + statisticsElement->addElement( new XmlElement( "FailuresTotal", + m_result->testFailuresTotal() ) ); + statisticsElement->addElement( new XmlElement( "Errors", m_result->testErrors() ) ); + statisticsElement->addElement( new XmlElement( "Failures", m_result->testFailures() ) ); + + for ( Hooks::iterator it = m_hooks.begin(); it != m_hooks.end(); ++it ) + (*it)->statisticsAdded( m_xml, statisticsElement ); +} + + +void +XmlOutputter::addFailedTest( Test *test, + TestFailure *failure, + int testNumber, + XmlElement *testsNode ) +{ + Exception *thrownException = failure->thrownException(); + + XmlElement *testElement = new XmlElement( "FailedTest" ); + testsNode->addElement( testElement ); + testElement->addAttribute( "id", testNumber ); + testElement->addElement( new XmlElement( "Name", test->getName() ) ); + testElement->addElement( new XmlElement( "FailureType", + failure->isError() ? "Error" : + "Assertion" ) ); + + if ( failure->sourceLine().isValid() ) + addFailureLocation( failure, testElement ); + + testElement->addElement( new XmlElement( "Message", thrownException->what() ) ); + + for ( Hooks::iterator it = m_hooks.begin(); it != m_hooks.end(); ++it ) + (*it)->failTestAdded( m_xml, testElement, test, failure ); +} + + +void +XmlOutputter::addFailureLocation( TestFailure *failure, + XmlElement *testElement ) +{ + XmlElement *locationNode = new XmlElement( "Location" ); + testElement->addElement( locationNode ); + SourceLine sourceLine = failure->sourceLine(); + locationNode->addElement( new XmlElement( "File", sourceLine.fileName() ) ); + locationNode->addElement( new XmlElement( "Line", sourceLine.lineNumber() ) ); +} + + +void +XmlOutputter::addSuccessfulTest( Test *test, + int testNumber, + XmlElement *testsNode ) +{ + XmlElement *testElement = new XmlElement( "Test" ); + testsNode->addElement( testElement ); + testElement->addAttribute( "id", testNumber ); + testElement->addElement( new XmlElement( "Name", test->getName() ) ); + + for ( Hooks::iterator it = m_hooks.begin(); it != m_hooks.end(); ++it ) + (*it)->successfulTestAdded( m_xml, testElement, test ); +} + + +CPPUNIT_NS_END diff --git a/UnitTests/cppunit/src/cppunit/XmlOutputterHook.cpp b/UnitTests/cppunit/src/cppunit/XmlOutputterHook.cpp new file mode 100644 index 000000000..53d10f6ea --- /dev/null +++ b/UnitTests/cppunit/src/cppunit/XmlOutputterHook.cpp @@ -0,0 +1,44 @@ +#include + + +CPPUNIT_NS_BEGIN + + +void +XmlOutputterHook::beginDocument( XmlDocument * ) +{ +} + + +void +XmlOutputterHook::endDocument( XmlDocument * ) +{ +} + + +void +XmlOutputterHook::failTestAdded( XmlDocument *, + XmlElement *, + Test *, + TestFailure * ) +{ +} + + +void +XmlOutputterHook::successfulTestAdded( XmlDocument *, + XmlElement *, + Test * ) +{ +} + + +void +XmlOutputterHook::statisticsAdded( XmlDocument *, + XmlElement * ) +{ +} + + +CPPUNIT_NS_END +