]> git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/itformat.cpp
ICU-6.2.8.tar.gz
[apple/icu.git] / icuSources / test / intltest / itformat.cpp
1 /********************************************************************
2 * COPYRIGHT:
3 * Copyright (c) 1997-2003, International Business Machines Corporation and
4 * 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
46 #define TESTCLASS(id, TestClass) \
47 case id: \
48 name = #TestClass; \
49 if (exec) { \
50 logln(#TestClass " test---"); \
51 logln((UnicodeString)""); \
52 TestClass test; \
53 callTest(test, par); \
54 } \
55 break
56
57 void IntlTestFormat::runIndexedTest( int32_t index, UBool exec, const char* &name, char* par )
58 {
59 // for all format tests, always set default Locale and TimeZone to ENGLISH and PST.
60 TimeZone* saveDefaultTimeZone = NULL;
61 Locale saveDefaultLocale = Locale::getDefault();
62 if (exec) {
63 saveDefaultTimeZone = TimeZone::createDefault();
64 TimeZone *tz = TimeZone::createTimeZone("PST");
65 TimeZone::setDefault(*tz);
66 delete tz;
67 UErrorCode status = U_ZERO_ERROR;
68 Locale::setDefault( Locale::getEnglish(), status );
69 if (U_FAILURE(status)) {
70 errln("itformat: couldn't set default Locale to ENGLISH!");
71 }
72 }
73 if (exec) logln("TestSuite Format: ");
74 switch (index) {
75 TESTCLASS(0,IntlTestDateFormat);
76 TESTCLASS(1,IntlTestNumberFormat);
77 TESTCLASS(2,CalendarTest);
78 TESTCLASS(3,CalendarLimitTest);
79 TESTCLASS(4,TimeZoneTest);
80 TESTCLASS(5,TimeZoneBoundaryTest);
81 TESTCLASS(6,TestChoiceFormat);
82 TESTCLASS(7,IntlTestDecimalFormatSymbols);
83 TESTCLASS(8,IntlTestDateFormatSymbols);
84 TESTCLASS(9,IntlTestDecimalFormatAPI);
85 TESTCLASS(10,TestFormatSmallClasses);
86 TESTCLASS(11,IntlTestNumberFormatAPI);
87 TESTCLASS(12,IntlTestSimpleDateFormatAPI);
88 TESTCLASS(13,IntlTestDateFormatAPI);
89 TESTCLASS(14,DateFormatTest);
90 TESTCLASS(15,TestMessageFormat);
91 TESTCLASS(16,NumberFormatTest);
92 TESTCLASS(17,DateFormatRegressionTest);
93 TESTCLASS(18,MessageFormatRegressionTest);
94 TESTCLASS(19,DateFormatMiscTests);
95 TESTCLASS(20,NumberFormatRoundTripTest);
96 TESTCLASS(21,NumberFormatRegressionTest);
97 TESTCLASS(22,DateFormatRoundTripTest);
98 TESTCLASS(23,ParsePositionTest);
99 TESTCLASS(24,CalendarRegressionTest);
100 TESTCLASS(25,TimeZoneRegressionTest);
101 TESTCLASS(26,IntlCalendarTest);
102 TESTCLASS(27,AstroTest);
103 TESTCLASS(28,CalendarCaseTest);
104
105 default: name = ""; break; //needed to end loop
106 }
107 if (exec) {
108 // restore saved Locale and TimeZone
109 TimeZone::adoptDefault(saveDefaultTimeZone);
110 UErrorCode status = U_ZERO_ERROR;
111 Locale::setDefault( saveDefaultLocale, status );
112 if (U_FAILURE(status)) {
113 errln("itformat: couldn't re-set default Locale!");
114 }
115 }
116 }
117
118 #endif /* #if !UCONFIG_NO_FORMATTING */