1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /********************************************************************
5 * Copyright (c) 2002-2005, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 ********************************************************************/
9 /* Created by weiv 05/09/2002 */
11 /* Base class for data driven tests */
13 #ifndef U_TESTFW_TESTMODULE
14 #define U_TESTFW_TESTMODULE
16 #include "unicode/unistr.h"
17 #include "unicode/ures.h"
18 #include "unicode/testtype.h"
19 #include "unicode/testdata.h"
20 #include "unicode/datamap.h"
21 #include "unicode/testlog.h"
24 /* This class abstracts the actual organization of the
25 * data for data driven tests
33 /** Main data driven test class. Corresponds to one named data
34 * unit (such as a resource bundle. It is instantiated using
35 * a factory method getTestDataModule
37 class T_CTEST_EXPORT_API TestDataModule
{
46 * @param name name of the test module. Usually name of a resource bundle or a XML file
47 * @param log a logging class, used for internal error reporting.
48 * @param status if something goes wrong, status will be set
49 * @return a TestDataModule object. Use it to get test data from it
51 static TestDataModule
*getTestDataModule(const char* name
, TestLog
& log
, UErrorCode
&status
);
52 virtual ~TestDataModule();
55 TestDataModule(const char* name
, TestLog
& log
, UErrorCode
& status
);
58 /** Name of this TestData module.
61 const char * getName() const;
63 /** Get a pointer to an object owned DataMap that contains more information on this module
64 * Usual fields are "Description", "LongDescription", "Settings". Also, if containing a
65 * field "Headers" these will be used as the default headers, so that you don't have to
66 * to specify per test headers.
67 * @param info pass in a const DataMap pointer. If no info, it will be set to NULL
69 virtual UBool
getInfo(const DataMap
*& info
, UErrorCode
&status
) const = 0;
71 /** Create a test data object from an index. Helpful for integrating tests with current
72 * intltest framework which addresses the tests by index.
73 * @param index index of the test to be instantiated
74 * @return an instantiated TestData object, ready to provide settings and cases for
77 virtual TestData
* createTestData(int32_t index
, UErrorCode
&status
) const = 0;
79 /** Create a test data object from a name.
80 * @param name name of the test to be instantiated
81 * @return an instantiated TestData object, ready to provide settings and cases for
84 virtual TestData
* createTestData(const char* name
, UErrorCode
&status
) const = 0;
87 class T_CTEST_EXPORT_API RBTestDataModule
: public TestDataModule
{
89 virtual ~RBTestDataModule();
92 RBTestDataModule(const char* name
, TestLog
& log
, UErrorCode
& status
);
95 virtual UBool
getInfo(const DataMap
*& info
, UErrorCode
&status
) const;
97 virtual TestData
* createTestData(int32_t index
, UErrorCode
&status
) const;
98 virtual TestData
* createTestData(const char* name
, UErrorCode
&status
) const;
101 UResourceBundle
*getTestBundle(const char* bundleName
, UErrorCode
&status
);
104 UResourceBundle
*fModuleBundle
;
105 UResourceBundle
*fTestData
;
106 UResourceBundle
*fInfoRB
;
107 UBool fDataTestValid
;
110 /* const char* fTestName;*/ /* See name */
111 int32_t fNumberOfTests
;