cppunit.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef COMPAT_CPPUNIT_H
  2. #define COMPAT_CPPUNIT_H
  3. /*Code taken from cppunit/extensions/HelperMacros.h version 1.13
  4. If the system doesn't supports the auto_ptr, then this code is used. Otherwise
  5. the cppunit Macros stays untouched.
  6. */
  7. #ifndef HAVE_UNIQUE_PTR
  8. #include <cppunit/extensions/HelperMacros.h>
  9. #undef CPPUNIT_TEST_SUITE_END
  10. #define CPPUNIT_TEST_SUITE_END() \
  11. } \
  12. \
  13. struct CppUnitExDeleter { /* avoid deprecated auto_ptr warnings */ \
  14. CPPUNIT_NS::TestSuite *suite; \
  15. CppUnitExDeleter() : suite (0) {} \
  16. ~CppUnitExDeleter() { delete suite; } \
  17. CPPUNIT_NS::TestSuite *release() { \
  18. CPPUNIT_NS::TestSuite *tmp = suite; suite = NULL; return tmp; \
  19. } \
  20. }; \
  21. \
  22. public: \
  23. static CPPUNIT_NS::TestSuite *suite() \
  24. { \
  25. const CPPUNIT_NS::TestNamer &namer = getTestNamer__(); \
  26. CppUnitExDeleter guard; \
  27. guard.suite = new CPPUNIT_NS::TestSuite( namer.getFixtureName() ); \
  28. CPPUNIT_NS::ConcretTestFixtureFactory<TestFixtureType> factory; \
  29. CPPUNIT_NS::TestSuiteBuilderContextBase context( *guard.suite, \
  30. namer, \
  31. factory ); \
  32. TestFixtureType::addTestsToSuite( context ); \
  33. return guard.release(); \
  34. } \
  35. private: /* dummy typedef so that the macro can still end with ';'*/ \
  36. typedef int CppUnitDummyTypedefForSemiColonEnding__
  37. #else
  38. #include <cppunit/extensions/HelperMacros.h>
  39. #endif /*HAVE_UNIQUE_PTR*/
  40. #endif /* COMPAT_CPPUNIT_H */