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();
75 extern IntlTest
*createFormattedStringBuilderTest();
76 extern IntlTest
*createStringSegmentTest();
79 #define TESTCLASS(id, TestClass) \
83 logln(#TestClass " test---"); \
84 logln((UnicodeString)""); \
86 callTest(test, par); \
90 void IntlTestFormat::runIndexedTest( int32_t index
, UBool exec
, const char* &name
, char* par
)
92 // for all format tests, always set default Locale and TimeZone to ENGLISH and PST.
93 TimeZone
* saveDefaultTimeZone
= NULL
;
94 Locale saveDefaultLocale
= Locale::getDefault();
96 saveDefaultTimeZone
= TimeZone::createDefault();
97 TimeZone
*tz
= TimeZone::createTimeZone("America/Los_Angeles");
98 TimeZone::setDefault(*tz
);
100 UErrorCode status
= U_ZERO_ERROR
;
101 Locale::setDefault( Locale::getEnglish(), status
);
102 if (U_FAILURE(status
)) {
103 errln("itformat: couldn't set default Locale to ENGLISH!");
106 if (exec
) logln("TestSuite Format: ");
108 TESTCLASS(0,IntlTestDateFormat
);
109 TESTCLASS(1,IntlTestNumberFormat
);
110 TESTCLASS(2,CalendarTest
);
111 TESTCLASS(3,CalendarLimitTest
);
112 TESTCLASS(4,TimeZoneTest
);
113 TESTCLASS(5,TimeZoneBoundaryTest
);
114 TESTCLASS(6,TestChoiceFormat
);
115 TESTCLASS(7,IntlTestDecimalFormatSymbols
);
116 TESTCLASS(8,IntlTestDateFormatSymbols
);
117 TESTCLASS(9,IntlTestDecimalFormatAPI
);
118 TESTCLASS(10,TestFormatSmallClasses
);
119 TESTCLASS(11,IntlTestNumberFormatAPI
);
120 TESTCLASS(12,IntlTestSimpleDateFormatAPI
);
121 TESTCLASS(13,IntlTestDateFormatAPI
);
122 TESTCLASS(14,DateFormatTest
);
123 TESTCLASS(15,TestMessageFormat
);
124 TESTCLASS(16,NumberFormatTest
);
125 TESTCLASS(17,DateFormatRegressionTest
);
126 TESTCLASS(18,MessageFormatRegressionTest
);
127 TESTCLASS(19,DateFormatMiscTests
);
128 TESTCLASS(20,NumberFormatRoundTripTest
);
129 TESTCLASS(21,NumberFormatRegressionTest
);
130 TESTCLASS(22,DateFormatRoundTripTest
);
131 TESTCLASS(23,ParsePositionTest
);
132 TESTCLASS(24,CalendarRegressionTest
);
133 TESTCLASS(25,TimeZoneRegressionTest
);
134 TESTCLASS(26,IntlCalendarTest
);
135 TESTCLASS(27,AstroTest
);
136 TESTCLASS(28,CalendarCaseTest
);
137 TESTCLASS(29,TimeZoneRuleTest
);
138 #if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION
139 TESTCLASS(30,DataDrivenCalendarTest
);
140 TESTCLASS(31,DataDrivenFormatTest
);
142 TESTCLASS(32,IntlTestDateTimePatternGeneratorAPI
);
143 TESTCLASS(33,TimeZoneOffsetLocalTest
);
144 TESTCLASS(34,TimeZoneFormatTest
);
145 TESTCLASS(35,PluralRulesTest
);
146 TESTCLASS(36,PluralFormatTest
);
147 TESTCLASS(37,DateIntervalFormatTest
);
149 name
= "TimeUnitTest";
151 logln("TimeUnitTest test---");
152 logln((UnicodeString
)"");
153 LocalPointer
<IntlTest
> test(createTimeUnitTest());
154 callTest(*test
, par
);
157 TESTCLASS(39,SelectFormatTest
);
158 TESTCLASS(40,LocaleDisplayNamesTest
);
159 #if !UCONFIG_NO_REGULAR_EXPRESSIONS
160 TESTCLASS(41,DecimalFormatTest
);
162 TESTCLASS(42,ListFormatterTest
);
164 name
= "GenderInfoTest";
166 logln("GenderInfoTest test---");
167 logln((UnicodeString
)"");
168 LocalPointer
<IntlTest
> test(createGenderInfoTest());
169 callTest(*test
, par
);
173 name
= "CompactDecimalFormatTest";
175 logln("CompactDecimalFormatTest test---");
176 logln((UnicodeString
)"");
177 LocalPointer
<IntlTest
> test(createCompactDecimalFormatTest());
178 callTest(*test
, par
);
181 TESTCLASS(45,RegionTest
);
183 #if !UCONFIG_NO_BREAK_ITERATION
184 name
= "RelativeDateTimeFormatterTest";
186 logln("RelativeDateTimeFormatterTest test---");
187 logln((UnicodeString
)"");
188 LocalPointer
<IntlTest
> test(createRelativeDateTimeFormatterTest());
189 callTest(*test
, par
);
194 name
= "MeasureFormatTest";
196 logln("MeasureFormatTest test---");
197 logln((UnicodeString
)"");
198 LocalPointer
<IntlTest
> test(createMeasureFormatTest());
199 callTest(*test
, par
);
203 name
= "NumberFormatSpecificationTest";
205 logln("NumberFormatSpecificationTest test---");
206 logln((UnicodeString
)"");
207 LocalPointer
<IntlTest
> test(createNumberFormatSpecificationTest());
208 callTest(*test
, par
);
212 name
= "ScientificNumberFormatterTest";
214 logln("ScientificNumberFormatterTest test---");
215 logln((UnicodeString
)"");
216 LocalPointer
<IntlTest
> test(createScientificNumberFormatterTest());
217 callTest(*test
, par
);
220 TESTCLASS(50,NumberFormatDataDrivenTest
);
221 TESTCLASS(51,NumberTest
);
222 TESTCLASS(52,EraRulesTest
);
224 name
= "FormattedValueTest";
226 logln("FormattedValueTest test---");
227 logln((UnicodeString
)"");
228 LocalPointer
<IntlTest
> test(createFormattedValueTest());
229 callTest(*test
, par
);
233 name
= "FormattedStringBuilderTest";
235 logln("FormattedStringBuilderTest test---");
236 logln((UnicodeString
)"");
237 LocalPointer
<IntlTest
> test(createFormattedStringBuilderTest());
238 callTest(*test
, par
);
242 name
= "StringSegmentTest";
244 logln("StringSegmentTest test---");
245 logln((UnicodeString
)"");
246 LocalPointer
<IntlTest
> test(createStringSegmentTest());
247 callTest(*test
, par
);
250 default: name
= ""; break; //needed to end loop
253 // restore saved Locale and TimeZone
254 TimeZone::adoptDefault(saveDefaultTimeZone
);
255 UErrorCode status
= U_ZERO_ERROR
;
256 Locale::setDefault( saveDefaultLocale
, status
);
257 if (U_FAILURE(status
)) {
258 errln("itformat: couldn't re-set default Locale!");
263 #endif /* #if !UCONFIG_NO_FORMATTING */