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 extern IntlTest
*createRelativeDateTimeFormatterTest();
65 extern IntlTest
*createMeasureFormatTest();
67 #define TESTCLASS(id, TestClass) \
71 logln(#TestClass " test---"); \
72 logln((UnicodeString)""); \
74 callTest(test, par); \
78 void IntlTestFormat::runIndexedTest( int32_t index
, UBool exec
, const char* &name
, char* par
)
80 // for all format tests, always set default Locale and TimeZone to ENGLISH and PST.
81 TimeZone
* saveDefaultTimeZone
= NULL
;
82 Locale saveDefaultLocale
= Locale::getDefault();
84 saveDefaultTimeZone
= TimeZone::createDefault();
85 TimeZone
*tz
= TimeZone::createTimeZone("America/Los_Angeles");
86 TimeZone::setDefault(*tz
);
88 UErrorCode status
= U_ZERO_ERROR
;
89 Locale::setDefault( Locale::getEnglish(), status
);
90 if (U_FAILURE(status
)) {
91 errln("itformat: couldn't set default Locale to ENGLISH!");
94 if (exec
) logln("TestSuite Format: ");
96 TESTCLASS(0,IntlTestDateFormat
);
97 TESTCLASS(1,IntlTestNumberFormat
);
98 TESTCLASS(2,CalendarTest
);
99 TESTCLASS(3,CalendarLimitTest
);
100 TESTCLASS(4,TimeZoneTest
);
101 TESTCLASS(5,TimeZoneBoundaryTest
);
102 TESTCLASS(6,TestChoiceFormat
);
103 TESTCLASS(7,IntlTestDecimalFormatSymbols
);
104 TESTCLASS(8,IntlTestDateFormatSymbols
);
105 TESTCLASS(9,IntlTestDecimalFormatAPI
);
106 TESTCLASS(10,TestFormatSmallClasses
);
107 TESTCLASS(11,IntlTestNumberFormatAPI
);
108 TESTCLASS(12,IntlTestSimpleDateFormatAPI
);
109 TESTCLASS(13,IntlTestDateFormatAPI
);
110 TESTCLASS(14,DateFormatTest
);
111 TESTCLASS(15,TestMessageFormat
);
112 TESTCLASS(16,NumberFormatTest
);
113 TESTCLASS(17,DateFormatRegressionTest
);
114 TESTCLASS(18,MessageFormatRegressionTest
);
115 TESTCLASS(19,DateFormatMiscTests
);
116 TESTCLASS(20,NumberFormatRoundTripTest
);
117 TESTCLASS(21,NumberFormatRegressionTest
);
118 TESTCLASS(22,DateFormatRoundTripTest
);
119 TESTCLASS(23,ParsePositionTest
);
120 TESTCLASS(24,CalendarRegressionTest
);
121 TESTCLASS(25,TimeZoneRegressionTest
);
122 TESTCLASS(26,IntlCalendarTest
);
123 TESTCLASS(27,AstroTest
);
124 TESTCLASS(28,CalendarCaseTest
);
125 TESTCLASS(29,TimeZoneRuleTest
);
126 #if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION
127 TESTCLASS(30,DataDrivenCalendarTest
);
128 TESTCLASS(31,DataDrivenFormatTest
);
130 TESTCLASS(32,IntlTestDateTimePatternGeneratorAPI
);
131 TESTCLASS(33,TimeZoneOffsetLocalTest
);
132 TESTCLASS(34,TimeZoneFormatTest
);
133 TESTCLASS(35,PluralRulesTest
);
134 TESTCLASS(36,PluralFormatTest
);
135 TESTCLASS(37,DateIntervalFormatTest
);
136 TESTCLASS(38,TimeUnitTest
);
137 TESTCLASS(39,SelectFormatTest
);
138 TESTCLASS(40,LocaleDisplayNamesTest
);
139 #if !UCONFIG_NO_REGULAR_EXPRESSIONS
140 TESTCLASS(41,DecimalFormatTest
);
142 TESTCLASS(42,ListFormatterTest
);
144 name
= "GenderInfoTest";
146 logln("GenderInfoTest test---");
147 logln((UnicodeString
)"");
148 LocalPointer
<IntlTest
> test(createGenderInfoTest());
149 callTest(*test
, par
);
153 name
= "CompactDecimalFormatTest";
155 logln("CompactDecimalFormatTest test---");
156 logln((UnicodeString
)"");
157 LocalPointer
<IntlTest
> test(createCompactDecimalFormatTest());
158 callTest(*test
, par
);
161 TESTCLASS(45,RegionTest
);
163 name
= "RelativeDateTimeFormatterTest";
165 logln("RelativeDateTimeFormatterTest test---");
166 logln((UnicodeString
)"");
167 LocalPointer
<IntlTest
> test(createRelativeDateTimeFormatterTest());
168 callTest(*test
, par
);
172 name
= "MeasureFormatTest";
174 logln("MeasureFormatTest test---");
175 logln((UnicodeString
)"");
176 LocalPointer
<IntlTest
> test(createMeasureFormatTest());
177 callTest(*test
, par
);
180 default: name
= ""; break; //needed to end loop
183 // restore saved Locale and TimeZone
184 TimeZone::adoptDefault(saveDefaultTimeZone
);
185 UErrorCode status
= U_ZERO_ERROR
;
186 Locale::setDefault( saveDefaultLocale
, status
);
187 if (U_FAILURE(status
)) {
188 errln("itformat: couldn't re-set default Locale!");
193 #endif /* #if !UCONFIG_NO_FORMATTING */