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();
76 #define TESTCLASS(id, TestClass) \
80 logln(#TestClass " test---"); \
81 logln((UnicodeString)""); \
83 callTest(test, par); \
87 void IntlTestFormat::runIndexedTest( int32_t index
, UBool exec
, const char* &name
, char* par
)
89 // for all format tests, always set default Locale and TimeZone to ENGLISH and PST.
90 TimeZone
* saveDefaultTimeZone
= NULL
;
91 Locale saveDefaultLocale
= Locale::getDefault();
93 saveDefaultTimeZone
= TimeZone::createDefault();
94 TimeZone
*tz
= TimeZone::createTimeZone("America/Los_Angeles");
95 TimeZone::setDefault(*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!");
103 if (exec
) logln("TestSuite Format: ");
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
);
132 TESTCLASS(27,AstroTest
);
133 TESTCLASS(28,CalendarCaseTest
);
134 TESTCLASS(29,TimeZoneRuleTest
);
135 #if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION
136 TESTCLASS(30,DataDrivenCalendarTest
);
137 TESTCLASS(31,DataDrivenFormatTest
);
139 TESTCLASS(32,IntlTestDateTimePatternGeneratorAPI
);
140 TESTCLASS(33,TimeZoneOffsetLocalTest
);
141 TESTCLASS(34,TimeZoneFormatTest
);
142 TESTCLASS(35,PluralRulesTest
);
143 TESTCLASS(36,PluralFormatTest
);
144 TESTCLASS(37,DateIntervalFormatTest
);
146 name
= "TimeUnitTest";
148 logln("TimeUnitTest test---");
149 logln((UnicodeString
)"");
150 LocalPointer
<IntlTest
> test(createTimeUnitTest());
151 callTest(*test
, par
);
154 TESTCLASS(39,SelectFormatTest
);
155 TESTCLASS(40,LocaleDisplayNamesTest
);
156 #if !UCONFIG_NO_REGULAR_EXPRESSIONS
157 TESTCLASS(41,DecimalFormatTest
);
159 TESTCLASS(42,ListFormatterTest
);
161 name
= "GenderInfoTest";
163 logln("GenderInfoTest test---");
164 logln((UnicodeString
)"");
165 LocalPointer
<IntlTest
> test(createGenderInfoTest());
166 callTest(*test
, par
);
170 name
= "CompactDecimalFormatTest";
172 logln("CompactDecimalFormatTest test---");
173 logln((UnicodeString
)"");
174 LocalPointer
<IntlTest
> test(createCompactDecimalFormatTest());
175 callTest(*test
, par
);
178 TESTCLASS(45,RegionTest
);
180 #if !UCONFIG_NO_BREAK_ITERATION
181 name
= "RelativeDateTimeFormatterTest";
183 logln("RelativeDateTimeFormatterTest test---");
184 logln((UnicodeString
)"");
185 LocalPointer
<IntlTest
> test(createRelativeDateTimeFormatterTest());
186 callTest(*test
, par
);
191 name
= "MeasureFormatTest";
193 logln("MeasureFormatTest test---");
194 logln((UnicodeString
)"");
195 LocalPointer
<IntlTest
> test(createMeasureFormatTest());
196 callTest(*test
, par
);
200 name
= "NumberFormatSpecificationTest";
202 logln("NumberFormatSpecificationTest test---");
203 logln((UnicodeString
)"");
204 LocalPointer
<IntlTest
> test(createNumberFormatSpecificationTest());
205 callTest(*test
, par
);
209 name
= "ScientificNumberFormatterTest";
211 logln("ScientificNumberFormatterTest test---");
212 logln((UnicodeString
)"");
213 LocalPointer
<IntlTest
> test(createScientificNumberFormatterTest());
214 callTest(*test
, par
);
217 TESTCLASS(50,NumberFormatDataDrivenTest
);
218 TESTCLASS(51,NumberTest
);
219 TESTCLASS(52,EraRulesTest
);
220 default: name
= ""; break; //needed to end loop
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!");
233 #endif /* #if !UCONFIG_NO_FORMATTING */