1 // © 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
62 #include "numbertest.h" // NumberTest
63 #include "erarulestest.h" // EraRulesTest
65 extern IntlTest
*createCompactDecimalFormatTest();
66 extern IntlTest
*createGenderInfoTest();
67 #if !UCONFIG_NO_BREAK_ITERATION
68 extern IntlTest
*createRelativeDateTimeFormatterTest();
70 extern IntlTest
*createTimeUnitTest();
71 extern IntlTest
*createMeasureFormatTest();
72 extern IntlTest
*createNumberFormatSpecificationTest();
73 extern IntlTest
*createScientificNumberFormatterTest();
74 extern IntlTest
*createFormattedValueTest();
77 #define TESTCLASS(id, TestClass) \
81 logln(#TestClass " test---"); \
82 logln((UnicodeString)""); \
84 callTest(test, par); \
88 void IntlTestFormat::runIndexedTest( int32_t index
, UBool exec
, const char* &name
, char* par
)
90 // for all format tests, always set default Locale and TimeZone to ENGLISH and PST.
91 TimeZone
* saveDefaultTimeZone
= NULL
;
92 Locale saveDefaultLocale
= Locale::getDefault();
94 saveDefaultTimeZone
= TimeZone::createDefault();
95 TimeZone
*tz
= TimeZone::createTimeZone("America/Los_Angeles");
96 TimeZone::setDefault(*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!");
104 if (exec
) logln("TestSuite Format: ");
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
);
133 TESTCLASS(27,AstroTest
);
134 TESTCLASS(28,CalendarCaseTest
);
135 TESTCLASS(29,TimeZoneRuleTest
);
136 #if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION
137 TESTCLASS(30,DataDrivenCalendarTest
);
138 TESTCLASS(31,DataDrivenFormatTest
);
140 TESTCLASS(32,IntlTestDateTimePatternGeneratorAPI
);
141 TESTCLASS(33,TimeZoneOffsetLocalTest
);
142 TESTCLASS(34,TimeZoneFormatTest
);
143 TESTCLASS(35,PluralRulesTest
);
144 TESTCLASS(36,PluralFormatTest
);
145 TESTCLASS(37,DateIntervalFormatTest
);
147 name
= "TimeUnitTest";
149 logln("TimeUnitTest test---");
150 logln((UnicodeString
)"");
151 LocalPointer
<IntlTest
> test(createTimeUnitTest());
152 callTest(*test
, par
);
155 TESTCLASS(39,SelectFormatTest
);
156 TESTCLASS(40,LocaleDisplayNamesTest
);
157 #if !UCONFIG_NO_REGULAR_EXPRESSIONS
158 TESTCLASS(41,DecimalFormatTest
);
160 TESTCLASS(42,ListFormatterTest
);
162 name
= "GenderInfoTest";
164 logln("GenderInfoTest test---");
165 logln((UnicodeString
)"");
166 LocalPointer
<IntlTest
> test(createGenderInfoTest());
167 callTest(*test
, par
);
171 name
= "CompactDecimalFormatTest";
173 logln("CompactDecimalFormatTest test---");
174 logln((UnicodeString
)"");
175 LocalPointer
<IntlTest
> test(createCompactDecimalFormatTest());
176 callTest(*test
, par
);
179 TESTCLASS(45,RegionTest
);
181 #if !UCONFIG_NO_BREAK_ITERATION
182 name
= "RelativeDateTimeFormatterTest";
184 logln("RelativeDateTimeFormatterTest test---");
185 logln((UnicodeString
)"");
186 LocalPointer
<IntlTest
> test(createRelativeDateTimeFormatterTest());
187 callTest(*test
, par
);
192 name
= "MeasureFormatTest";
194 logln("MeasureFormatTest test---");
195 logln((UnicodeString
)"");
196 LocalPointer
<IntlTest
> test(createMeasureFormatTest());
197 callTest(*test
, par
);
201 name
= "NumberFormatSpecificationTest";
203 logln("NumberFormatSpecificationTest test---");
204 logln((UnicodeString
)"");
205 LocalPointer
<IntlTest
> test(createNumberFormatSpecificationTest());
206 callTest(*test
, par
);
210 name
= "ScientificNumberFormatterTest";
212 logln("ScientificNumberFormatterTest test---");
213 logln((UnicodeString
)"");
214 LocalPointer
<IntlTest
> test(createScientificNumberFormatterTest());
215 callTest(*test
, par
);
218 TESTCLASS(50,NumberFormatDataDrivenTest
);
219 TESTCLASS(51,NumberTest
);
220 TESTCLASS(52,EraRulesTest
);
222 name
= "FormattedValueTest";
224 logln("FormattedValueTest test---");
225 logln((UnicodeString
)"");
226 LocalPointer
<IntlTest
> test(createFormattedValueTest());
227 callTest(*test
, par
);
230 default: name
= ""; break; //needed to end loop
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!");
243 #endif /* #if !UCONFIG_NO_FORMATTING */