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