1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /********************************************************************
5 * Copyright (c) 1997-2015, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 ********************************************************************/
10 * IntlTestFormat is the medium level test class for everything in the directory "format".
13 #include "unicode/utypes.h"
14 #include "unicode/localpointer.h"
16 #if !UCONFIG_NO_FORMATTING
25 #include "tsdcfmsy.h" // DecimalFormatSymbols
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
63 extern IntlTest *createCompactDecimalFormatTest();
64 extern IntlTest *createGenderInfoTest();
65 #if !UCONFIG_NO_BREAK_ITERATION
66 extern IntlTest *createRelativeDateTimeFormatterTest();
68 extern IntlTest *createTimeUnitTest();
69 extern IntlTest *createMeasureFormatTest();
70 extern IntlTest *createNumberFormatSpecificationTest();
71 extern IntlTest *createScientificNumberFormatterTest();
72 extern IntlTest *createNumberFormat2Test();
75 #define TESTCLASS(id, TestClass) \
79 logln(#TestClass " test---"); \
80 logln((UnicodeString)""); \
82 callTest(test, par); \
86 void IntlTestFormat::runIndexedTest( int32_t index, UBool exec, const char* &name, char* par )
88 // for all format tests, always set default Locale and TimeZone to ENGLISH and PST.
89 TimeZone* saveDefaultTimeZone = NULL;
90 Locale saveDefaultLocale = Locale::getDefault();
92 saveDefaultTimeZone = TimeZone::createDefault();
93 TimeZone *tz = TimeZone::createTimeZone("America/Los_Angeles");
94 TimeZone::setDefault(*tz);
96 UErrorCode status = U_ZERO_ERROR;
97 Locale::setDefault( Locale::getEnglish(), status );
98 if (U_FAILURE(status)) {
99 errln("itformat: couldn't set default Locale to ENGLISH!");
102 if (exec) logln("TestSuite Format: ");
104 TESTCLASS(0,IntlTestDateFormat);
105 TESTCLASS(1,IntlTestNumberFormat);
106 TESTCLASS(2,CalendarTest);
107 TESTCLASS(3,CalendarLimitTest);
108 TESTCLASS(4,TimeZoneTest);
109 TESTCLASS(5,TimeZoneBoundaryTest);
110 TESTCLASS(6,TestChoiceFormat);
111 TESTCLASS(7,IntlTestDecimalFormatSymbols);
112 TESTCLASS(8,IntlTestDateFormatSymbols);
113 TESTCLASS(9,IntlTestDecimalFormatAPI);
114 TESTCLASS(10,TestFormatSmallClasses);
115 TESTCLASS(11,IntlTestNumberFormatAPI);
116 TESTCLASS(12,IntlTestSimpleDateFormatAPI);
117 TESTCLASS(13,IntlTestDateFormatAPI);
118 TESTCLASS(14,DateFormatTest);
119 TESTCLASS(15,TestMessageFormat);
120 TESTCLASS(16,NumberFormatTest);
121 TESTCLASS(17,DateFormatRegressionTest);
122 TESTCLASS(18,MessageFormatRegressionTest);
123 TESTCLASS(19,DateFormatMiscTests);
124 TESTCLASS(20,NumberFormatRoundTripTest);
125 TESTCLASS(21,NumberFormatRegressionTest);
126 TESTCLASS(22,DateFormatRoundTripTest);
127 TESTCLASS(23,ParsePositionTest);
128 TESTCLASS(24,CalendarRegressionTest);
129 TESTCLASS(25,TimeZoneRegressionTest);
130 TESTCLASS(26,IntlCalendarTest);
131 TESTCLASS(27,AstroTest);
132 TESTCLASS(28,CalendarCaseTest);
133 TESTCLASS(29,TimeZoneRuleTest);
134 #if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION
135 TESTCLASS(30,DataDrivenCalendarTest);
136 TESTCLASS(31,DataDrivenFormatTest);
138 TESTCLASS(32,IntlTestDateTimePatternGeneratorAPI);
139 TESTCLASS(33,TimeZoneOffsetLocalTest);
140 TESTCLASS(34,TimeZoneFormatTest);
141 TESTCLASS(35,PluralRulesTest);
142 TESTCLASS(36,PluralFormatTest);
143 TESTCLASS(37,DateIntervalFormatTest);
145 name = "TimeUnitTest";
147 logln("TimeUnitTest test---");
148 logln((UnicodeString)"");
149 LocalPointer<IntlTest> test(createTimeUnitTest());
150 callTest(*test, par);
153 TESTCLASS(39,SelectFormatTest);
154 TESTCLASS(40,LocaleDisplayNamesTest);
155 #if !UCONFIG_NO_REGULAR_EXPRESSIONS
156 TESTCLASS(41,DecimalFormatTest);
158 TESTCLASS(42,ListFormatterTest);
160 name = "GenderInfoTest";
162 logln("GenderInfoTest test---");
163 logln((UnicodeString)"");
164 LocalPointer<IntlTest> test(createGenderInfoTest());
165 callTest(*test, par);
169 name = "CompactDecimalFormatTest";
171 logln("CompactDecimalFormatTest test---");
172 logln((UnicodeString)"");
173 LocalPointer<IntlTest> test(createCompactDecimalFormatTest());
174 callTest(*test, par);
177 TESTCLASS(45,RegionTest);
179 #if !UCONFIG_NO_BREAK_ITERATION
180 name = "RelativeDateTimeFormatterTest";
182 logln("RelativeDateTimeFormatterTest test---");
183 logln((UnicodeString)"");
184 LocalPointer<IntlTest> test(createRelativeDateTimeFormatterTest());
185 callTest(*test, par);
190 name = "MeasureFormatTest";
192 logln("MeasureFormatTest test---");
193 logln((UnicodeString)"");
194 LocalPointer<IntlTest> test(createMeasureFormatTest());
195 callTest(*test, par);
199 name = "NumberFormatSpecificationTest";
201 logln("NumberFormatSpecificationTest test---");
202 logln((UnicodeString)"");
203 LocalPointer<IntlTest> test(createNumberFormatSpecificationTest());
204 callTest(*test, par);
208 name = "ScientificNumberFormatterTest";
210 logln("ScientificNumberFormatterTest test---");
211 logln((UnicodeString)"");
212 LocalPointer<IntlTest> test(createScientificNumberFormatterTest());
213 callTest(*test, par);
217 name = "NumberFormat2Test";
219 logln("NumberFormat2Test test---");
220 logln((UnicodeString)"");
221 LocalPointer<IntlTest> test(createNumberFormat2Test());
222 callTest(*test, par);
225 default: name = ""; break; //needed to end loop
228 // restore saved Locale and TimeZone
229 TimeZone::adoptDefault(saveDefaultTimeZone);
230 UErrorCode status = U_ZERO_ERROR;
231 Locale::setDefault( saveDefaultLocale, status );
232 if (U_FAILURE(status)) {
233 errln("itformat: couldn't re-set default Locale!");
238 #endif /* #if !UCONFIG_NO_FORMATTING */