unittests: Start simplifying test structure
* Rework ByteOrderTest and DateTimeTest to use autoregistration. * Functional changes in ByteOrderTest are confirmed in git history to be R5 compatibility fixes. This doesn't include B_ASCII_TYPE - it seems it has never been part of is_type_swapped(). * Autoregistered test names start with a number - this is because RTTI is used to create them. Disabling RTTI is not an option because CppUnit in our repo has a broken macro which always sets the name to "ATestFixtureType". This is probably fixed in newer CppUnit versions. Change-Id: I56ab5df6e998b6f47fca3c3458a56a761c1740a8 Reviewed-on: https://review.haiku-os.org/c/haiku/+/10266 Reviewed-by: waddlesplash <[email protected]> Tested-by: Commit checker robot <[email protected]> Reviewed-by: Kacper Kasper <[email protected]>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <LockerSyncObject.h>
|
||||
#include <cppunit/Exception.h>
|
||||
#include <cppunit/Test.h>
|
||||
#include <cppunit/TestSuite.h>
|
||||
#include <cppunit/TestListener.h>
|
||||
#include <cppunit/TestResult.h>
|
||||
#include <cppunit/TestResultCollector.h>
|
||||
@@ -61,6 +62,8 @@ public:
|
||||
// the list of tests via a call to AddTest(string
|
||||
status_t AddSuite(BTestSuite *kit);
|
||||
|
||||
status_t AddSuite(CppUnit::TestSuite *suite);
|
||||
|
||||
// This function is used to add test suites to the list of available
|
||||
// tests. The test pointer may not be NULL. The name given is the name that
|
||||
// will be presented when the program is run with "--list" as an argument.
|
||||
@@ -107,7 +110,7 @@ public:
|
||||
|
||||
protected:
|
||||
typedef std::map<std::string, CppUnit::Test*> TestMap;
|
||||
typedef std::map<std::string, BTestSuite*> SuiteMap;
|
||||
typedef std::map<std::string, CppUnit::TestSuite*> SuiteMap;
|
||||
|
||||
VerbosityLevel fVerbosityLevel;
|
||||
std::set<std::string> fTestsToRun;
|
||||
|
||||
@@ -4,5 +4,6 @@
|
||||
class BTestSuite;
|
||||
|
||||
extern "C" CPPUNIT_API BTestSuite* getTestSuite();
|
||||
extern "C" CPPUNIT_API const char* getTestSuiteName();
|
||||
|
||||
#endif // _beos_test_suite_addon_h_
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#include <cppunit/Portability.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
// Handy defines :-)
|
||||
#define CHK CPPUNIT_ASSERT
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace CppUnit {
|
||||
/** Auto-register the suite factory in the specified registry.
|
||||
* \param name Name of the registry.
|
||||
*/
|
||||
AutoRegisterSuite( const string &name )
|
||||
AutoRegisterSuite( const std::string &name )
|
||||
{
|
||||
TestFactory *factory = new TestSuiteFactory<TestCaseType>();
|
||||
TestFactoryRegistry::getRegistry( name ).registerFactory( factory );
|
||||
|
||||
@@ -97,7 +97,11 @@ namespace CppUnit {
|
||||
}
|
||||
|
||||
private:
|
||||
#if __GNUC__ == 2
|
||||
auto_ptr<TestSuite> m_suite;
|
||||
#else
|
||||
std::unique_ptr<TestSuite> m_suite;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace CppUnit
|
||||
|
||||
Reference in New Issue
Block a user