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