1 /********************************************************************
3 * Copyright (c) 1997-2010, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
7 #ifndef _DATEFORMATTEST_
8 #define _DATEFORMATTEST_
10 #include "unicode/utypes.h"
12 #if !UCONFIG_NO_FORMATTING
14 #include "unicode/datefmt.h"
15 #include "unicode/smpdtfmt.h"
19 * Performs many different tests for DateFormat and SimpleDateFormat
21 class DateFormatTest: public CalendarTimeZoneTest {
23 void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par );
26 * "Test written by Wally Wedel and emailed to me."
27 * Test handling of timezone offsets
29 virtual void TestWallyWedel(void);
33 virtual void TestEquals(void);
35 * Test the parsing of 2-digit years.
37 virtual void TestTwoDigitYearDSTParse(void);
40 // internal utility routine (genrates escape sequences for characters)
41 static UnicodeString& escape(UnicodeString& s);
45 * Verify that returned field position indices are correct.
47 void TestFieldPosition(void);
52 // internal utility function
53 static void getFieldText(DateFormat* df, int32_t field, UDate date, UnicodeString& str);
57 * Verify that strings which contain incomplete specifications are parsed
58 * correctly. In some instances, this means not being parsed at all, and
59 * returning an appropriate error.
61 virtual void TestPartialParse994(void);
64 // internal test subroutine, used by TestPartialParse994
65 virtual void tryPat994(SimpleDateFormat* format, const char* pat, const char* str, UDate expected);
69 * Verify the behavior of patterns in which digits for different fields run together
70 * without intervening separators.
72 virtual void TestRunTogetherPattern985(void);
74 * Verify the behavior of patterns in which digits for different fields run together
75 * without intervening separators.
77 virtual void TestRunTogetherPattern917(void);
80 // internal test subroutine, used by TestRunTogetherPattern917
81 virtual void testIt917(SimpleDateFormat* fmt, UnicodeString& str, UDate expected);
85 * Verify the handling of Czech June and July, which have the unique attribute that
86 * one is a proper prefix substring of the other.
88 virtual void TestCzechMonths459(void);
90 * Test the handling of 'D' in patterns.
92 virtual void TestLetterDPattern212(void);
94 * Test the day of year pattern.
96 virtual void TestDayOfYearPattern195(void);
99 // interl test subroutine, used by TestDayOfYearPattern195
100 virtual void tryPattern(SimpleDateFormat& sdf, UDate d, const char* pattern, UDate expected);
104 * Test the handling of single quotes in patterns.
106 virtual void TestQuotePattern161(void);
108 * Verify the correct behavior when handling invalid input strings.
110 virtual void TestBadInput135(void);
114 * Verify the correct behavior when parsing an array of inputs against an
115 * array of patterns, with known results. The results are encoded after
116 * the input strings in each row.
118 virtual void TestBadInput135a(void);
120 * Test the parsing of two-digit years.
122 virtual void TestTwoDigitYear(void);
125 // internal test subroutine, used by TestTwoDigitYear
126 virtual void parse2DigitYear(DateFormat& fmt, const char* str, UDate expected);
130 * Test the formatting of time zones.
132 virtual void TestDateFormatZone061(void);
134 * Further test the formatting of time zones.
136 virtual void TestDateFormatZone146(void);
138 void TestTimeZoneStringsAPI(void);
140 void TestGMTParsing(void);
144 * Test the formatting of dates in different locales.
146 virtual void TestLocaleDateFormat(void);
148 virtual void TestDateFormatCalendar(void);
150 virtual void TestSpaceParsing(void);
152 void TestExactCountFormat(void);
154 void TestWhiteSpaceParsing(void);
156 void TestInvalidPattern(void);
158 void TestGreekMay(void);
160 void TestGenericTime(void);
162 void TestGenericTimeZoneOrder(void);
170 void TestISOEra(void);
172 void TestFormalChineseDate(void);
176 * Test host-specific formatting.
182 * Test patterns added in CLDR 1.4
186 void TestNarrowNames(void);
188 void TestStandAloneDays(void);
190 void TestStandAloneMonths(void);
192 void TestQuarters(void);
194 void TestZTimeZoneParsing(void);
196 void TestRelativeClone(void);
198 void TestHostClone(void);
200 void TestTimeZoneDisplayName(void);
202 void TestRoundtripWithCalendar(void);
206 * Test Relative Dates
208 void TestRelative(void);
209 /* void TestRelativeError(void);
210 void TestRelativeOther(void);
214 void TestRelative(int daysdelta,
216 const char *expectChars);
219 void expectParse(const char** data, int32_t data_length,
220 const Locale& locale);
222 void expect(const char** data, int32_t data_length,
225 void expectFormat(const char **data, int32_t data_length,
226 const Locale &locale);
229 #endif /* #if !UCONFIG_NO_FORMATTING */
231 #endif // _DATEFORMATTEST_