]> git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/itformat.cpp
ICU-461.18.tar.gz
[apple/icu.git] / icuSources / test / intltest / itformat.cpp
1 /********************************************************************
2 * COPYRIGHT:
3 * Copyright (c) 1997-2010, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 ********************************************************************/
6
7 /**
8 * IntlTestFormat is the medium level test class for everything in the directory "format".
9 */
10
11 #include "unicode/utypes.h"
12
13 #if !UCONFIG_NO_FORMATTING
14
15 #include "itformat.h"
16 #include "tsdate.h"
17 #include "tsnmfmt.h"
18 #include "caltest.h"
19 #include "callimts.h"
20 #include "tztest.h"
21 #include "tzbdtest.h"
22 #include "tsdcfmsy.h" // DecimalFormatSymbols
23 #include "tchcfmt.h"
24 #include "tsdtfmsy.h" // DateFormatSymbols
25 #include "dcfmapts.h" // DecimalFormatAPI
26 #include "tfsmalls.h" // Format Small Classes
27 #include "nmfmapts.h" // NumberFormatAPI
28 #include "numfmtst.h" // NumberFormatTest
29 #include "sdtfmtts.h" // SimpleDateFormatAPI
30 #include "dtfmapts.h" // DateFormatAPI
31 #include "dtfmttst.h" // DateFormatTest
32 #include "tmsgfmt.h" // TestMessageFormat
33 #include "dtfmrgts.h" // DateFormatRegressionTest
34 #include "msfmrgts.h" // MessageFormatRegressionTest
35 #include "miscdtfm.h" // DateFormatMiscTests
36 #include "nmfmtrt.h" // NumberFormatRoundTripTest
37 #include "numrgts.h" // NumberFormatRegressionTest
38 #include "dtfmtrtts.h" // DateFormatRoundTripTest
39 #include "pptest.h" // ParsePositionTest
40 #include "calregts.h" // CalendarRegressionTest
41 #include "tzregts.h" // TimeZoneRegressionTest
42 #include "astrotst.h" // AstroTest
43 #include "incaltst.h" // IntlCalendarTest
44 #include "calcasts.h" // CalendarCaseTest
45 #include "tzrulets.h" // TimeZoneRuleTest
46 #include "dadrcal.h" // DataDrivenCalendarTest
47 #include "dadrfmt.h" // DataDrivenFormatTest
48 #include "dtptngts.h" // IntlTestDateTimePatternGeneratorAPI
49 #include "tzoffloc.h" // TimeZoneOffsetLocalTest
50 #include "tzfmttst.h" // TimeZoneFormatTest
51 #include "plurults.h" // PluralRulesTest
52 #include "plurfmts.h" // PluralFormatTest
53 #include "selfmts.h" // PluralFormatTest
54 #include "dtifmtts.h" // DateIntervalFormatTest
55 #include "tufmtts.h" // TimeUnitTest
56 #include "locnmtst.h" // LocaleDisplayNamesTest
57 #include "dcfmtest.h" // DecimalFormatTest
58
59 #define TESTCLASS(id, TestClass) \
60 case id: \
61 name = #TestClass; \
62 if (exec) { \
63 logln(#TestClass " test---"); \
64 logln((UnicodeString)""); \
65 TestClass test; \
66 callTest(test, par); \
67 } \
68 break
69
70 void IntlTestFormat::runIndexedTest( int32_t index, UBool exec, const char* &name, char* par )
71 {
72 // for all format tests, always set default Locale and TimeZone to ENGLISH and PST.
73 TimeZone* saveDefaultTimeZone = NULL;
74 Locale saveDefaultLocale = Locale::getDefault();
75 if (exec) {
76 saveDefaultTimeZone = TimeZone::createDefault();
77 TimeZone *tz = TimeZone::createTimeZone("PST");
78 TimeZone::setDefault(*tz);
79 delete tz;
80 UErrorCode status = U_ZERO_ERROR;
81 Locale::setDefault( Locale::getEnglish(), status );
82 if (U_FAILURE(status)) {
83 errln("itformat: couldn't set default Locale to ENGLISH!");
84 }
85 }
86 if (exec) logln("TestSuite Format: ");
87 switch (index) {
88 TESTCLASS(0,IntlTestDateFormat);
89 TESTCLASS(1,IntlTestNumberFormat);
90 TESTCLASS(2,CalendarTest);
91 TESTCLASS(3,CalendarLimitTest);
92 TESTCLASS(4,TimeZoneTest);
93 TESTCLASS(5,TimeZoneBoundaryTest);
94 TESTCLASS(6,TestChoiceFormat);
95 TESTCLASS(7,IntlTestDecimalFormatSymbols);
96 TESTCLASS(8,IntlTestDateFormatSymbols);
97 TESTCLASS(9,IntlTestDecimalFormatAPI);
98 TESTCLASS(10,TestFormatSmallClasses);
99 TESTCLASS(11,IntlTestNumberFormatAPI);
100 TESTCLASS(12,IntlTestSimpleDateFormatAPI);
101 TESTCLASS(13,IntlTestDateFormatAPI);
102 TESTCLASS(14,DateFormatTest);
103 TESTCLASS(15,TestMessageFormat);
104 TESTCLASS(16,NumberFormatTest);
105 TESTCLASS(17,DateFormatRegressionTest);
106 TESTCLASS(18,MessageFormatRegressionTest);
107 TESTCLASS(19,DateFormatMiscTests);
108 TESTCLASS(20,NumberFormatRoundTripTest);
109 TESTCLASS(21,NumberFormatRegressionTest);
110 TESTCLASS(22,DateFormatRoundTripTest);
111 TESTCLASS(23,ParsePositionTest);
112 TESTCLASS(24,CalendarRegressionTest);
113 TESTCLASS(25,TimeZoneRegressionTest);
114 TESTCLASS(26,IntlCalendarTest);
115 TESTCLASS(27,AstroTest);
116 TESTCLASS(28,CalendarCaseTest);
117 TESTCLASS(29,TimeZoneRuleTest);
118 #if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION
119 TESTCLASS(30,DataDrivenCalendarTest);
120 TESTCLASS(31,DataDrivenFormatTest);
121 #endif
122 TESTCLASS(32,IntlTestDateTimePatternGeneratorAPI);
123 TESTCLASS(33,TimeZoneOffsetLocalTest);
124 TESTCLASS(34,TimeZoneFormatTest);
125 TESTCLASS(35,PluralRulesTest);
126 TESTCLASS(36,PluralFormatTest);
127 TESTCLASS(37,DateIntervalFormatTest);
128 TESTCLASS(38,TimeUnitTest);
129 TESTCLASS(39,SelectFormatTest);
130 TESTCLASS(40,LocaleDisplayNamesTest);
131 #if !UCONFIG_NO_REGULAR_EXPRESSIONS
132 TESTCLASS(41,DecimalFormatTest);
133 #endif
134
135 default: name = ""; break; //needed to end loop
136 }
137 if (exec) {
138 // restore saved Locale and TimeZone
139 TimeZone::adoptDefault(saveDefaultTimeZone);
140 UErrorCode status = U_ZERO_ERROR;
141 Locale::setDefault( saveDefaultLocale, status );
142 if (U_FAILURE(status)) {
143 errln("itformat: couldn't re-set default Locale!");
144 }
145 }
146 }
147
148 #endif /* #if !UCONFIG_NO_FORMATTING */