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