michael@0: /******************************************************************** michael@0: * COPYRIGHT: michael@0: * Copyright (c) 2002-2005, International Business Machines Corporation and michael@0: * others. All Rights Reserved. michael@0: ********************************************************************/ michael@0: michael@0: /* Created by weiv 05/09/2002 */ michael@0: michael@0: /* Base class for data driven tests */ michael@0: michael@0: #ifndef U_TESTFW_TESTMODULE michael@0: #define U_TESTFW_TESTMODULE michael@0: michael@0: #include "unicode/unistr.h" michael@0: #include "unicode/ures.h" michael@0: #include "unicode/testtype.h" michael@0: #include "unicode/testdata.h" michael@0: #include "unicode/datamap.h" michael@0: #include "unicode/testlog.h" michael@0: michael@0: michael@0: /* This class abstracts the actual organization of the michael@0: * data for data driven tests michael@0: */ michael@0: michael@0: michael@0: class DataMap; michael@0: class TestData; michael@0: michael@0: michael@0: /** Main data driven test class. Corresponds to one named data michael@0: * unit (such as a resource bundle. It is instantiated using michael@0: * a factory method getTestDataModule michael@0: */ michael@0: class T_CTEST_EXPORT_API TestDataModule { michael@0: const char* testName; michael@0: michael@0: protected: michael@0: DataMap *fInfo; michael@0: TestLog& fLog; michael@0: michael@0: public: michael@0: /** Factory method. michael@0: * @param name name of the test module. Usually name of a resource bundle or a XML file michael@0: * @param log a logging class, used for internal error reporting. michael@0: * @param status if something goes wrong, status will be set michael@0: * @return a TestDataModule object. Use it to get test data from it michael@0: */ michael@0: static TestDataModule *getTestDataModule(const char* name, TestLog& log, UErrorCode &status); michael@0: virtual ~TestDataModule(); michael@0: michael@0: protected: michael@0: TestDataModule(const char* name, TestLog& log, UErrorCode& status); michael@0: michael@0: public: michael@0: /** Name of this TestData module. michael@0: * @return a name michael@0: */ michael@0: const char * getName() const; michael@0: michael@0: /** Get a pointer to an object owned DataMap that contains more information on this module michael@0: * Usual fields are "Description", "LongDescription", "Settings". Also, if containing a michael@0: * field "Headers" these will be used as the default headers, so that you don't have to michael@0: * to specify per test headers. michael@0: * @param info pass in a const DataMap pointer. If no info, it will be set to NULL michael@0: */ michael@0: virtual UBool getInfo(const DataMap *& info, UErrorCode &status) const = 0; michael@0: michael@0: /** Create a test data object from an index. Helpful for integrating tests with current michael@0: * intltest framework which addresses the tests by index. michael@0: * @param index index of the test to be instantiated michael@0: * @return an instantiated TestData object, ready to provide settings and cases for michael@0: * the tests. michael@0: */ michael@0: virtual TestData* createTestData(int32_t index, UErrorCode &status) const = 0; michael@0: michael@0: /** Create a test data object from a name. michael@0: * @param name name of the test to be instantiated michael@0: * @return an instantiated TestData object, ready to provide settings and cases for michael@0: * the tests. michael@0: */ michael@0: virtual TestData* createTestData(const char* name, UErrorCode &status) const = 0; michael@0: }; michael@0: michael@0: class T_CTEST_EXPORT_API RBTestDataModule : public TestDataModule { michael@0: public: michael@0: virtual ~RBTestDataModule(); michael@0: michael@0: public: michael@0: RBTestDataModule(const char* name, TestLog& log, UErrorCode& status); michael@0: michael@0: public: michael@0: virtual UBool getInfo(const DataMap *& info, UErrorCode &status) const; michael@0: michael@0: virtual TestData* createTestData(int32_t index, UErrorCode &status) const; michael@0: virtual TestData* createTestData(const char* name, UErrorCode &status) const; michael@0: michael@0: private: michael@0: UResourceBundle *getTestBundle(const char* bundleName, UErrorCode &status); michael@0: michael@0: private: michael@0: UResourceBundle *fModuleBundle; michael@0: UResourceBundle *fTestData; michael@0: UResourceBundle *fInfoRB; michael@0: UBool fDataTestValid; michael@0: char *tdpath; michael@0: michael@0: /* const char* fTestName;*/ /* See name */ michael@0: int32_t fNumberOfTests; michael@0: michael@0: }; michael@0: michael@0: michael@0: #endif michael@0: