]>
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 | extern IntlTest *createFormattedStringBuilderTest(); | |
76 | extern IntlTest *createStringSegmentTest(); | |
77 | ||
78 | ||
79 | #define TESTCLASS(id, TestClass) \ | |
80 | case id: \ | |
81 | name = #TestClass; \ | |
82 | if (exec) { \ | |
83 | logln(#TestClass " test---"); \ | |
84 | logln((UnicodeString)""); \ | |
85 | TestClass test; \ | |
86 | callTest(test, par); \ | |
87 | } \ | |
88 | break | |
89 | ||
90 | void IntlTestFormat::runIndexedTest( int32_t index, UBool exec, const char* &name, char* par ) | |
91 | { | |
92 | // for all format tests, always set default Locale and TimeZone to ENGLISH and PST. | |
93 | TimeZone* saveDefaultTimeZone = NULL; | |
94 | Locale saveDefaultLocale = Locale::getDefault(); | |
95 | if (exec) { | |
96 | saveDefaultTimeZone = TimeZone::createDefault(); | |
97 | TimeZone *tz = TimeZone::createTimeZone("America/Los_Angeles"); | |
98 | TimeZone::setDefault(*tz); | |
99 | delete tz; | |
100 | UErrorCode status = U_ZERO_ERROR; | |
101 | Locale::setDefault( Locale::getEnglish(), status ); | |
102 | if (U_FAILURE(status)) { | |
103 | errln("itformat: couldn't set default Locale to ENGLISH!"); | |
104 | } | |
105 | } | |
106 | if (exec) logln("TestSuite Format: "); | |
107 | switch (index) { | |
108 | TESTCLASS(0,IntlTestDateFormat); | |
109 | TESTCLASS(1,IntlTestNumberFormat); | |
110 | TESTCLASS(2,CalendarTest); | |
111 | TESTCLASS(3,CalendarLimitTest); | |
112 | TESTCLASS(4,TimeZoneTest); | |
113 | TESTCLASS(5,TimeZoneBoundaryTest); | |
114 | TESTCLASS(6,TestChoiceFormat); | |
115 | TESTCLASS(7,IntlTestDecimalFormatSymbols); | |
116 | TESTCLASS(8,IntlTestDateFormatSymbols); | |
117 | TESTCLASS(9,IntlTestDecimalFormatAPI); | |
118 | TESTCLASS(10,TestFormatSmallClasses); | |
119 | TESTCLASS(11,IntlTestNumberFormatAPI); | |
120 | TESTCLASS(12,IntlTestSimpleDateFormatAPI); | |
121 | TESTCLASS(13,IntlTestDateFormatAPI); | |
122 | TESTCLASS(14,DateFormatTest); | |
123 | TESTCLASS(15,TestMessageFormat); | |
124 | TESTCLASS(16,NumberFormatTest); | |
125 | TESTCLASS(17,DateFormatRegressionTest); | |
126 | TESTCLASS(18,MessageFormatRegressionTest); | |
127 | TESTCLASS(19,DateFormatMiscTests); | |
128 | TESTCLASS(20,NumberFormatRoundTripTest); | |
129 | TESTCLASS(21,NumberFormatRegressionTest); | |
130 | TESTCLASS(22,DateFormatRoundTripTest); | |
131 | TESTCLASS(23,ParsePositionTest); | |
132 | TESTCLASS(24,CalendarRegressionTest); | |
133 | TESTCLASS(25,TimeZoneRegressionTest); | |
134 | TESTCLASS(26,IntlCalendarTest); | |
135 | TESTCLASS(27,AstroTest); | |
136 | TESTCLASS(28,CalendarCaseTest); | |
137 | TESTCLASS(29,TimeZoneRuleTest); | |
138 | #if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION | |
139 | TESTCLASS(30,DataDrivenCalendarTest); | |
140 | TESTCLASS(31,DataDrivenFormatTest); | |
141 | #endif | |
142 | TESTCLASS(32,IntlTestDateTimePatternGeneratorAPI); | |
143 | TESTCLASS(33,TimeZoneOffsetLocalTest); | |
144 | TESTCLASS(34,TimeZoneFormatTest); | |
145 | TESTCLASS(35,PluralRulesTest); | |
146 | TESTCLASS(36,PluralFormatTest); | |
147 | TESTCLASS(37,DateIntervalFormatTest); | |
148 | case 38: | |
149 | name = "TimeUnitTest"; | |
150 | if (exec) { | |
151 | logln("TimeUnitTest test---"); | |
152 | logln((UnicodeString)""); | |
153 | LocalPointer<IntlTest> test(createTimeUnitTest()); | |
154 | callTest(*test, par); | |
155 | } | |
156 | break; | |
157 | TESTCLASS(39,SelectFormatTest); | |
158 | TESTCLASS(40,LocaleDisplayNamesTest); | |
159 | #if !UCONFIG_NO_REGULAR_EXPRESSIONS | |
160 | TESTCLASS(41,DecimalFormatTest); | |
161 | #endif | |
162 | TESTCLASS(42,ListFormatterTest); | |
163 | case 43: | |
164 | name = "GenderInfoTest"; | |
165 | if (exec) { | |
166 | logln("GenderInfoTest test---"); | |
167 | logln((UnicodeString)""); | |
168 | LocalPointer<IntlTest> test(createGenderInfoTest()); | |
169 | callTest(*test, par); | |
170 | } | |
171 | break; | |
172 | case 44: | |
173 | name = "CompactDecimalFormatTest"; | |
174 | if (exec) { | |
175 | logln("CompactDecimalFormatTest test---"); | |
176 | logln((UnicodeString)""); | |
177 | LocalPointer<IntlTest> test(createCompactDecimalFormatTest()); | |
178 | callTest(*test, par); | |
179 | } | |
180 | break; | |
181 | TESTCLASS(45,RegionTest); | |
182 | case 46: | |
183 | #if !UCONFIG_NO_BREAK_ITERATION | |
184 | name = "RelativeDateTimeFormatterTest"; | |
185 | if (exec) { | |
186 | logln("RelativeDateTimeFormatterTest test---"); | |
187 | logln((UnicodeString)""); | |
188 | LocalPointer<IntlTest> test(createRelativeDateTimeFormatterTest()); | |
189 | callTest(*test, par); | |
190 | } | |
191 | #endif | |
192 | break; | |
193 | case 47: | |
194 | name = "MeasureFormatTest"; | |
195 | if (exec) { | |
196 | logln("MeasureFormatTest test---"); | |
197 | logln((UnicodeString)""); | |
198 | LocalPointer<IntlTest> test(createMeasureFormatTest()); | |
199 | callTest(*test, par); | |
200 | } | |
201 | break; | |
202 | case 48: | |
203 | name = "NumberFormatSpecificationTest"; | |
204 | if (exec) { | |
205 | logln("NumberFormatSpecificationTest test---"); | |
206 | logln((UnicodeString)""); | |
207 | LocalPointer<IntlTest> test(createNumberFormatSpecificationTest()); | |
208 | callTest(*test, par); | |
209 | } | |
210 | break; | |
211 | case 49: | |
212 | name = "ScientificNumberFormatterTest"; | |
213 | if (exec) { | |
214 | logln("ScientificNumberFormatterTest test---"); | |
215 | logln((UnicodeString)""); | |
216 | LocalPointer<IntlTest> test(createScientificNumberFormatterTest()); | |
217 | callTest(*test, par); | |
218 | } | |
219 | break; | |
220 | TESTCLASS(50,NumberFormatDataDrivenTest); | |
221 | TESTCLASS(51,NumberTest); | |
222 | TESTCLASS(52,EraRulesTest); | |
223 | case 53: | |
224 | name = "FormattedValueTest"; | |
225 | if (exec) { | |
226 | logln("FormattedValueTest test---"); | |
227 | logln((UnicodeString)""); | |
228 | LocalPointer<IntlTest> test(createFormattedValueTest()); | |
229 | callTest(*test, par); | |
230 | } | |
231 | break; | |
232 | case 54: | |
233 | name = "FormattedStringBuilderTest"; | |
234 | if (exec) { | |
235 | logln("FormattedStringBuilderTest test---"); | |
236 | logln((UnicodeString)""); | |
237 | LocalPointer<IntlTest> test(createFormattedStringBuilderTest()); | |
238 | callTest(*test, par); | |
239 | } | |
240 | break; | |
241 | case 55: | |
242 | name = "StringSegmentTest"; | |
243 | if (exec) { | |
244 | logln("StringSegmentTest test---"); | |
245 | logln((UnicodeString)""); | |
246 | LocalPointer<IntlTest> test(createStringSegmentTest()); | |
247 | callTest(*test, par); | |
248 | } | |
249 | break; | |
250 | default: name = ""; break; //needed to end loop | |
251 | } | |
252 | if (exec) { | |
253 | // restore saved Locale and TimeZone | |
254 | TimeZone::adoptDefault(saveDefaultTimeZone); | |
255 | UErrorCode status = U_ZERO_ERROR; | |
256 | Locale::setDefault( saveDefaultLocale, status ); | |
257 | if (U_FAILURE(status)) { | |
258 | errln("itformat: couldn't re-set default Locale!"); | |
259 | } | |
260 | } | |
261 | } | |
262 | ||
263 | #endif /* #if !UCONFIG_NO_FORMATTING */ |