]> git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/tstdtmod.h
ICU-3.13.tar.gz
[apple/icu.git] / icuSources / test / intltest / tstdtmod.h
1 /********************************************************************
2 * COPYRIGHT:
3 * Copyright (c) 2002, 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 INTLTST_TESTMODULE
12 #define INTLTST_TESTMODULE
13
14 #include "unicode/utypes.h"
15 #include "unicode/unistr.h"
16 #include "intltest.h"
17 #include "unicode/ures.h"
18 #include "testdata.h"
19 #include "datamap.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 /** Facilitates internal logging of data driven test service
30 * It would be interesting to develop this into a full
31 * fledged control system as in Java.
32 */
33 class TestLog : public IntlTest{
34 };
35
36
37 /** Main data driven test class. Corresponds to one named data
38 * unit (such as a resource bundle. It is instantiated using
39 * a factory method getTestDataModule
40 */
41 class TestDataModule {
42 const char* testName;
43
44 protected:
45 DataMap *fInfo;
46 TestLog& fLog;
47
48 public:
49 /** Factory method.
50 * @param name name of the test module. Usually name of a resource bundle or a XML file
51 * @param log a logging class, used for internal error reporting.
52 * @param status if something goes wrong, status will be set
53 * @return a TestDataModule object. Use it to get test data from it
54 */
55 static TestDataModule *getTestDataModule(const char* name, TestLog& log, UErrorCode &status);
56 virtual ~TestDataModule();
57
58 protected:
59 TestDataModule(const char* name, TestLog& log, UErrorCode& status);
60
61 public:
62 /** Name of this TestData module.
63 * @return a name
64 */
65 const char * getName() const;
66
67 /** Get a pointer to an object owned DataMap that contains more information on this module
68 * Usual fields are "Description", "LongDescription", "Settings". Also, if containing a
69 * field "Headers" these will be used as the default headers, so that you don't have to
70 * to specify per test headers.
71 * @param info pass in a const DataMap pointer. If no info, it will be set to NULL
72 */
73 virtual UBool getInfo(const DataMap *& info, UErrorCode &status) const = 0;
74
75 /** Create a test data object from an index. Helpful for integrating tests with current
76 * intltest framework which addresses the tests by index.
77 * @param index index 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(int32_t index, UErrorCode &status) const = 0;
82
83 /** Create a test data object from a name.
84 * @param name name of the test to be instantiated
85 * @return an instantiated TestData object, ready to provide settings and cases for
86 * the tests.
87 */
88 virtual TestData* createTestData(const char* name, UErrorCode &status) const = 0;
89 };
90
91 class RBTestDataModule : public TestDataModule {
92 public:
93 virtual ~RBTestDataModule();
94
95 public:
96 RBTestDataModule(const char* name, TestLog& log, UErrorCode& status);
97
98 public:
99 virtual UBool getInfo(const DataMap *& info, UErrorCode &status) const;
100
101 virtual TestData* createTestData(int32_t index, UErrorCode &status) const;
102 virtual TestData* createTestData(const char* name, UErrorCode &status) const;
103
104 private:
105 UResourceBundle *getTestBundle(const char* bundleName, UErrorCode &status);
106
107 private:
108 UResourceBundle *fModuleBundle;
109 UResourceBundle *fTestData;
110 UResourceBundle *fInfoRB;
111 UBool fDataTestValid;
112 char *tdpath;
113
114 /* const char* fTestName;*/ /* See name */
115 int32_t fNumberOfTests;
116
117 };
118
119
120 #endif