• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /********************************************************************
4  * COPYRIGHT:
5  * Copyright (c) 2008-2016 International Business Machines Corporation and
6  * others. All Rights Reserved.
7  ********************************************************************/
8 
9 #ifndef _INTLTESTDATEINTERVALFORMAT
10 #define _INTLTESTDATEINTERVALFORMAT
11 
12 #include "unicode/utypes.h"
13 #include "unicode/locid.h"
14 
15 #if !UCONFIG_NO_FORMATTING
16 
17 #include "intltest.h"
18 #include "itformat.h"
19 
20 U_NAMESPACE_BEGIN
21 class FormattedDateInterval;
22 U_NAMESPACE_END
23 
24 /**
25  * Test basic functionality of various API functions
26  **/
27 class DateIntervalFormatTest: public IntlTestWithFieldPosition {
28     void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par = NULL ) override;
29 
30 public:
31     /**
32      * Performs tests on many API functions, see detailed comments in source code
33      **/
34     void testAPI();
35 
36     /**
37      * Test formatting
38      */
39     void testFormat();
40 
41 
42     /**
43      * Test handling of hour and day period metacharacters
44      */
45     void testHourMetacharacters();
46 
47     void testFormatMillisecond();
48 
49     /**
50      * Test formatting using user defined DateIntervalInfo
51      */
52     void testFormatUserDII();
53 
54     /*
55      * Test format using UDisplayContext
56      */
57     void testContext();
58 
59     /**
60      * Test for no unwanted side effects when setting
61      * interval patterns.
62      */
63     void testSetIntervalPatternNoSideEffect();
64 
65     /**
66      * Tests different year formats.
67      */
68     void testYearFormats();
69 
70     /**
71      * Stress test -- stress test formatting on 40 locales
72      */
73     void testStress();
74 
75     void testTicket11583_2();
76 
77     void testTicket11985();
78 
79     void testTicket11669();
80     void threadFunc11669(int32_t threadNum);
81 
82     void testTicket12065();
83 
84     void testFormattedDateInterval();
85     void testCreateInstanceForAllLocales();
86 
87     void testTicket20707();
88     void testTicket21222GregorianEraDiff();
89     void testTicket21222ROCEraDiff();
90     void testTicket21222JapaneseEraDiff();
91 
92     void testTicket21939();
93 
94 private:
95     /**
96      * Test formatting against expected result
97      */
98     void expect(const char** data, int32_t data_length);
99 
100     /**
101      * Test formatting against expected result using user defined
102      * DateIntervalInfo
103      */
104     void expectUserDII(const char** data, int32_t data_length);
105 
106     /**
107      * Stress test formatting
108      */
109     void stress(const char** data, int32_t data_length, const Locale& loc,
110                 const char* locName);
111 
112     void getCategoryAndField(
113         const FormattedDateInterval& formatted,
114         std::vector<int32_t>& categories,
115         std::vector<int32_t>& fields,
116         IcuTestErrorCode& status);
117 
118     void verifyCategoryAndField(
119         const FormattedDateInterval& formatted,
120         const std::vector<int32_t>& categories,
121         const std::vector<int32_t>& fields,
122         IcuTestErrorCode& status);
123 
124 };
125 
126 #endif /* #if !UCONFIG_NO_FORMATTING */
127 
128 #endif
129