Home | History | Annotate | Download | only in intltest
      1 /********************************************************************
      2  * COPYRIGHT:
      3  * Copyright (c) 1997-2014, International Business Machines Corporation and
      4  * others. All Rights Reserved.
      5  ********************************************************************/
      6 
      7 #ifndef _DATEFORMATTEST_
      8 #define _DATEFORMATTEST_
      9 
     10 #include "unicode/utypes.h"
     11 
     12 #if !UCONFIG_NO_FORMATTING
     13 
     14 #include "unicode/datefmt.h"
     15 #include "unicode/smpdtfmt.h"
     16 #include "caltztst.h"
     17 
     18 /**
     19  * Performs many different tests for DateFormat and SimpleDateFormat
     20  **/
     21 class DateFormatTest: public CalendarTimeZoneTest {
     22     // IntlTest override
     23     void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par );
     24 public:
     25     /**
     26      * Verify that patterns have the correct values and could produce
     27      * the DateFormat instances that contain the correct localized patterns.
     28      */
     29     void TestPatterns();
     30     /**
     31      *  "Test written by Wally Wedel and emailed to me."
     32      *  Test handling of timezone offsets
     33      **/
     34     virtual void TestWallyWedel(void);
     35     /**
     36      * Test operator==
     37      */
     38     virtual void TestEquals(void);
     39     /**
     40      * Test the parsing of 2-digit years.
     41      */
     42     virtual void TestTwoDigitYearDSTParse(void);
     43 
     44 public: // package
     45     // internal utility routine (genrates escape sequences for characters)
     46     static UnicodeString& escape(UnicodeString& s);
     47 
     48 public:
     49     /**
     50      * Verify that returned field position indices are correct.
     51      */
     52     void TestFieldPosition(void);
     53 
     54     void TestGeneral();
     55 
     56 public: // package
     57     // internal utility function
     58     static void getFieldText(DateFormat* df, int32_t field, UDate date, UnicodeString& str);
     59 
     60 public:
     61     /**
     62      * Verify that strings which contain incomplete specifications are parsed
     63      * correctly.  In some instances, this means not being parsed at all, and
     64      * returning an appropriate error.
     65      */
     66     virtual void TestPartialParse994(void);
     67 
     68 public: // package
     69     // internal test subroutine, used by TestPartialParse994
     70     virtual void tryPat994(SimpleDateFormat* format, const char* pat, const char* str, UDate expected);
     71 
     72 public:
     73     /**
     74      * Verify the behavior of patterns in which digits for different fields run together
     75      * without intervening separators.
     76      */
     77     virtual void TestRunTogetherPattern985(void);
     78     /**
     79      * Verify the behavior of patterns in which digits for different fields run together
     80      * without intervening separators.
     81      */
     82     virtual void TestRunTogetherPattern917(void);
     83 
     84 public: // package
     85     // internal test subroutine, used by TestRunTogetherPattern917
     86     virtual void testIt917(SimpleDateFormat* fmt, UnicodeString& str, UDate expected);
     87 
     88 public:
     89     /**
     90      * Verify the handling of Czech June and July, which have the unique attribute that
     91      * one is a proper prefix substring of the other.
     92      */
     93     virtual void TestCzechMonths459(void);
     94     /**
     95      * Test the handling of 'D' in patterns.
     96      */
     97     virtual void TestLetterDPattern212(void);
     98     /**
     99      * Test the day of year pattern.
    100      */
    101     virtual void TestDayOfYearPattern195(void);
    102 
    103 public: // package
    104     // interl test subroutine, used by TestDayOfYearPattern195
    105     virtual void tryPattern(SimpleDateFormat& sdf, UDate d, const char* pattern, UDate expected);
    106 
    107 public:
    108     /**
    109      * Test the handling of single quotes in patterns.
    110      */
    111     virtual void TestQuotePattern161(void);
    112     /**
    113      * Verify the correct behavior when handling invalid input strings.
    114      */
    115     virtual void TestBadInput135(void);
    116 
    117 public:
    118     /**
    119      * Verify the correct behavior when parsing an array of inputs against an
    120      * array of patterns, with known results.  The results are encoded after
    121      * the input strings in each row.
    122      */
    123     virtual void TestBadInput135a(void);
    124     /**
    125      * Test the parsing of two-digit years.
    126      */
    127     virtual void TestTwoDigitYear(void);
    128 
    129 public: // package
    130     // internal test subroutine, used by TestTwoDigitYear
    131     virtual void parse2DigitYear(DateFormat& fmt, const char* str, UDate expected);
    132 
    133 public:
    134     /**
    135      * Test the formatting of time zones.
    136      */
    137     virtual void TestDateFormatZone061(void);
    138     /**
    139      * Further test the formatting of time zones.
    140      */
    141     virtual void TestDateFormatZone146(void);
    142 
    143     void TestTimeZoneStringsAPI(void);
    144 
    145     void TestGMTParsing(void);
    146 
    147 public: // package
    148     /**
    149      * Test the formatting of dates in different locales.
    150      */
    151     virtual void TestLocaleDateFormat(void);
    152 
    153     virtual void TestFormattingLocaleTimeSeparator(void);
    154 
    155     virtual void TestDateFormatCalendar(void);
    156 
    157     virtual void TestSpaceParsing(void);
    158 
    159     void TestExactCountFormat(void);
    160 
    161     void TestWhiteSpaceParsing(void);
    162 
    163     void TestInvalidPattern(void);
    164 
    165     void TestGreekMay(void);
    166 
    167     void TestGenericTime(void);
    168 
    169     void TestGenericTimeZoneOrder(void);
    170 
    171     void Test6338(void);
    172 
    173     void Test6726(void);
    174 
    175     void Test6880(void);
    176 
    177     void TestISOEra(void);
    178 
    179     void TestFormalChineseDate(void);
    180 
    181     void TestStandAloneGMTParse(void);
    182 
    183     void TestParsePosition(void);
    184 
    185     void TestMonthPatterns(void);
    186 
    187     void TestContext(void);
    188 
    189     void TestNonGregoFmtParse(void);
    190 
    191 public:
    192     /**
    193      * Test host-specific formatting.
    194      */
    195     void TestHost(void);
    196 
    197 public:
    198     /**
    199      * Test patterns added in CLDR 1.4, CLDR 23
    200      */
    201     void TestEras(void);
    202 
    203     void TestNarrowNames(void);
    204 
    205     void TestShortDays(void);
    206 
    207     void TestStandAloneDays(void);
    208 
    209     void TestStandAloneMonths(void);
    210 
    211     void TestQuarters(void);
    212 
    213     void TestZTimeZoneParsing(void);
    214 
    215     void TestRelativeClone(void);
    216 
    217     void TestHostClone(void);
    218 
    219     void TestHebrewClone(void);
    220 
    221     void TestDateFormatSymbolsClone(void);
    222 
    223     void TestTimeZoneDisplayName(void);
    224 
    225     void TestRoundtripWithCalendar(void);
    226 
    227 public:
    228     /***
    229      * Test Relative Dates
    230      */
    231      void TestRelative(void);
    232 /*   void TestRelativeError(void);
    233      void TestRelativeOther(void);
    234 */
    235 
    236     void TestDotAndAtLeniency();
    237 
    238     void TestDateFormatLeniency();
    239 
    240     void TestParseMultiPatternMatch();
    241 
    242     void TestParseLeniencyAPIs();
    243 
    244     // test override NumberFormat
    245     void TestNumberFormatOverride();
    246     void TestCreateInstanceForSkeleton();
    247     void TestCreateInstanceForSkeletonDefault();
    248     void TestCreateInstanceForSkeletonWithCalendar();
    249     void TestDFSCreateForLocaleNonGregorianLocale();
    250     void TestDFSCreateForLocaleWithCalendarInLocale();
    251     void TestChangeCalendar();
    252 
    253 private:
    254     UBool showParse(DateFormat &format, const UnicodeString &formattedString);
    255 
    256 public:
    257     /**
    258      * Test parsing a number as a string
    259      */
    260     void TestNumberAsStringParsing(void);
    261 
    262  private:
    263       void TestRelative(int daysdelta,
    264                                   const Locale& loc,
    265                                   const char *expectChars);
    266 
    267  private:
    268     void expectParse(const char** data, int32_t data_length,
    269                      const Locale& locale);
    270 
    271     void expect(const char** data, int32_t data_length,
    272                 const Locale& loc);
    273 
    274     void expectFormat(const char **data, int32_t data_length,
    275                       const Locale &locale);
    276 };
    277 
    278 #endif /* #if !UCONFIG_NO_FORMATTING */
    279 
    280 #endif // _DATEFORMATTEST_
    281 //eof
    282