]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/dtfmttst.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /********************************************************************
5 * Copyright (c) 1997-2016, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 ********************************************************************/
9 #ifndef _DATEFORMATTEST_
10 #define _DATEFORMATTEST_
12 #include "unicode/utypes.h"
14 #if !UCONFIG_NO_FORMATTING
16 #include "unicode/datefmt.h"
17 #include "unicode/smpdtfmt.h"
21 * Performs many different tests for DateFormat and SimpleDateFormat
23 class DateFormatTest
: public CalendarTimeZoneTest
{
25 void runIndexedTest( int32_t index
, UBool exec
, const char* &name
, char* par
);
28 * Verify that patterns have the correct values and could produce
29 * the DateFormat instances that contain the correct localized patterns.
33 * "Test written by Wally Wedel and emailed to me."
34 * Test handling of timezone offsets
36 virtual void TestWallyWedel(void);
40 virtual void TestEquals(void);
42 * Test the parsing of 2-digit years.
44 virtual void TestTwoDigitYearDSTParse(void);
47 // internal utility routine (genrates escape sequences for characters)
48 static UnicodeString
& escape(UnicodeString
& s
);
52 * Verify that returned field position indices are correct.
54 void TestFieldPosition(void);
59 // internal utility function
60 static void getFieldText(DateFormat
* df
, int32_t field
, UDate date
, UnicodeString
& str
);
64 * Verify that strings which contain incomplete specifications are parsed
65 * correctly. In some instances, this means not being parsed at all, and
66 * returning an appropriate error.
68 virtual void TestPartialParse994(void);
71 // internal test subroutine, used by TestPartialParse994
72 virtual void tryPat994(SimpleDateFormat
* format
, const char* pat
, const char* str
, UDate expected
);
76 * Verify the behavior of patterns in which digits for different fields run together
77 * without intervening separators.
79 virtual void TestRunTogetherPattern985(void);
81 * Verify the behavior of patterns in which digits for different fields run together
82 * without intervening separators.
84 virtual void TestRunTogetherPattern917(void);
87 // internal test subroutine, used by TestRunTogetherPattern917
88 virtual void testIt917(SimpleDateFormat
* fmt
, UnicodeString
& str
, UDate expected
);
92 * Verify the handling of Czech June and July, which have the unique attribute that
93 * one is a proper prefix substring of the other.
95 virtual void TestCzechMonths459(void);
97 * Test the handling of 'D' in patterns.
99 virtual void TestLetterDPattern212(void);
101 * Test the day of year pattern.
103 virtual void TestDayOfYearPattern195(void);
106 // interl test subroutine, used by TestDayOfYearPattern195
107 virtual void tryPattern(SimpleDateFormat
& sdf
, UDate d
, const char* pattern
, UDate expected
);
111 * Test the handling of single quotes in patterns.
113 virtual void TestQuotePattern161(void);
115 * Verify the correct behavior when handling invalid input strings.
117 virtual void TestBadInput135(void);
121 * Verify the correct behavior when parsing an array of inputs against an
122 * array of patterns, with known results. The results are encoded after
123 * the input strings in each row.
125 virtual void TestBadInput135a(void);
127 * Test the parsing of two-digit years.
129 virtual void TestTwoDigitYear(void);
132 // internal test subroutine, used by TestTwoDigitYear
133 virtual void parse2DigitYear(DateFormat
& fmt
, const char* str
, UDate expected
);
137 * Test the formatting of time zones.
139 virtual void TestDateFormatZone061(void);
141 * Further test the formatting of time zones.
143 virtual void TestDateFormatZone146(void);
145 void TestTimeZoneStringsAPI(void);
147 void TestGMTParsing(void);
151 * Test the formatting of dates in different locales.
153 virtual void TestLocaleDateFormat(void);
155 virtual void TestFormattingLocaleTimeSeparator(void);
157 virtual void TestDateFormatCalendar(void);
159 virtual void TestSpaceParsing(void);
161 void TestExactCountFormat(void);
163 void TestWhiteSpaceParsing(void);
165 void TestInvalidPattern(void);
167 void TestGreekMay(void);
169 void TestGenericTime(void);
171 void TestGenericTimeZoneOrder(void);
179 void TestISOEra(void);
181 void TestFormalChineseDate(void);
183 void TestStandAloneGMTParse(void);
185 void TestParsePosition(void);
187 void TestMonthPatterns(void);
189 void TestContext(void);
191 void TestNonGregoFmtParse(void);
193 void TestFormatsWithNumberSystems(void);
197 * Test host-specific formatting.
203 * Test patterns added in CLDR 1.4, CLDR 23
207 void TestNarrowNames(void);
209 void TestShortDays(void);
211 void TestStandAloneDays(void);
213 void TestStandAloneMonths(void);
215 void TestQuarters(void);
217 void TestZTimeZoneParsing(void);
219 void TestRelativeClone(void);
221 void TestHostClone(void);
223 void TestHebrewClone(void);
225 void TestDateFormatSymbolsClone(void);
227 void TestTimeZoneDisplayName(void);
229 void TestRoundtripWithCalendar(void);
233 * Test Relative Dates
235 void TestRelative(void);
236 /* void TestRelativeError(void);
237 void TestRelativeOther(void);
240 void TestDotAndAtLeniency();
242 void TestDateFormatLeniency();
244 void TestParseMultiPatternMatch();
246 void TestParseLeniencyAPIs();
248 // test override NumberFormat
249 void TestNumberFormatOverride();
250 void TestCreateInstanceForSkeleton();
251 void TestCreateInstanceForSkeletonDefault();
252 void TestCreateInstanceForSkeletonWithCalendar();
253 void TestDFSCreateForLocaleNonGregorianLocale();
254 void TestDFSCreateForLocaleWithCalendarInLocale();
255 void TestChangeCalendar();
257 void TestPatternFromSkeleton();
259 void TestAmPmMidnightNoon();
260 void TestFlexibleDayPeriod();
261 void TestDayPeriodWithLocales();
262 void TestMinuteSecondFieldsInOddPlaces();
263 void TestDayPeriodParsing();
264 void TestParseRegression13744();
267 UBool
showParse(DateFormat
&format
, const UnicodeString
&formattedString
);
271 * Test parsing a number as a string
273 void TestNumberAsStringParsing(void);
276 void TestRelative(int daysdelta
,
278 const char *expectChars
);
281 void expectParse(const char** data
, int32_t data_length
,
282 const Locale
& locale
);
284 void expect(const char** data
, int32_t data_length
,
287 void expectFormat(const char **data
, int32_t data_length
,
288 const Locale
&locale
);
292 #endif /* #if !UCONFIG_NO_FORMATTING */
294 #endif // _DATEFORMATTEST_