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