]>
Commit | Line | Data |
---|---|---|
f3c0d7a5 A |
1 | // © 2016 and later: Unicode, Inc. and others. |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
b75a7d8f | 3 | /******************************************************************** |
51004dcb | 4 | * COPYRIGHT: |
2ca993e8 | 5 | * Copyright (c) 1997-2015, International Business Machines |
46f4442e | 6 | * Corporation and others. All Rights Reserved. |
b75a7d8f A |
7 | ********************************************************************/ |
8 | ||
9 | /** | |
10 | * IntlTestFormat is the medium level test class for everything in the directory "format". | |
11 | */ | |
12 | ||
13 | #include "unicode/utypes.h" | |
51004dcb | 14 | #include "unicode/localpointer.h" |
b75a7d8f A |
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 | |
374ca955 | 45 | #include "astrotst.h" // AstroTest |
b75a7d8f | 46 | #include "incaltst.h" // IntlCalendarTest |
374ca955 | 47 | #include "calcasts.h" // CalendarCaseTest |
46f4442e A |
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 | |
729e4ab9 | 56 | #include "selfmts.h" // PluralFormatTest |
46f4442e | 57 | #include "dtifmtts.h" // DateIntervalFormatTest |
729e4ab9 A |
58 | #include "locnmtst.h" // LocaleDisplayNamesTest |
59 | #include "dcfmtest.h" // DecimalFormatTest | |
51004dcb A |
60 | #include "listformattertest.h" // ListFormatterTest |
61 | #include "regiontst.h" // RegionTest | |
0f5d89e8 | 62 | #include "numbertest.h" // NumberTest |
1546d4af | 63 | #include "erarulestest.h" // EraRulesTest |
51004dcb A |
64 | |
65 | extern IntlTest *createCompactDecimalFormatTest(); | |
66 | extern IntlTest *createGenderInfoTest(); | |
b331163b | 67 | #if !UCONFIG_NO_BREAK_ITERATION |
57a6839d | 68 | extern IntlTest *createRelativeDateTimeFormatterTest(); |
b331163b | 69 | #endif |
2ca993e8 | 70 | extern IntlTest *createTimeUnitTest(); |
57a6839d | 71 | extern IntlTest *createMeasureFormatTest(); |
b331163b A |
72 | extern IntlTest *createNumberFormatSpecificationTest(); |
73 | extern IntlTest *createScientificNumberFormatterTest(); | |
3d1f044b | 74 | extern IntlTest *createFormattedValueTest(); |
2ca993e8 | 75 | |
b75a7d8f A |
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(); | |
57a6839d | 95 | TimeZone *tz = TimeZone::createTimeZone("America/Los_Angeles"); |
b75a7d8f A |
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); | |
374ca955 A |
133 | TESTCLASS(27,AstroTest); |
134 | TESTCLASS(28,CalendarCaseTest); | |
46f4442e | 135 | TESTCLASS(29,TimeZoneRuleTest); |
729e4ab9 | 136 | #if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION |
46f4442e A |
137 | TESTCLASS(30,DataDrivenCalendarTest); |
138 | TESTCLASS(31,DataDrivenFormatTest); | |
729e4ab9 | 139 | #endif |
46f4442e A |
140 | TESTCLASS(32,IntlTestDateTimePatternGeneratorAPI); |
141 | TESTCLASS(33,TimeZoneOffsetLocalTest); | |
142 | TESTCLASS(34,TimeZoneFormatTest); | |
143 | TESTCLASS(35,PluralRulesTest); | |
144 | TESTCLASS(36,PluralFormatTest); | |
145 | TESTCLASS(37,DateIntervalFormatTest); | |
2ca993e8 A |
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; | |
729e4ab9 A |
155 | TESTCLASS(39,SelectFormatTest); |
156 | TESTCLASS(40,LocaleDisplayNamesTest); | |
157 | #if !UCONFIG_NO_REGULAR_EXPRESSIONS | |
158 | TESTCLASS(41,DecimalFormatTest); | |
159 | #endif | |
51004dcb A |
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); | |
57a6839d | 180 | case 46: |
b331163b | 181 | #if !UCONFIG_NO_BREAK_ITERATION |
57a6839d A |
182 | name = "RelativeDateTimeFormatterTest"; |
183 | if (exec) { | |
184 | logln("RelativeDateTimeFormatterTest test---"); | |
185 | logln((UnicodeString)""); | |
186 | LocalPointer<IntlTest> test(createRelativeDateTimeFormatterTest()); | |
187 | callTest(*test, par); | |
188 | } | |
b331163b | 189 | #endif |
57a6839d A |
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; | |
b331163b A |
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; | |
0f5d89e8 | 209 | case 49: |
b331163b A |
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; | |
0f5d89e8 A |
218 | TESTCLASS(50,NumberFormatDataDrivenTest); |
219 | TESTCLASS(51,NumberTest); | |
1546d4af | 220 | TESTCLASS(52,EraRulesTest); |
3d1f044b A |
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; | |
b75a7d8f A |
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 */ |