2000-01-15 02:00:06 +00:00
|
|
|
/********************************************************************
|
|
|
|
* COPYRIGHT:
|
2011-05-04 12:23:42 +00:00
|
|
|
* Copyright (c) 1997-2011, International Business Machines Corporation and
|
2000-01-15 02:00:06 +00:00
|
|
|
* others. All Rights Reserved.
|
|
|
|
********************************************************************/
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
#ifndef _DATEFORMATTEST_
|
|
|
|
#define _DATEFORMATTEST_
|
|
|
|
|
2002-09-21 00:43:14 +00:00
|
|
|
#include "unicode/utypes.h"
|
|
|
|
|
|
|
|
#if !UCONFIG_NO_FORMATTING
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
#include "unicode/datefmt.h"
|
2001-10-08 23:26:58 +00:00
|
|
|
#include "unicode/smpdtfmt.h"
|
|
|
|
#include "caltztst.h"
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
/**
|
2009-12-17 22:15:20 +00:00
|
|
|
* Performs many different tests for DateFormat and SimpleDateFormat
|
1999-08-16 21:50:52 +00:00
|
|
|
**/
|
|
|
|
class DateFormatTest: public CalendarTimeZoneTest {
|
|
|
|
// IntlTest override
|
2000-08-14 21:42:36 +00:00
|
|
|
void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par );
|
1999-08-16 21:50:52 +00:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* "Test written by Wally Wedel and emailed to me."
|
|
|
|
* Test handling of timezone offsets
|
|
|
|
**/
|
|
|
|
virtual void TestWallyWedel(void);
|
|
|
|
/**
|
|
|
|
* Test operator==
|
|
|
|
*/
|
|
|
|
virtual void TestEquals(void);
|
|
|
|
/**
|
|
|
|
* Test the parsing of 2-digit years.
|
|
|
|
*/
|
1999-12-22 22:57:04 +00:00
|
|
|
virtual void TestTwoDigitYearDSTParse(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
public: // package
|
|
|
|
// internal utility routine (genrates escape sequences for characters)
|
|
|
|
static UnicodeString& escape(UnicodeString& s);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Verify that returned field position indices are correct.
|
|
|
|
*/
|
2004-03-11 14:05:12 +00:00
|
|
|
void TestFieldPosition(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2004-03-11 14:05:12 +00:00
|
|
|
void TestGeneral();
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
public: // package
|
|
|
|
// internal utility function
|
|
|
|
static void getFieldText(DateFormat* df, int32_t field, UDate date, UnicodeString& str);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Verify that strings which contain incomplete specifications are parsed
|
|
|
|
* correctly. In some instances, this means not being parsed at all, and
|
|
|
|
* returning an appropriate error.
|
|
|
|
*/
|
|
|
|
virtual void TestPartialParse994(void);
|
|
|
|
|
|
|
|
public: // package
|
|
|
|
// internal test subroutine, used by TestPartialParse994
|
|
|
|
virtual void tryPat994(SimpleDateFormat* format, const char* pat, const char* str, UDate expected);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Verify the behavior of patterns in which digits for different fields run together
|
|
|
|
* without intervening separators.
|
|
|
|
*/
|
|
|
|
virtual void TestRunTogetherPattern985(void);
|
|
|
|
/**
|
|
|
|
* Verify the behavior of patterns in which digits for different fields run together
|
|
|
|
* without intervening separators.
|
|
|
|
*/
|
|
|
|
virtual void TestRunTogetherPattern917(void);
|
|
|
|
|
|
|
|
public: // package
|
|
|
|
// internal test subroutine, used by TestRunTogetherPattern917
|
|
|
|
virtual void testIt917(SimpleDateFormat* fmt, UnicodeString& str, UDate expected);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Verify the handling of Czech June and July, which have the unique attribute that
|
|
|
|
* one is a proper prefix substring of the other.
|
|
|
|
*/
|
|
|
|
virtual void TestCzechMonths459(void);
|
|
|
|
/**
|
|
|
|
* Test the handling of 'D' in patterns.
|
|
|
|
*/
|
|
|
|
virtual void TestLetterDPattern212(void);
|
|
|
|
/**
|
|
|
|
* Test the day of year pattern.
|
|
|
|
*/
|
|
|
|
virtual void TestDayOfYearPattern195(void);
|
|
|
|
|
|
|
|
public: // package
|
|
|
|
// interl test subroutine, used by TestDayOfYearPattern195
|
|
|
|
virtual void tryPattern(SimpleDateFormat& sdf, UDate d, const char* pattern, UDate expected);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Test the handling of single quotes in patterns.
|
|
|
|
*/
|
|
|
|
virtual void TestQuotePattern161(void);
|
|
|
|
/**
|
|
|
|
* Verify the correct behavior when handling invalid input strings.
|
|
|
|
*/
|
|
|
|
virtual void TestBadInput135(void);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Verify the correct behavior when parsing an array of inputs against an
|
|
|
|
* array of patterns, with known results. The results are encoded after
|
|
|
|
* the input strings in each row.
|
|
|
|
*/
|
|
|
|
virtual void TestBadInput135a(void);
|
|
|
|
/**
|
|
|
|
* Test the parsing of two-digit years.
|
|
|
|
*/
|
|
|
|
virtual void TestTwoDigitYear(void);
|
|
|
|
|
|
|
|
public: // package
|
|
|
|
// internal test subroutine, used by TestTwoDigitYear
|
|
|
|
virtual void parse2DigitYear(DateFormat& fmt, const char* str, UDate expected);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Test the formatting of time zones.
|
|
|
|
*/
|
|
|
|
virtual void TestDateFormatZone061(void);
|
|
|
|
/**
|
|
|
|
* Further test the formatting of time zones.
|
|
|
|
*/
|
|
|
|
virtual void TestDateFormatZone146(void);
|
2005-08-26 21:55:55 +00:00
|
|
|
|
2005-09-01 18:07:52 +00:00
|
|
|
void TestTimeZoneStringsAPI(void);
|
2009-03-25 05:02:30 +00:00
|
|
|
|
|
|
|
void TestGMTParsing(void);
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
public: // package
|
|
|
|
/**
|
|
|
|
* Test the formatting of dates in different locales.
|
|
|
|
*/
|
|
|
|
virtual void TestLocaleDateFormat(void);
|
2002-04-09 23:24:42 +00:00
|
|
|
|
|
|
|
virtual void TestDateFormatCalendar(void);
|
2002-08-22 21:55:51 +00:00
|
|
|
|
|
|
|
virtual void TestSpaceParsing(void);
|
2003-03-07 01:04:43 +00:00
|
|
|
|
|
|
|
void TestExactCountFormat(void);
|
|
|
|
|
2003-04-04 20:55:10 +00:00
|
|
|
void TestWhiteSpaceParsing(void);
|
|
|
|
|
2003-10-13 17:15:39 +00:00
|
|
|
void TestInvalidPattern(void);
|
|
|
|
|
2004-06-07 21:59:41 +00:00
|
|
|
void TestGreekMay(void);
|
|
|
|
|
2005-06-04 03:08:25 +00:00
|
|
|
void TestGenericTime(void);
|
|
|
|
|
|
|
|
void TestGenericTimeZoneOrder(void);
|
|
|
|
|
2009-01-29 18:35:02 +00:00
|
|
|
void Test6338(void);
|
|
|
|
|
2009-03-16 15:23:11 +00:00
|
|
|
void Test6726(void);
|
2009-04-28 06:20:32 +00:00
|
|
|
|
|
|
|
void Test6880(void);
|
|
|
|
|
2010-04-06 18:04:27 +00:00
|
|
|
void TestISOEra(void);
|
|
|
|
|
2010-08-13 21:23:00 +00:00
|
|
|
void TestFormalChineseDate(void);
|
|
|
|
|
2011-07-06 16:42:25 +00:00
|
|
|
void TestStandAloneGMTParse(void);
|
|
|
|
|
2006-01-23 23:25:00 +00:00
|
|
|
public:
|
|
|
|
/**
|
2006-06-26 17:51:25 +00:00
|
|
|
* Test host-specific formatting.
|
|
|
|
*/
|
2006-01-23 23:25:00 +00:00
|
|
|
void TestHost(void);
|
|
|
|
|
2006-06-26 17:51:25 +00:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Test patterns added in CLDR 1.4
|
|
|
|
*/
|
|
|
|
void TestEras(void);
|
|
|
|
|
|
|
|
void TestNarrowNames(void);
|
|
|
|
|
|
|
|
void TestStandAloneDays(void);
|
|
|
|
|
|
|
|
void TestStandAloneMonths(void);
|
|
|
|
|
|
|
|
void TestQuarters(void);
|
2007-03-02 06:57:40 +00:00
|
|
|
|
|
|
|
void TestZTimeZoneParsing(void);
|
2007-06-12 01:36:50 +00:00
|
|
|
|
|
|
|
void TestRelativeClone(void);
|
2007-04-09 22:29:57 +00:00
|
|
|
|
2007-06-12 05:20:11 +00:00
|
|
|
void TestHostClone(void);
|
|
|
|
|
2009-01-23 23:15:42 +00:00
|
|
|
void TestTimeZoneDisplayName(void);
|
|
|
|
|
|
|
|
void TestRoundtripWithCalendar(void);
|
|
|
|
|
2007-04-09 22:29:57 +00:00
|
|
|
public:
|
|
|
|
/***
|
|
|
|
* Test Relative Dates
|
|
|
|
*/
|
|
|
|
void TestRelative(void);
|
|
|
|
/* void TestRelativeError(void);
|
|
|
|
void TestRelativeOther(void);
|
|
|
|
*/
|
|
|
|
|
2011-05-04 12:23:42 +00:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Test parsing a number as a string
|
|
|
|
*/
|
|
|
|
void TestNumberAsStringParsing(void);
|
|
|
|
|
2007-04-09 22:29:57 +00:00
|
|
|
private:
|
|
|
|
void TestRelative(int daysdelta,
|
|
|
|
const Locale& loc,
|
|
|
|
const char *expectChars);
|
2006-06-26 17:51:25 +00:00
|
|
|
|
2003-03-07 01:04:43 +00:00
|
|
|
private:
|
|
|
|
void expectParse(const char** data, int32_t data_length,
|
|
|
|
const Locale& locale);
|
2004-03-11 14:05:12 +00:00
|
|
|
|
|
|
|
void expect(const char** data, int32_t data_length,
|
|
|
|
const Locale& loc);
|
2006-06-26 17:51:25 +00:00
|
|
|
|
|
|
|
void expectFormat(const char **data, int32_t data_length,
|
|
|
|
const Locale &locale);
|
1999-08-16 21:50:52 +00:00
|
|
|
};
|
2002-09-21 00:43:14 +00:00
|
|
|
|
|
|
|
#endif /* #if !UCONFIG_NO_FORMATTING */
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
#endif // _DATEFORMATTEST_
|
|
|
|
//eof
|