]> git.saurik.com Git - apple/icu.git/blob - icuSources/tools/ctestfw/unicode/tstdtmod.h
ICU-6.2.8.tar.gz
[apple/icu.git] / icuSources / tools / ctestfw / unicode / tstdtmod.h
1 /********************************************************************
2 * COPYRIGHT:
3 * Copyright (c) 2002-2004, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
6
7 /* Created by weiv 05/09/2002 */
8
9 /* Base class for data driven tests */
10
11 #ifndef U_TESTFW_TESTMODULE
12 #define U_TESTFW_TESTMODULE
13
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"
20
21 /* This class abstracts the actual organization of the
22 * data for data driven tests
23 */
24
25
26 class DataMap;
27 class TestData;
28
29
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
33 */
34 class T_CTEST_EXPORT_API TestDataModule {
35 const char* testName;
36
37 protected:
38 DataMap *fInfo;
39 TestLog& fLog;
40
41 public:
42 /** Factory method.
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
47 */
48 static TestDataModule *getTestDataModule(const char* name, TestLog& log, UErrorCode &status);
49 virtual ~TestDataModule();
50
51 protected:
52 TestDataModule(const char* name, TestLog& log, UErrorCode& status);
53
54 public:
55 /** Name of this TestData module.
56 * @return a name
57 */
58 const char * getName() const;
59
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
65 */
66 virtual UBool getInfo(const DataMap *& info, UErrorCode &status) const = 0;
67
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
72 * the tests.
73 */
74 virtual TestData* createTestData(int32_t index, UErrorCode &status) const = 0;
75
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
79 * the tests.
80 */
81 virtual TestData* createTestData(const char* name, UErrorCode &status) const = 0;
82 };
83
84 class T_CTEST_EXPORT_API RBTestDataModule : public TestDataModule {
85 public:
86 virtual ~RBTestDataModule();
87
88 public:
89 RBTestDataModule(const char* name, TestLog& log, UErrorCode& status);
90
91 public:
92 virtual UBool getInfo(const DataMap *& info, UErrorCode &status) const;
93
94 virtual TestData* createTestData(int32_t index, UErrorCode &status) const;
95 virtual TestData* createTestData(const char* name, UErrorCode &status) const;
96
97 private:
98 UResourceBundle *getTestBundle(const char* bundleName, UErrorCode &status);
99
100 private:
101 UResourceBundle *fModuleBundle;
102 UResourceBundle *fTestData;
103 UResourceBundle *fInfoRB;
104 UBool fDataTestValid;
105 char *tdpath;
106
107 /* const char* fTestName;*/ /* See name */
108 int32_t fNumberOfTests;
109
110 };
111
112
113 #endif