1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
|
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2015, International Business Machines
* Corporation and others. All Rights Reserved.
********************************************************************/
/**
* IntlTestFormat is the medium level test class for everything in the directory "format".
*/
#include "unicode/utypes.h"
#include "unicode/localpointer.h"
#if !UCONFIG_NO_FORMATTING
#include "itformat.h"
#include "tsdate.h"
#include "tsnmfmt.h"
#include "caltest.h"
#include "callimts.h"
#include "tztest.h"
#include "tzbdtest.h"
#include "tsdcfmsy.h" // DecimalFormatSymbols
#include "tchcfmt.h"
#include "tsdtfmsy.h" // DateFormatSymbols
#include "dcfmapts.h" // DecimalFormatAPI
#include "tfsmalls.h" // Format Small Classes
#include "nmfmapts.h" // NumberFormatAPI
#include "numfmtst.h" // NumberFormatTest
#include "sdtfmtts.h" // SimpleDateFormatAPI
#include "dtfmapts.h" // DateFormatAPI
#include "dtfmttst.h" // DateFormatTest
#include "tmsgfmt.h" // TestMessageFormat
#include "messageformat2test.h" // TestMessageFormat2
#include "dtfmrgts.h" // DateFormatRegressionTest
#include "msfmrgts.h" // MessageFormatRegressionTest
#include "miscdtfm.h" // DateFormatMiscTests
#include "nmfmtrt.h" // NumberFormatRoundTripTest
#include "numrgts.h" // NumberFormatRegressionTest
#include "dtfmtrtts.h" // DateFormatRoundTripTest
#include "pptest.h" // ParsePositionTest
#include "calregts.h" // CalendarRegressionTest
#include "tzregts.h" // TimeZoneRegressionTest
#include "astrotst.h" // AstroTest
#include "incaltst.h" // IntlCalendarTest
#include "calcasts.h" // CalendarCaseTest
#include "tzrulets.h" // TimeZoneRuleTest
#include "dadrcal.h" // DataDrivenCalendarTest
#include "dadrfmt.h" // DataDrivenFormatTest
#include "dtptngts.h" // IntlTestDateTimePatternGeneratorAPI
#include "tzoffloc.h" // TimeZoneOffsetLocalTest
#include "tzfmttst.h" // TimeZoneFormatTest
#include "plurults.h" // PluralRulesTest
#include "plurfmts.h" // PluralFormatTest
#include "selfmts.h" // PluralFormatTest
#include "dtifmtts.h" // DateIntervalFormatTest
#include "locnmtst.h" // LocaleDisplayNamesTest
#include "dcfmtest.h" // DecimalFormatTest
#include "listformattertest.h" // ListFormatterTest
#include "regiontst.h" // RegionTest
#include "numbertest.h" // NumberTest
#include "erarulestest.h" // EraRulesTest
extern IntlTest *createCompactDecimalFormatTest();
extern IntlTest *createGenderInfoTest();
#if !UCONFIG_NO_BREAK_ITERATION
extern IntlTest *createRelativeDateTimeFormatterTest();
#endif
extern IntlTest *createTimeUnitTest();
extern IntlTest *createMeasureFormatTest();
extern IntlTest *createNumberFormatSpecificationTest();
extern IntlTest *createScientificNumberFormatterTest();
extern IntlTest *createFormattedValueTest();
extern IntlTest *createFormattedStringBuilderTest();
extern IntlTest *createStringSegmentTest();
extern IntlTest *createUnitsDataTest();
extern IntlTest *createUnitsTest();
extern IntlTest *createUnitsRouterTest();
extern IntlTest *createDisplayOptionsTest();
#define TESTCLASS(id, TestClass) \
case id: \
name = #TestClass; \
if (exec) { \
logln(#TestClass " test---"); \
logln((UnicodeString)""); \
TestClass test; \
callTest(test, par); \
} \
break
void IntlTestFormat::runIndexedTest( int32_t index, UBool exec, const char* &name, char* par )
{
// for all format tests, always set default Locale and TimeZone to ENGLISH and PST.
TimeZone* saveDefaultTimeZone = nullptr;
Locale saveDefaultLocale = Locale::getDefault();
if (exec) {
saveDefaultTimeZone = TimeZone::createDefault();
TimeZone *tz = TimeZone::createTimeZone("America/Los_Angeles");
TimeZone::setDefault(*tz);
delete tz;
UErrorCode status = U_ZERO_ERROR;
Locale::setDefault( Locale::getEnglish(), status );
if (U_FAILURE(status)) {
errln("itformat: couldn't set default Locale to ENGLISH!");
}
}
if (exec) logln("TestSuite Format: ");
switch (index) {
TESTCLASS(0,IntlTestDateFormat);
TESTCLASS(1,IntlTestNumberFormat);
TESTCLASS(2,CalendarTest);
TESTCLASS(3,CalendarLimitTest);
TESTCLASS(4,TimeZoneTest);
TESTCLASS(5,TimeZoneBoundaryTest);
TESTCLASS(6,TestChoiceFormat);
TESTCLASS(7,IntlTestDecimalFormatSymbols);
TESTCLASS(8,IntlTestDateFormatSymbols);
TESTCLASS(9,IntlTestDecimalFormatAPI);
TESTCLASS(10,TestFormatSmallClasses);
TESTCLASS(11,IntlTestNumberFormatAPI);
TESTCLASS(12,IntlTestSimpleDateFormatAPI);
TESTCLASS(13,IntlTestDateFormatAPI);
TESTCLASS(14,DateFormatTest);
TESTCLASS(15,TestMessageFormat);
TESTCLASS(16,NumberFormatTest);
TESTCLASS(17,DateFormatRegressionTest);
TESTCLASS(18,MessageFormatRegressionTest);
TESTCLASS(19,DateFormatMiscTests);
TESTCLASS(20,NumberFormatRoundTripTest);
TESTCLASS(21,NumberFormatRegressionTest);
TESTCLASS(22,DateFormatRoundTripTest);
TESTCLASS(23,ParsePositionTest);
TESTCLASS(24,CalendarRegressionTest);
TESTCLASS(25,TimeZoneRegressionTest);
TESTCLASS(26,IntlCalendarTest);
TESTCLASS(27,AstroTest);
TESTCLASS(28,CalendarCaseTest);
TESTCLASS(29,TimeZoneRuleTest);
#if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION
TESTCLASS(30,DataDrivenCalendarTest);
TESTCLASS(31,DataDrivenFormatTest);
#endif
TESTCLASS(32,IntlTestDateTimePatternGeneratorAPI);
TESTCLASS(33,TimeZoneOffsetLocalTest);
TESTCLASS(34,TimeZoneFormatTest);
TESTCLASS(35,PluralRulesTest);
TESTCLASS(36,PluralFormatTest);
TESTCLASS(37,DateIntervalFormatTest);
case 38:
name = "TimeUnitTest";
if (exec) {
logln("TimeUnitTest test---");
logln(UnicodeString(""));
LocalPointer<IntlTest> test(createTimeUnitTest());
callTest(*test, par);
}
break;
TESTCLASS(39,SelectFormatTest);
TESTCLASS(40,LocaleDisplayNamesTest);
#if !UCONFIG_NO_REGULAR_EXPRESSIONS
TESTCLASS(41,DecimalFormatTest);
#endif
TESTCLASS(42,ListFormatterTest);
case 43:
name = "GenderInfoTest";
if (exec) {
logln("GenderInfoTest test---");
logln(UnicodeString(""));
LocalPointer<IntlTest> test(createGenderInfoTest());
callTest(*test, par);
}
break;
case 44:
name = "CompactDecimalFormatTest";
if (exec) {
logln("CompactDecimalFormatTest test---");
logln(UnicodeString(""));
LocalPointer<IntlTest> test(createCompactDecimalFormatTest());
callTest(*test, par);
}
break;
TESTCLASS(45,RegionTest);
case 46:
#if !UCONFIG_NO_BREAK_ITERATION
name = "RelativeDateTimeFormatterTest";
if (exec) {
logln("RelativeDateTimeFormatterTest test---");
logln(UnicodeString(""));
LocalPointer<IntlTest> test(createRelativeDateTimeFormatterTest());
callTest(*test, par);
}
#endif
break;
case 47:
name = "MeasureFormatTest";
if (exec) {
logln("MeasureFormatTest test---");
logln(UnicodeString(""));
LocalPointer<IntlTest> test(createMeasureFormatTest());
callTest(*test, par);
}
break;
case 48:
name = "NumberFormatSpecificationTest";
if (exec) {
logln("NumberFormatSpecificationTest test---");
logln(UnicodeString(""));
LocalPointer<IntlTest> test(createNumberFormatSpecificationTest());
callTest(*test, par);
}
break;
case 49:
name = "ScientificNumberFormatterTest";
if (exec) {
logln("ScientificNumberFormatterTest test---");
logln(UnicodeString(""));
LocalPointer<IntlTest> test(createScientificNumberFormatterTest());
callTest(*test, par);
}
break;
TESTCLASS(50,NumberFormatDataDrivenTest);
TESTCLASS(51,NumberTest);
TESTCLASS(52,EraRulesTest);
case 53:
name = "FormattedValueTest";
if (exec) {
logln("FormattedValueTest test---");
logln(UnicodeString(""));
LocalPointer<IntlTest> test(createFormattedValueTest());
callTest(*test, par);
}
break;
case 54:
name = "FormattedStringBuilderTest";
if (exec) {
logln("FormattedStringBuilderTest test---");
logln(UnicodeString(""));
LocalPointer<IntlTest> test(createFormattedStringBuilderTest());
callTest(*test, par);
}
break;
case 55:
name = "StringSegmentTest";
if (exec) {
logln("StringSegmentTest test---");
logln(UnicodeString(""));
LocalPointer<IntlTest> test(createStringSegmentTest());
callTest(*test, par);
}
break;
case 56:
name = "UnitsTest";
if (exec) {
logln("UnitsTest test---");
logln(UnicodeString(""));
LocalPointer<IntlTest> test(createUnitsTest());
callTest(*test, par);
}
break;
case 57:
name = "UnitsDataTest";
if (exec) {
logln("UnitsDataTest test---");
logln(UnicodeString(""));
LocalPointer<IntlTest> test(createUnitsDataTest());
callTest(*test, par);
}
break;
case 58:
name = "UnitsRouterTest";
if (exec) {
logln("UnitsRouterTest test---");
logln(UnicodeString(""));
LocalPointer<IntlTest> test(createUnitsRouterTest());
callTest(*test, par);
}
break;
case 59:
name = "DisplayOptionsTest";
if (exec) {
logln("DisplayOptionsTest test---");
logln(UnicodeString(""));
LocalPointer<IntlTest> test(createDisplayOptionsTest());
callTest(*test, par);
}
break;
#if !UCONFIG_NO_NORMALIZATION
#if !UCONFIG_NO_MF2
TESTCLASS(60,TestMessageFormat2);
#endif
#endif
default: name = ""; break; //needed to end loop
}
if (exec) {
// restore saved Locale and TimeZone
TimeZone::adoptDefault(saveDefaultTimeZone);
UErrorCode status = U_ZERO_ERROR;
Locale::setDefault( saveDefaultLocale, status );
if (U_FAILURE(status)) {
errln("itformat: couldn't re-set default Locale!");
}
}
}
#endif /* #if !UCONFIG_NO_FORMATTING */
|