• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /********************************************************************
2  * COPYRIGHT:
3  * Copyright (c) 1997-2014, 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 #include "unicode/localpointer.h"
13 
14 #if !UCONFIG_NO_FORMATTING
15 
16 #include "itformat.h"
17 #include "tsdate.h"
18 #include "tsnmfmt.h"
19 #include "caltest.h"
20 #include "callimts.h"
21 #include "tztest.h"
22 #include "tzbdtest.h"
23 #include "tsdcfmsy.h"       // DecimalFormatSymbols
24 #include "tchcfmt.h"
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
61 
62 extern IntlTest *createCompactDecimalFormatTest();
63 extern IntlTest *createGenderInfoTest();
64 extern IntlTest *createRelativeDateTimeFormatterTest();
65 extern IntlTest *createMeasureFormatTest();
66 
67 #define TESTCLASS(id, TestClass)          \
68     case id:                              \
69         name = #TestClass;                \
70         if (exec) {                       \
71             logln(#TestClass " test---"); \
72             logln((UnicodeString)"");     \
73             TestClass test;               \
74             callTest(test, par);          \
75         }                                 \
76         break
77 
runIndexedTest(int32_t index,UBool exec,const char * & name,char * par)78 void IntlTestFormat::runIndexedTest( int32_t index, UBool exec, const char* &name, char* par )
79 {
80     // for all format tests, always set default Locale and TimeZone to ENGLISH and PST.
81     TimeZone* saveDefaultTimeZone = NULL;
82     Locale  saveDefaultLocale = Locale::getDefault();
83     if (exec) {
84         saveDefaultTimeZone = TimeZone::createDefault();
85         TimeZone *tz = TimeZone::createTimeZone("America/Los_Angeles");
86         TimeZone::setDefault(*tz);
87         delete 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!");
92         }
93     }
94     if (exec) logln("TestSuite Format: ");
95     switch (index) {
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);
129 #endif
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);
141 #endif
142         TESTCLASS(42,ListFormatterTest);
143         case 43:
144           name = "GenderInfoTest";
145           if (exec) {
146             logln("GenderInfoTest test---");
147             logln((UnicodeString)"");
148             LocalPointer<IntlTest> test(createGenderInfoTest());
149             callTest(*test, par);
150           }
151           break;
152         case 44:
153           name = "CompactDecimalFormatTest";
154           if (exec) {
155             logln("CompactDecimalFormatTest test---");
156             logln((UnicodeString)"");
157             LocalPointer<IntlTest> test(createCompactDecimalFormatTest());
158             callTest(*test, par);
159           }
160           break;
161         TESTCLASS(45,RegionTest);
162         case 46:
163           name = "RelativeDateTimeFormatterTest";
164           if (exec) {
165             logln("RelativeDateTimeFormatterTest test---");
166             logln((UnicodeString)"");
167             LocalPointer<IntlTest> test(createRelativeDateTimeFormatterTest());
168             callTest(*test, par);
169           }
170           break;
171         case 47:
172           name = "MeasureFormatTest";
173           if (exec) {
174             logln("MeasureFormatTest test---");
175             logln((UnicodeString)"");
176             LocalPointer<IntlTest> test(createMeasureFormatTest());
177             callTest(*test, par);
178           }
179           break;
180         default: name = ""; break; //needed to end loop
181     }
182     if (exec) {
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!");
189         }
190     }
191 }
192 
193 #endif /* #if !UCONFIG_NO_FORMATTING */
194