1 /********************************************************************
3 * Copyright (c) 2002-2005, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
7 /* Created by weiv 05/09/2002 */
9 /* Base class for data driven tests */
11 #ifndef U_TESTFW_TESTMODULE
12 #define U_TESTFW_TESTMODULE
14 #include "unicode/unistr.h"
15 #include "unicode/ures.h"
16 #include "unicode/testtype.h"
17 #include "unicode/testdata.h"
18 #include "unicode/datamap.h"
19 #include "unicode/testlog.h"
22 /* This class abstracts the actual organization of the
23 * data for data driven tests
31 /** Main data driven test class. Corresponds to one named data
32 * unit (such as a resource bundle. It is instantiated using
33 * a factory method getTestDataModule
35 class T_CTEST_EXPORT_API TestDataModule
{
44 * @param name name of the test module. Usually name of a resource bundle or a XML file
45 * @param log a logging class, used for internal error reporting.
46 * @param status if something goes wrong, status will be set
47 * @return a TestDataModule object. Use it to get test data from it
49 static TestDataModule
*getTestDataModule(const char* name
, TestLog
& log
, UErrorCode
&status
);
50 virtual ~TestDataModule();
53 TestDataModule(const char* name
, TestLog
& log
, UErrorCode
& status
);
56 /** Name of this TestData module.
59 const char * getName() const;
61 /** Get a pointer to an object owned DataMap that contains more information on this module
62 * Usual fields are "Description", "LongDescription", "Settings". Also, if containing a
63 * field "Headers" these will be used as the default headers, so that you don't have to
64 * to specify per test headers.
65 * @param info pass in a const DataMap pointer. If no info, it will be set to NULL
67 virtual UBool
getInfo(const DataMap
*& info
, UErrorCode
&status
) const = 0;
69 /** Create a test data object from an index. Helpful for integrating tests with current
70 * intltest framework which addresses the tests by index.
71 * @param index index of the test to be instantiated
72 * @return an instantiated TestData object, ready to provide settings and cases for
75 virtual TestData
* createTestData(int32_t index
, UErrorCode
&status
) const = 0;
77 /** Create a test data object from a name.
78 * @param name name of the test to be instantiated
79 * @return an instantiated TestData object, ready to provide settings and cases for
82 virtual TestData
* createTestData(const char* name
, UErrorCode
&status
) const = 0;
85 class T_CTEST_EXPORT_API RBTestDataModule
: public TestDataModule
{
87 virtual ~RBTestDataModule();
90 RBTestDataModule(const char* name
, TestLog
& log
, UErrorCode
& status
);
93 virtual UBool
getInfo(const DataMap
*& info
, UErrorCode
&status
) const;
95 virtual TestData
* createTestData(int32_t index
, UErrorCode
&status
) const;
96 virtual TestData
* createTestData(const char* name
, UErrorCode
&status
) const;
99 UResourceBundle
*getTestBundle(const char* bundleName
, UErrorCode
&status
);
102 UResourceBundle
*fModuleBundle
;
103 UResourceBundle
*fTestData
;
104 UResourceBundle
*fInfoRB
;
105 UBool fDataTestValid
;
108 /* const char* fTestName;*/ /* See name */
109 int32_t fNumberOfTests
;