]>
Commit | Line | Data |
---|---|---|
1 | // © 2016 and later: Unicode, Inc. and others. | |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
3 | /******************************************************************** | |
4 | * COPYRIGHT: | |
5 | * Copyright (c) 1997-2015, International Business Machines | |
6 | * Corporation and others. All Rights Reserved. | |
7 | ********************************************************************/ | |
8 | ||
9 | /** | |
10 | * IntlTestFormat is the medium level test class for everything in the directory "format". | |
11 | */ | |
12 | ||
13 | #include "unicode/utypes.h" | |
14 | #include "unicode/localpointer.h" | |
15 | ||
16 | #if !UCONFIG_NO_FORMATTING | |
17 | ||
18 | #include "itformat.h" | |
19 | #include "tsdate.h" | |
20 | #include "tsnmfmt.h" | |
21 | #include "caltest.h" | |
22 | #include "callimts.h" | |
23 | #include "tztest.h" | |
24 | #include "tzbdtest.h" | |
25 | #include "tsdcfmsy.h" // DecimalFormatSymbols | |
26 | #include "tchcfmt.h" | |
27 | #include "tsdtfmsy.h" // DateFormatSymbols | |
28 | #include "dcfmapts.h" // DecimalFormatAPI | |
29 | #include "tfsmalls.h" // Format Small Classes | |
30 | #include "nmfmapts.h" // NumberFormatAPI | |
31 | #include "numfmtst.h" // NumberFormatTest | |
32 | #include "sdtfmtts.h" // SimpleDateFormatAPI | |
33 | #include "dtfmapts.h" // DateFormatAPI | |
34 | #include "dtfmttst.h" // DateFormatTest | |
35 | #include "tmsgfmt.h" // TestMessageFormat | |
36 | #include "dtfmrgts.h" // DateFormatRegressionTest | |
37 | #include "msfmrgts.h" // MessageFormatRegressionTest | |
38 | #include "miscdtfm.h" // DateFormatMiscTests | |
39 | #include "nmfmtrt.h" // NumberFormatRoundTripTest | |
40 | #include "numrgts.h" // NumberFormatRegressionTest | |
41 | #include "dtfmtrtts.h" // DateFormatRoundTripTest | |
42 | #include "pptest.h" // ParsePositionTest | |
43 | #include "calregts.h" // CalendarRegressionTest | |
44 | #include "tzregts.h" // TimeZoneRegressionTest | |
45 | #include "astrotst.h" // AstroTest | |
46 | #include "incaltst.h" // IntlCalendarTest | |
47 | #include "calcasts.h" // CalendarCaseTest | |
48 | #include "tzrulets.h" // TimeZoneRuleTest | |
49 | #include "dadrcal.h" // DataDrivenCalendarTest | |
50 | #include "dadrfmt.h" // DataDrivenFormatTest | |
51 | #include "dtptngts.h" // IntlTestDateTimePatternGeneratorAPI | |
52 | #include "tzoffloc.h" // TimeZoneOffsetLocalTest | |
53 | #include "tzfmttst.h" // TimeZoneFormatTest | |
54 | #include "plurults.h" // PluralRulesTest | |
55 | #include "plurfmts.h" // PluralFormatTest | |
56 | #include "selfmts.h" // PluralFormatTest | |
57 | #include "dtifmtts.h" // DateIntervalFormatTest | |
58 | #include "locnmtst.h" // LocaleDisplayNamesTest | |
59 | #include "dcfmtest.h" // DecimalFormatTest | |
60 | #include "listformattertest.h" // ListFormatterTest | |
61 | #include "regiontst.h" // RegionTest | |
62 | #include "numbertest.h" // NumberTest | |
63 | #include "erarulestest.h" // EraRulesTest | |
64 | ||
65 | extern IntlTest *createCompactDecimalFormatTest(); | |
66 | extern IntlTest *createGenderInfoTest(); | |
67 | #if !UCONFIG_NO_BREAK_ITERATION | |
68 | extern IntlTest *createRelativeDateTimeFormatterTest(); | |
69 | #endif | |
70 | extern IntlTest *createTimeUnitTest(); | |
71 | extern IntlTest *createMeasureFormatTest(); | |
72 | extern IntlTest *createNumberFormatSpecificationTest(); | |
73 | extern IntlTest *createScientificNumberFormatterTest(); | |
74 | extern IntlTest *createFormattedValueTest(); | |
75 | ||
76 | ||
77 | #define TESTCLASS(id, TestClass) \ | |
78 | case id: \ | |
79 | name = #TestClass; \ | |
80 | if (exec) { \ | |
81 | logln(#TestClass " test---"); \ | |
82 | logln((UnicodeString)""); \ | |
83 | TestClass test; \ | |
84 | callTest(test, par); \ | |
85 | } \ | |
86 | break | |
87 | ||
88 | void IntlTestFormat::runIndexedTest( int32_t index, UBool exec, const char* &name, char* par ) | |
89 | { | |
90 | // for all format tests, always set default Locale and TimeZone to ENGLISH and PST. | |
91 | TimeZone* saveDefaultTimeZone = NULL; | |
92 | Locale saveDefaultLocale = Locale::getDefault(); | |
93 | if (exec) { | |
94 | saveDefaultTimeZone = TimeZone::createDefault(); | |
95 | TimeZone *tz = TimeZone::createTimeZone("America/Los_Angeles"); | |
96 | TimeZone::setDefault(*tz); | |
97 | delete tz; | |
98 | UErrorCode status = U_ZERO_ERROR; | |
99 | Locale::setDefault( Locale::getEnglish(), status ); | |
100 | if (U_FAILURE(status)) { | |
101 | errln("itformat: couldn't set default Locale to ENGLISH!"); | |
102 | } | |
103 | } | |
104 | if (exec) logln("TestSuite Format: "); | |
105 | switch (index) { | |
106 | TESTCLASS(0,IntlTestDateFormat); | |
107 | TESTCLASS(1,IntlTestNumberFormat); | |
108 | TESTCLASS(2,CalendarTest); | |
109 | TESTCLASS(3,CalendarLimitTest); | |
110 | TESTCLASS(4,TimeZoneTest); | |
111 | TESTCLASS(5,TimeZoneBoundaryTest); | |
112 | TESTCLASS(6,TestChoiceFormat); | |
113 | TESTCLASS(7,IntlTestDecimalFormatSymbols); | |
114 | TESTCLASS(8,IntlTestDateFormatSymbols); | |
115 | TESTCLASS(9,IntlTestDecimalFormatAPI); | |
116 | TESTCLASS(10,TestFormatSmallClasses); | |
117 | TESTCLASS(11,IntlTestNumberFormatAPI); | |
118 | TESTCLASS(12,IntlTestSimpleDateFormatAPI); | |
119 | TESTCLASS(13,IntlTestDateFormatAPI); | |
120 | TESTCLASS(14,DateFormatTest); | |
121 | TESTCLASS(15,TestMessageFormat); | |
122 | TESTCLASS(16,NumberFormatTest); | |
123 | TESTCLASS(17,DateFormatRegressionTest); | |
124 | TESTCLASS(18,MessageFormatRegressionTest); | |
125 | TESTCLASS(19,DateFormatMiscTests); | |
126 | TESTCLASS(20,NumberFormatRoundTripTest); | |
127 | TESTCLASS(21,NumberFormatRegressionTest); | |
128 | TESTCLASS(22,DateFormatRoundTripTest); | |
129 | TESTCLASS(23,ParsePositionTest); | |
130 | TESTCLASS(24,CalendarRegressionTest); | |
131 | TESTCLASS(25,TimeZoneRegressionTest); | |
132 | TESTCLASS(26,IntlCalendarTest); | |
133 | TESTCLASS(27,AstroTest); | |
134 | TESTCLASS(28,CalendarCaseTest); | |
135 | TESTCLASS(29,TimeZoneRuleTest); | |
136 | #if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION | |
137 | TESTCLASS(30,DataDrivenCalendarTest); | |
138 | TESTCLASS(31,DataDrivenFormatTest); | |
139 | #endif | |
140 | TESTCLASS(32,IntlTestDateTimePatternGeneratorAPI); | |
141 | TESTCLASS(33,TimeZoneOffsetLocalTest); | |
142 | TESTCLASS(34,TimeZoneFormatTest); | |
143 | TESTCLASS(35,PluralRulesTest); | |
144 | TESTCLASS(36,PluralFormatTest); | |
145 | TESTCLASS(37,DateIntervalFormatTest); | |
146 | case 38: | |
147 | name = "TimeUnitTest"; | |
148 | if (exec) { | |
149 | logln("TimeUnitTest test---"); | |
150 | logln((UnicodeString)""); | |
151 | LocalPointer<IntlTest> test(createTimeUnitTest()); | |
152 | callTest(*test, par); | |
153 | } | |
154 | break; | |
155 | TESTCLASS(39,SelectFormatTest); | |
156 | TESTCLASS(40,LocaleDisplayNamesTest); | |
157 | #if !UCONFIG_NO_REGULAR_EXPRESSIONS | |
158 | TESTCLASS(41,DecimalFormatTest); | |
159 | #endif | |
160 | TESTCLASS(42,ListFormatterTest); | |
161 | case 43: | |
162 | name = "GenderInfoTest"; | |
163 | if (exec) { | |
164 | logln("GenderInfoTest test---"); | |
165 | logln((UnicodeString)""); | |
166 | LocalPointer<IntlTest> test(createGenderInfoTest()); | |
167 | callTest(*test, par); | |
168 | } | |
169 | break; | |
170 | case 44: | |
171 | name = "CompactDecimalFormatTest"; | |
172 | if (exec) { | |
173 | logln("CompactDecimalFormatTest test---"); | |
174 | logln((UnicodeString)""); | |
175 | LocalPointer<IntlTest> test(createCompactDecimalFormatTest()); | |
176 | callTest(*test, par); | |
177 | } | |
178 | break; | |
179 | TESTCLASS(45,RegionTest); | |
180 | case 46: | |
181 | #if !UCONFIG_NO_BREAK_ITERATION | |
182 | name = "RelativeDateTimeFormatterTest"; | |
183 | if (exec) { | |
184 | logln("RelativeDateTimeFormatterTest test---"); | |
185 | logln((UnicodeString)""); | |
186 | LocalPointer<IntlTest> test(createRelativeDateTimeFormatterTest()); | |
187 | callTest(*test, par); | |
188 | } | |
189 | #endif | |
190 | break; | |
191 | case 47: | |
192 | name = "MeasureFormatTest"; | |
193 | if (exec) { | |
194 | logln("MeasureFormatTest test---"); | |
195 | logln((UnicodeString)""); | |
196 | LocalPointer<IntlTest> test(createMeasureFormatTest()); | |
197 | callTest(*test, par); | |
198 | } | |
199 | break; | |
200 | case 48: | |
201 | name = "NumberFormatSpecificationTest"; | |
202 | if (exec) { | |
203 | logln("NumberFormatSpecificationTest test---"); | |
204 | logln((UnicodeString)""); | |
205 | LocalPointer<IntlTest> test(createNumberFormatSpecificationTest()); | |
206 | callTest(*test, par); | |
207 | } | |
208 | break; | |
209 | case 49: | |
210 | name = "ScientificNumberFormatterTest"; | |
211 | if (exec) { | |
212 | logln("ScientificNumberFormatterTest test---"); | |
213 | logln((UnicodeString)""); | |
214 | LocalPointer<IntlTest> test(createScientificNumberFormatterTest()); | |
215 | callTest(*test, par); | |
216 | } | |
217 | break; | |
218 | TESTCLASS(50,NumberFormatDataDrivenTest); | |
219 | TESTCLASS(51,NumberTest); | |
220 | TESTCLASS(52,EraRulesTest); | |
221 | case 53: | |
222 | name = "FormattedValueTest"; | |
223 | if (exec) { | |
224 | logln("FormattedValueTest test---"); | |
225 | logln((UnicodeString)""); | |
226 | LocalPointer<IntlTest> test(createFormattedValueTest()); | |
227 | callTest(*test, par); | |
228 | } | |
229 | break; | |
230 | default: name = ""; break; //needed to end loop | |
231 | } | |
232 | if (exec) { | |
233 | // restore saved Locale and TimeZone | |
234 | TimeZone::adoptDefault(saveDefaultTimeZone); | |
235 | UErrorCode status = U_ZERO_ERROR; | |
236 | Locale::setDefault( saveDefaultLocale, status ); | |
237 | if (U_FAILURE(status)) { | |
238 | errln("itformat: couldn't re-set default Locale!"); | |
239 | } | |
240 | } | |
241 | } | |
242 | ||
243 | #endif /* #if !UCONFIG_NO_FORMATTING */ |