1 /********************************************************************
3 * Copyright (c) 2002-2004, 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"
21 /* This class abstracts the actual organization of the
22 * data for data driven tests
30 /** Main data driven test class. Corresponds to one named data
31 * unit (such as a resource bundle. It is instantiated using
32 * a factory method getTestDataModule
34 class T_CTEST_EXPORT_API TestDataModule
{
43 * @param name name of the test module. Usually name of a resource bundle or a XML file
44 * @param log a logging class, used for internal error reporting.
45 * @param status if something goes wrong, status will be set
46 * @return a TestDataModule object. Use it to get test data from it
48 static TestDataModule
*getTestDataModule(const char* name
, TestLog
& log
, UErrorCode
&status
);
49 virtual ~TestDataModule();
52 TestDataModule(const char* name
, TestLog
& log
, UErrorCode
& status
);
55 /** Name of this TestData module.
58 const char * getName() const;
60 /** Get a pointer to an object owned DataMap that contains more information on this module
61 * Usual fields are "Description", "LongDescription", "Settings". Also, if containing a
62 * field "Headers" these will be used as the default headers, so that you don't have to
63 * to specify per test headers.
64 * @param info pass in a const DataMap pointer. If no info, it will be set to NULL
66 virtual UBool
getInfo(const DataMap
*& info
, UErrorCode
&status
) const = 0;
68 /** Create a test data object from an index. Helpful for integrating tests with current
69 * intltest framework which addresses the tests by index.
70 * @param index index of the test to be instantiated
71 * @return an instantiated TestData object, ready to provide settings and cases for
74 virtual TestData
* createTestData(int32_t index
, UErrorCode
&status
) const = 0;
76 /** Create a test data object from a name.
77 * @param name name of the test to be instantiated
78 * @return an instantiated TestData object, ready to provide settings and cases for
81 virtual TestData
* createTestData(const char* name
, UErrorCode
&status
) const = 0;
84 class T_CTEST_EXPORT_API RBTestDataModule
: public TestDataModule
{
86 virtual ~RBTestDataModule();
89 RBTestDataModule(const char* name
, TestLog
& log
, UErrorCode
& status
);
92 virtual UBool
getInfo(const DataMap
*& info
, UErrorCode
&status
) const;
94 virtual TestData
* createTestData(int32_t index
, UErrorCode
&status
) const;
95 virtual TestData
* createTestData(const char* name
, UErrorCode
&status
) const;
98 UResourceBundle
*getTestBundle(const char* bundleName
, UErrorCode
&status
);
101 UResourceBundle
*fModuleBundle
;
102 UResourceBundle
*fTestData
;
103 UResourceBundle
*fInfoRB
;
104 UBool fDataTestValid
;
107 /* const char* fTestName;*/ /* See name */
108 int32_t fNumberOfTests
;