1 /********************************************************************
3 * Copyright (c) 1997-2015, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 ********************************************************************/
8 * IntlTestFormat is the medium level test class for everything in the directory "format".
11 #include "unicode/utypes.h"
12 #include "unicode/localpointer.h"
14 #if !UCONFIG_NO_FORMATTING
23 #include "tsdcfmsy.h" // DecimalFormatSymbols
25 #include "tsdtfmsy.h" // DateFormatSymbols
26 #include "dcfmapts.h" // DecimalFormatAPI
27 #include "tfsmalls.h" // Format Small Classes
28 #include "nmfmapts.h" // NumberFormatAPI
29 #include "numfmtst.h" // NumberFormatTest
30 #include "sdtfmtts.h" // SimpleDateFormatAPI
31 #include "dtfmapts.h" // DateFormatAPI
32 #include "dtfmttst.h" // DateFormatTest
33 #include "tmsgfmt.h" // TestMessageFormat
34 #include "dtfmrgts.h" // DateFormatRegressionTest
35 #include "msfmrgts.h" // MessageFormatRegressionTest
36 #include "miscdtfm.h" // DateFormatMiscTests
37 #include "nmfmtrt.h" // NumberFormatRoundTripTest
38 #include "numrgts.h" // NumberFormatRegressionTest
39 #include "dtfmtrtts.h" // DateFormatRoundTripTest
40 #include "pptest.h" // ParsePositionTest
41 #include "calregts.h" // CalendarRegressionTest
42 #include "tzregts.h" // TimeZoneRegressionTest
43 #include "astrotst.h" // AstroTest
44 #include "incaltst.h" // IntlCalendarTest
45 #include "calcasts.h" // CalendarCaseTest
46 #include "tzrulets.h" // TimeZoneRuleTest
47 #include "dadrcal.h" // DataDrivenCalendarTest
48 #include "dadrfmt.h" // DataDrivenFormatTest
49 #include "dtptngts.h" // IntlTestDateTimePatternGeneratorAPI
50 #include "tzoffloc.h" // TimeZoneOffsetLocalTest
51 #include "tzfmttst.h" // TimeZoneFormatTest
52 #include "plurults.h" // PluralRulesTest
53 #include "plurfmts.h" // PluralFormatTest
54 #include "selfmts.h" // PluralFormatTest
55 #include "dtifmtts.h" // DateIntervalFormatTest
56 #include "locnmtst.h" // LocaleDisplayNamesTest
57 #include "dcfmtest.h" // DecimalFormatTest
58 #include "listformattertest.h" // ListFormatterTest
59 #include "regiontst.h" // RegionTest
61 extern IntlTest
*createCompactDecimalFormatTest();
62 extern IntlTest
*createGenderInfoTest();
63 #if !UCONFIG_NO_BREAK_ITERATION
64 extern IntlTest
*createRelativeDateTimeFormatterTest();
66 extern IntlTest
*createTimeUnitTest();
67 extern IntlTest
*createMeasureFormatTest();
68 extern IntlTest
*createNumberFormatSpecificationTest();
69 extern IntlTest
*createScientificNumberFormatterTest();
70 extern IntlTest
*createNumberFormat2Test();
73 #define TESTCLASS(id, TestClass) \
77 logln(#TestClass " test---"); \
78 logln((UnicodeString)""); \
80 callTest(test, par); \
84 void IntlTestFormat::runIndexedTest( int32_t index
, UBool exec
, const char* &name
, char* par
)
86 // for all format tests, always set default Locale and TimeZone to ENGLISH and PST.
87 TimeZone
* saveDefaultTimeZone
= NULL
;
88 Locale saveDefaultLocale
= Locale::getDefault();
90 saveDefaultTimeZone
= TimeZone::createDefault();
91 TimeZone
*tz
= TimeZone::createTimeZone("America/Los_Angeles");
92 TimeZone::setDefault(*tz
);
94 UErrorCode status
= U_ZERO_ERROR
;
95 Locale::setDefault( Locale::getEnglish(), status
);
96 if (U_FAILURE(status
)) {
97 errln("itformat: couldn't set default Locale to ENGLISH!");
100 if (exec
) logln("TestSuite Format: ");
102 TESTCLASS(0,IntlTestDateFormat
);
103 TESTCLASS(1,IntlTestNumberFormat
);
104 TESTCLASS(2,CalendarTest
);
105 TESTCLASS(3,CalendarLimitTest
);
106 TESTCLASS(4,TimeZoneTest
);
107 TESTCLASS(5,TimeZoneBoundaryTest
);
108 TESTCLASS(6,TestChoiceFormat
);
109 TESTCLASS(7,IntlTestDecimalFormatSymbols
);
110 TESTCLASS(8,IntlTestDateFormatSymbols
);
111 TESTCLASS(9,IntlTestDecimalFormatAPI
);
112 TESTCLASS(10,TestFormatSmallClasses
);
113 TESTCLASS(11,IntlTestNumberFormatAPI
);
114 TESTCLASS(12,IntlTestSimpleDateFormatAPI
);
115 TESTCLASS(13,IntlTestDateFormatAPI
);
116 TESTCLASS(14,DateFormatTest
);
117 TESTCLASS(15,TestMessageFormat
);
118 TESTCLASS(16,NumberFormatTest
);
119 TESTCLASS(17,DateFormatRegressionTest
);
120 TESTCLASS(18,MessageFormatRegressionTest
);
121 TESTCLASS(19,DateFormatMiscTests
);
122 TESTCLASS(20,NumberFormatRoundTripTest
);
123 TESTCLASS(21,NumberFormatRegressionTest
);
124 TESTCLASS(22,DateFormatRoundTripTest
);
125 TESTCLASS(23,ParsePositionTest
);
126 TESTCLASS(24,CalendarRegressionTest
);
127 TESTCLASS(25,TimeZoneRegressionTest
);
128 TESTCLASS(26,IntlCalendarTest
);
129 TESTCLASS(27,AstroTest
);
130 TESTCLASS(28,CalendarCaseTest
);
131 TESTCLASS(29,TimeZoneRuleTest
);
132 #if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION
133 TESTCLASS(30,DataDrivenCalendarTest
);
134 TESTCLASS(31,DataDrivenFormatTest
);
136 TESTCLASS(32,IntlTestDateTimePatternGeneratorAPI
);
137 TESTCLASS(33,TimeZoneOffsetLocalTest
);
138 TESTCLASS(34,TimeZoneFormatTest
);
139 TESTCLASS(35,PluralRulesTest
);
140 TESTCLASS(36,PluralFormatTest
);
141 TESTCLASS(37,DateIntervalFormatTest
);
143 name
= "TimeUnitTest";
145 logln("TimeUnitTest test---");
146 logln((UnicodeString
)"");
147 LocalPointer
<IntlTest
> test(createTimeUnitTest());
148 callTest(*test
, par
);
151 TESTCLASS(39,SelectFormatTest
);
152 TESTCLASS(40,LocaleDisplayNamesTest
);
153 #if !UCONFIG_NO_REGULAR_EXPRESSIONS
154 TESTCLASS(41,DecimalFormatTest
);
156 TESTCLASS(42,ListFormatterTest
);
158 name
= "GenderInfoTest";
160 logln("GenderInfoTest test---");
161 logln((UnicodeString
)"");
162 LocalPointer
<IntlTest
> test(createGenderInfoTest());
163 callTest(*test
, par
);
167 name
= "CompactDecimalFormatTest";
169 logln("CompactDecimalFormatTest test---");
170 logln((UnicodeString
)"");
171 LocalPointer
<IntlTest
> test(createCompactDecimalFormatTest());
172 callTest(*test
, par
);
175 TESTCLASS(45,RegionTest
);
177 #if !UCONFIG_NO_BREAK_ITERATION
178 name
= "RelativeDateTimeFormatterTest";
180 logln("RelativeDateTimeFormatterTest test---");
181 logln((UnicodeString
)"");
182 LocalPointer
<IntlTest
> test(createRelativeDateTimeFormatterTest());
183 callTest(*test
, par
);
188 name
= "MeasureFormatTest";
190 logln("MeasureFormatTest test---");
191 logln((UnicodeString
)"");
192 LocalPointer
<IntlTest
> test(createMeasureFormatTest());
193 callTest(*test
, par
);
197 name
= "NumberFormatSpecificationTest";
199 logln("NumberFormatSpecificationTest test---");
200 logln((UnicodeString
)"");
201 LocalPointer
<IntlTest
> test(createNumberFormatSpecificationTest());
202 callTest(*test
, par
);
206 name
= "ScientificNumberFormatterTest";
208 logln("ScientificNumberFormatterTest test---");
209 logln((UnicodeString
)"");
210 LocalPointer
<IntlTest
> test(createScientificNumberFormatterTest());
211 callTest(*test
, par
);
215 name
= "NumberFormat2Test";
217 logln("NumberFormat2Test test---");
218 logln((UnicodeString
)"");
219 LocalPointer
<IntlTest
> test(createNumberFormat2Test());
220 callTest(*test
, par
);
223 default: name
= ""; break; //needed to end loop
226 // restore saved Locale and TimeZone
227 TimeZone::adoptDefault(saveDefaultTimeZone
);
228 UErrorCode status
= U_ZERO_ERROR
;
229 Locale::setDefault( saveDefaultLocale
, status
);
230 if (U_FAILURE(status
)) {
231 errln("itformat: couldn't re-set default Locale!");
236 #endif /* #if !UCONFIG_NO_FORMATTING */