1 /********************************************************************
3 * Copyright (c) 1997-2014, 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 "tufmtts.h" // TimeUnitTest
57 #include "locnmtst.h" // LocaleDisplayNamesTest
58 #include "dcfmtest.h" // DecimalFormatTest
59 #include "listformattertest.h" // ListFormatterTest
60 #include "regiontst.h" // RegionTest
62 extern IntlTest
*createCompactDecimalFormatTest();
63 extern IntlTest
*createGenderInfoTest();
64 #if !UCONFIG_NO_BREAK_ITERATION
65 extern IntlTest
*createRelativeDateTimeFormatterTest();
67 extern IntlTest
*createMeasureFormatTest();
68 extern IntlTest
*createNumberFormatSpecificationTest();
69 extern IntlTest
*createScientificNumberFormatterTest();
71 #define TESTCLASS(id, TestClass) \
75 logln(#TestClass " test---"); \
76 logln((UnicodeString)""); \
78 callTest(test, par); \
82 void IntlTestFormat::runIndexedTest( int32_t index
, UBool exec
, const char* &name
, char* par
)
84 // for all format tests, always set default Locale and TimeZone to ENGLISH and PST.
85 TimeZone
* saveDefaultTimeZone
= NULL
;
86 Locale saveDefaultLocale
= Locale::getDefault();
88 saveDefaultTimeZone
= TimeZone::createDefault();
89 TimeZone
*tz
= TimeZone::createTimeZone("America/Los_Angeles");
90 TimeZone::setDefault(*tz
);
92 UErrorCode status
= U_ZERO_ERROR
;
93 Locale::setDefault( Locale::getEnglish(), status
);
94 if (U_FAILURE(status
)) {
95 errln("itformat: couldn't set default Locale to ENGLISH!");
98 if (exec
) logln("TestSuite Format: ");
100 TESTCLASS(0,IntlTestDateFormat
);
101 TESTCLASS(1,IntlTestNumberFormat
);
102 TESTCLASS(2,CalendarTest
);
103 TESTCLASS(3,CalendarLimitTest
);
104 TESTCLASS(4,TimeZoneTest
);
105 TESTCLASS(5,TimeZoneBoundaryTest
);
106 TESTCLASS(6,TestChoiceFormat
);
107 TESTCLASS(7,IntlTestDecimalFormatSymbols
);
108 TESTCLASS(8,IntlTestDateFormatSymbols
);
109 TESTCLASS(9,IntlTestDecimalFormatAPI
);
110 TESTCLASS(10,TestFormatSmallClasses
);
111 TESTCLASS(11,IntlTestNumberFormatAPI
);
112 TESTCLASS(12,IntlTestSimpleDateFormatAPI
);
113 TESTCLASS(13,IntlTestDateFormatAPI
);
114 TESTCLASS(14,DateFormatTest
);
115 TESTCLASS(15,TestMessageFormat
);
116 TESTCLASS(16,NumberFormatTest
);
117 TESTCLASS(17,DateFormatRegressionTest
);
118 TESTCLASS(18,MessageFormatRegressionTest
);
119 TESTCLASS(19,DateFormatMiscTests
);
120 TESTCLASS(20,NumberFormatRoundTripTest
);
121 TESTCLASS(21,NumberFormatRegressionTest
);
122 TESTCLASS(22,DateFormatRoundTripTest
);
123 TESTCLASS(23,ParsePositionTest
);
124 TESTCLASS(24,CalendarRegressionTest
);
125 TESTCLASS(25,TimeZoneRegressionTest
);
126 TESTCLASS(26,IntlCalendarTest
);
127 TESTCLASS(27,AstroTest
);
128 TESTCLASS(28,CalendarCaseTest
);
129 TESTCLASS(29,TimeZoneRuleTest
);
130 #if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION
131 TESTCLASS(30,DataDrivenCalendarTest
);
132 TESTCLASS(31,DataDrivenFormatTest
);
134 TESTCLASS(32,IntlTestDateTimePatternGeneratorAPI
);
135 TESTCLASS(33,TimeZoneOffsetLocalTest
);
136 TESTCLASS(34,TimeZoneFormatTest
);
137 TESTCLASS(35,PluralRulesTest
);
138 TESTCLASS(36,PluralFormatTest
);
139 TESTCLASS(37,DateIntervalFormatTest
);
140 TESTCLASS(38,TimeUnitTest
);
141 TESTCLASS(39,SelectFormatTest
);
142 TESTCLASS(40,LocaleDisplayNamesTest
);
143 #if !UCONFIG_NO_REGULAR_EXPRESSIONS
144 TESTCLASS(41,DecimalFormatTest
);
146 TESTCLASS(42,ListFormatterTest
);
148 name
= "GenderInfoTest";
150 logln("GenderInfoTest test---");
151 logln((UnicodeString
)"");
152 LocalPointer
<IntlTest
> test(createGenderInfoTest());
153 callTest(*test
, par
);
157 name
= "CompactDecimalFormatTest";
159 logln("CompactDecimalFormatTest test---");
160 logln((UnicodeString
)"");
161 LocalPointer
<IntlTest
> test(createCompactDecimalFormatTest());
162 callTest(*test
, par
);
165 TESTCLASS(45,RegionTest
);
167 #if !UCONFIG_NO_BREAK_ITERATION
168 name
= "RelativeDateTimeFormatterTest";
170 logln("RelativeDateTimeFormatterTest test---");
171 logln((UnicodeString
)"");
172 LocalPointer
<IntlTest
> test(createRelativeDateTimeFormatterTest());
173 callTest(*test
, par
);
178 name
= "MeasureFormatTest";
180 logln("MeasureFormatTest test---");
181 logln((UnicodeString
)"");
182 LocalPointer
<IntlTest
> test(createMeasureFormatTest());
183 callTest(*test
, par
);
187 name
= "NumberFormatSpecificationTest";
189 logln("NumberFormatSpecificationTest test---");
190 logln((UnicodeString
)"");
191 LocalPointer
<IntlTest
> test(createNumberFormatSpecificationTest());
192 callTest(*test
, par
);
196 name
= "ScientificNumberFormatterTest";
198 logln("ScientificNumberFormatterTest test---");
199 logln((UnicodeString
)"");
200 LocalPointer
<IntlTest
> test(createScientificNumberFormatterTest());
201 callTest(*test
, par
);
204 default: name
= ""; break; //needed to end loop
207 // restore saved Locale and TimeZone
208 TimeZone::adoptDefault(saveDefaultTimeZone
);
209 UErrorCode status
= U_ZERO_ERROR
;
210 Locale::setDefault( saveDefaultLocale
, status
);
211 if (U_FAILURE(status
)) {
212 errln("itformat: couldn't re-set default Locale!");
217 #endif /* #if !UCONFIG_NO_FORMATTING */