1 /********************************************************************
2 * COPYRIGHT:
3 * Copyright (c) 1997-2007, 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
52
53 #define TESTCLASS(id, TestClass) \
54 case id: \
55 name = #TestClass; \
56 if (exec) { \
57 logln(#TestClass " test---"); \
58 logln((UnicodeString)""); \
59 TestClass test; \
60 callTest(test, par); \
61 } \
62 break
63
runIndexedTest(int32_t index,UBool exec,const char * & name,char * par)64 void IntlTestFormat::runIndexedTest( int32_t index, UBool exec, const char* &name, char* par )
65 {
66 // for all format tests, always set default Locale and TimeZone to ENGLISH and PST.
67 TimeZone* saveDefaultTimeZone = NULL;
68 Locale saveDefaultLocale = Locale::getDefault();
69 if (exec) {
70 saveDefaultTimeZone = TimeZone::createDefault();
71 TimeZone *tz = TimeZone::createTimeZone("PST");
72 TimeZone::setDefault(*tz);
73 delete tz;
74 UErrorCode status = U_ZERO_ERROR;
75 Locale::setDefault( Locale::getEnglish(), status );
76 if (U_FAILURE(status)) {
77 errln("itformat: couldn't set default Locale to ENGLISH!");
78 }
79 }
80 if (exec) logln("TestSuite Format: ");
81 switch (index) {
82 TESTCLASS(0,IntlTestDateFormat);
83 TESTCLASS(1,IntlTestNumberFormat);
84 TESTCLASS(2,CalendarTest);
85 TESTCLASS(3,CalendarLimitTest);
86 TESTCLASS(4,TimeZoneTest);
87 TESTCLASS(5,TimeZoneBoundaryTest);
88 TESTCLASS(6,TestChoiceFormat);
89 TESTCLASS(7,IntlTestDecimalFormatSymbols);
90 TESTCLASS(8,IntlTestDateFormatSymbols);
91 TESTCLASS(9,IntlTestDecimalFormatAPI);
92 TESTCLASS(10,TestFormatSmallClasses);
93 TESTCLASS(11,IntlTestNumberFormatAPI);
94 TESTCLASS(12,IntlTestSimpleDateFormatAPI);
95 TESTCLASS(13,IntlTestDateFormatAPI);
96 TESTCLASS(14,DateFormatTest);
97 TESTCLASS(15,TestMessageFormat);
98 TESTCLASS(16,NumberFormatTest);
99 TESTCLASS(17,DateFormatRegressionTest);
100 TESTCLASS(18,MessageFormatRegressionTest);
101 TESTCLASS(19,DateFormatMiscTests);
102 TESTCLASS(20,NumberFormatRoundTripTest);
103 TESTCLASS(21,NumberFormatRegressionTest);
104 TESTCLASS(22,DateFormatRoundTripTest);
105 TESTCLASS(23,ParsePositionTest);
106 TESTCLASS(24,CalendarRegressionTest);
107 TESTCLASS(25,TimeZoneRegressionTest);
108 TESTCLASS(26,IntlCalendarTest);
109 TESTCLASS(27,AstroTest);
110 TESTCLASS(28,CalendarCaseTest);
111 TESTCLASS(29,TimeZoneRuleTest);
112 TESTCLASS(30,DataDrivenCalendarTest);
113 TESTCLASS(31,DataDrivenFormatTest);
114 TESTCLASS(32,IntlTestDateTimePatternGeneratorAPI);
115 TESTCLASS(33,TimeZoneOffsetLocalTest);
116 TESTCLASS(34,TimeZoneFormatTest);
117
118
119 default: name = ""; break; //needed to end loop
120 }
121 if (exec) {
122 // restore saved Locale and TimeZone
123 TimeZone::adoptDefault(saveDefaultTimeZone);
124 UErrorCode status = U_ZERO_ERROR;
125 Locale::setDefault( saveDefaultLocale, status );
126 if (U_FAILURE(status)) {
127 errln("itformat: couldn't re-set default Locale!");
128 }
129 }
130 }
131
132 #endif /* #if !UCONFIG_NO_FORMATTING */
133