Home | History | Annotate | Download | only in intltest
      1 /********************************************************************
      2  * COPYRIGHT:
      3  * Copyright (c) 1997-2013, 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 TestDateFormatCalendar(void);
    154 
    155     virtual void TestSpaceParsing(void);
    156 
    157     void TestExactCountFormat(void);
    158 
    159     void TestWhiteSpaceParsing(void);
    160 
    161     void TestInvalidPattern(void);
    162 
    163     void TestGreekMay(void);
    164 
    165     void TestGenericTime(void);
    166 
    167     void TestGenericTimeZoneOrder(void);
    168 
    169     void Test6338(void);
    170 
    171     void Test6726(void);
    172 
    173     void Test6880(void);
    174 
    175     void TestISOEra(void);
    176 
    177     void TestFormalChineseDate(void);
    178 
    179     void TestStandAloneGMTParse(void);
    180 
    181     void TestParsePosition(void);
    182 
    183     void TestMonthPatterns(void);
    184 
    185     void TestContext(void);
    186 
    187     void TestNonGregoFmtParse(void);
    188 
    189 public:
    190     /**
    191      * Test host-specific formatting.
    192      */
    193     void TestHost(void);
    194 
    195 public:
    196     /**
    197      * Test patterns added in CLDR 1.4, CLDR 23
    198      */
    199     void TestEras(void);
    200 
    201     void TestNarrowNames(void);
    202 
    203     void TestShortDays(void);
    204 
    205     void TestStandAloneDays(void);
    206 
    207     void TestStandAloneMonths(void);
    208 
    209     void TestQuarters(void);
    210 
    211     void TestZTimeZoneParsing(void);
    212 
    213     void TestRelativeClone(void);
    214 
    215     void TestHostClone(void);
    216 
    217     void TestTimeZoneDisplayName(void);
    218 
    219     void TestRoundtripWithCalendar(void);
    220 
    221 public:
    222     /***
    223      * Test Relative Dates
    224      */
    225      void TestRelative(void);
    226 /*   void TestRelativeError(void);
    227      void TestRelativeOther(void);
    228 */
    229 
    230     void TestDotAndAtLeniency();
    231 private:
    232     UBool showParse(DateFormat &format, const UnicodeString &formattedString);
    233 
    234 public:
    235     /**
    236      * Test parsing a number as a string
    237      */
    238     void TestNumberAsStringParsing(void);
    239 
    240  private:
    241       void TestRelative(int daysdelta,
    242                                   const Locale& loc,
    243                                   const char *expectChars);
    244 
    245  private:
    246     void expectParse(const char** data, int32_t data_length,
    247                      const Locale& locale);
    248 
    249     void expect(const char** data, int32_t data_length,
    250                 const Locale& loc);
    251 
    252     void expectFormat(const char **data, int32_t data_length,
    253                       const Locale &locale);
    254 };
    255 
    256 #endif /* #if !UCONFIG_NO_FORMATTING */
    257 
    258 #endif // _DATEFORMATTEST_
    259 //eof
    260