]>
Commit | Line | Data |
---|---|---|
57a6839d A |
1 | /* |
2 | ******************************************************************************* | |
b331163b | 3 | * Copyright (C) 2013-2015, International Business Machines Corporation and * |
57a6839d A |
4 | * others. All Rights Reserved. * |
5 | ******************************************************************************* | |
6 | * | |
7 | * File RELDATEFMTTEST.CPP | |
8 | * | |
9 | ******************************************************************************* | |
10 | */ | |
11 | #include <stdio.h> | |
12 | #include <stdlib.h> | |
13 | ||
14 | #include "intltest.h" | |
15 | ||
b331163b | 16 | #if !UCONFIG_NO_FORMATTING && !UCONFIG_NO_BREAK_ITERATION |
57a6839d A |
17 | |
18 | #include "unicode/localpointer.h" | |
19 | #include "unicode/numfmt.h" | |
20 | #include "unicode/reldatefmt.h" | |
b331163b | 21 | #include "cmemory.h" |
57a6839d A |
22 | |
23 | static const char *DirectionStr(UDateDirection direction); | |
24 | static const char *RelativeUnitStr(UDateRelativeUnit unit); | |
25 | static const char *AbsoluteUnitStr(UDateAbsoluteUnit unit); | |
26 | ||
27 | typedef struct WithQuantityExpected { | |
28 | double value; | |
29 | UDateDirection direction; | |
30 | UDateRelativeUnit unit; | |
31 | const char *expected; | |
32 | } WithQuantityExpected; | |
33 | ||
34 | typedef struct WithoutQuantityExpected { | |
35 | UDateDirection direction; | |
36 | UDateAbsoluteUnit unit; | |
37 | const char *expected; | |
38 | } WithoutQuantityExpected; | |
39 | ||
40 | static WithQuantityExpected kEnglish[] = { | |
41 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "in 0 seconds"}, | |
42 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "in 0.5 seconds"}, | |
43 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "in 1 second"}, | |
44 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "in 2 seconds"}, | |
45 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MINUTES, "in 0 minutes"}, | |
46 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MINUTES, "in 0.5 minutes"}, | |
47 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MINUTES, "in 1 minute"}, | |
48 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MINUTES, "in 2 minutes"}, | |
49 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_HOURS, "in 0 hours"}, | |
50 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_HOURS, "in 0.5 hours"}, | |
51 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_HOURS, "in 1 hour"}, | |
52 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_HOURS, "in 2 hours"}, | |
53 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, "in 0 days"}, | |
54 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, "in 0.5 days"}, | |
55 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, "in 1 day"}, | |
56 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, "in 2 days"}, | |
57 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_WEEKS, "in 0 weeks"}, | |
58 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_WEEKS, "in 0.5 weeks"}, | |
59 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_WEEKS, "in 1 week"}, | |
60 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_WEEKS, "in 2 weeks"}, | |
61 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "in 0 months"}, | |
62 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "in 0.5 months"}, | |
63 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "in 1 month"}, | |
64 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "in 2 months"}, | |
65 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_YEARS, "in 0 years"}, | |
66 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_YEARS, "in 0.5 years"}, | |
67 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_YEARS, "in 1 year"}, | |
68 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_YEARS, "in 2 years"}, | |
69 | ||
70 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_SECONDS, "0 seconds ago"}, | |
71 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_SECONDS, "0.5 seconds ago"}, | |
72 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_SECONDS, "1 second ago"}, | |
73 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_SECONDS, "2 seconds ago"}, | |
74 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES, "0 minutes ago"}, | |
75 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES, "0.5 minutes ago"}, | |
76 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES, "1 minute ago"}, | |
77 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES, "2 minutes ago"}, | |
78 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, "0 hours ago"}, | |
79 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, "0.5 hours ago"}, | |
80 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, "1 hour ago"}, | |
81 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, "2 hours ago"}, | |
82 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, "0 days ago"}, | |
83 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, "0.5 days ago"}, | |
84 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, "1 day ago"}, | |
85 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, "2 days ago"}, | |
86 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_WEEKS, "0 weeks ago"}, | |
87 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_WEEKS, "0.5 weeks ago"}, | |
88 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_WEEKS, "1 week ago"}, | |
89 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_WEEKS, "2 weeks ago"}, | |
90 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "0 months ago"}, | |
91 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "0.5 months ago"}, | |
92 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "1 month ago"}, | |
93 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "2 months ago"}, | |
94 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, "0 years ago"}, | |
95 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, "0.5 years ago"}, | |
96 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, "1 year ago"}, | |
97 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, "2 years ago"} | |
98 | }; | |
99 | ||
b331163b A |
100 | static WithQuantityExpected kEnglishCaps[] = { |
101 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "In 0 seconds"}, | |
102 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "In 0.5 seconds"}, | |
103 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "In 1 second"}, | |
104 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "In 2 seconds"}, | |
105 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MINUTES, "In 0 minutes"}, | |
106 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MINUTES, "In 0.5 minutes"}, | |
107 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MINUTES, "In 1 minute"}, | |
108 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MINUTES, "In 2 minutes"}, | |
109 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_HOURS, "In 0 hours"}, | |
110 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_HOURS, "In 0.5 hours"}, | |
111 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_HOURS, "In 1 hour"}, | |
112 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_HOURS, "In 2 hours"}, | |
113 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, "In 0 days"}, | |
114 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, "In 0.5 days"}, | |
115 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, "In 1 day"}, | |
116 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, "In 2 days"}, | |
117 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_WEEKS, "In 0 weeks"}, | |
118 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_WEEKS, "In 0.5 weeks"}, | |
119 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_WEEKS, "In 1 week"}, | |
120 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_WEEKS, "In 2 weeks"}, | |
121 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "In 0 months"}, | |
122 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "In 0.5 months"}, | |
123 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "In 1 month"}, | |
124 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "In 2 months"}, | |
125 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_YEARS, "In 0 years"}, | |
126 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_YEARS, "In 0.5 years"}, | |
127 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_YEARS, "In 1 year"}, | |
128 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_YEARS, "In 2 years"}, | |
129 | ||
130 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_SECONDS, "0 seconds ago"}, | |
131 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_SECONDS, "0.5 seconds ago"}, | |
132 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_SECONDS, "1 second ago"}, | |
133 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_SECONDS, "2 seconds ago"}, | |
134 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES, "0 minutes ago"}, | |
135 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES, "0.5 minutes ago"}, | |
136 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES, "1 minute ago"}, | |
137 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES, "2 minutes ago"}, | |
138 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, "0 hours ago"}, | |
139 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, "0.5 hours ago"}, | |
140 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, "1 hour ago"}, | |
141 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, "2 hours ago"}, | |
142 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, "0 days ago"}, | |
143 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, "0.5 days ago"}, | |
144 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, "1 day ago"}, | |
145 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, "2 days ago"}, | |
146 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_WEEKS, "0 weeks ago"}, | |
147 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_WEEKS, "0.5 weeks ago"}, | |
148 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_WEEKS, "1 week ago"}, | |
149 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_WEEKS, "2 weeks ago"}, | |
150 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "0 months ago"}, | |
151 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "0.5 months ago"}, | |
152 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "1 month ago"}, | |
153 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "2 months ago"}, | |
154 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, "0 years ago"}, | |
155 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, "0.5 years ago"}, | |
156 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, "1 year ago"}, | |
157 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, "2 years ago"} | |
158 | }; | |
159 | ||
160 | static WithQuantityExpected kEnglishShort[] = { | |
161 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "in 0 sec."}, | |
162 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "in 0.5 sec."}, | |
163 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "in 1 sec."}, | |
164 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "in 2 sec."}, | |
165 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MINUTES, "in 0 min."}, | |
166 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MINUTES, "in 0.5 min."}, | |
167 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MINUTES, "in 1 min."}, | |
168 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MINUTES, "in 2 min."}, | |
169 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_HOURS, "in 0 hr."}, | |
170 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_HOURS, "in 0.5 hr."}, | |
171 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_HOURS, "in 1 hr."}, | |
172 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_HOURS, "in 2 hr."}, | |
173 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, "in 0 days"}, | |
174 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, "in 0.5 days"}, | |
175 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, "in 1 day"}, | |
176 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, "in 2 days"}, | |
177 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_WEEKS, "in 0 wk."}, | |
178 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_WEEKS, "in 0.5 wk."}, | |
179 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_WEEKS, "in 1 wk."}, | |
180 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_WEEKS, "in 2 wk."}, | |
181 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "in 0 mo."}, | |
182 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "in 0.5 mo."}, | |
183 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "in 1 mo."}, | |
184 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "in 2 mo."}, | |
185 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_YEARS, "in 0 yr."}, | |
186 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_YEARS, "in 0.5 yr."}, | |
187 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_YEARS, "in 1 yr."}, | |
188 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_YEARS, "in 2 yr."}, | |
189 | ||
190 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_SECONDS, "0 sec. ago"}, | |
191 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_SECONDS, "0.5 sec. ago"}, | |
192 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_SECONDS, "1 sec. ago"}, | |
193 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_SECONDS, "2 sec. ago"}, | |
194 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES, "0 min. ago"}, | |
195 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES, "0.5 min. ago"}, | |
196 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES, "1 min. ago"}, | |
197 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES, "2 min. ago"}, | |
198 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, "0 hr. ago"}, | |
199 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, "0.5 hr. ago"}, | |
200 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, "1 hr. ago"}, | |
201 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, "2 hr. ago"}, | |
202 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, "0 days ago"}, | |
203 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, "0.5 days ago"}, | |
204 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, "1 day ago"}, | |
205 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, "2 days ago"}, | |
206 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_WEEKS, "0 wk. ago"}, | |
207 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_WEEKS, "0.5 wk. ago"}, | |
208 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_WEEKS, "1 wk. ago"}, | |
209 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_WEEKS, "2 wk. ago"}, | |
210 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "0 mo. ago"}, | |
211 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "0.5 mo. ago"}, | |
212 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "1 mo. ago"}, | |
213 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "2 mo. ago"}, | |
214 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, "0 yr. ago"}, | |
215 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, "0.5 yr. ago"}, | |
216 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, "1 yr. ago"}, | |
217 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, "2 yr. ago"} | |
218 | }; | |
219 | ||
57a6839d A |
220 | static WithQuantityExpected kEnglishDecimal[] = { |
221 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "in 0.0 seconds"}, | |
222 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "in 0.5 seconds"}, | |
223 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "in 1.0 seconds"}, | |
224 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "in 2.0 seconds"} | |
225 | }; | |
226 | ||
227 | static WithQuantityExpected kSerbian[] = { | |
228 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "\\u0437\\u0430 0 \\u043c\\u0435\\u0441\\u0435\\u0446\\u0438"}, | |
229 | {1.2, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "\\u0437\\u0430 1,2 \\u043c\\u0435\\u0441\\u0435\\u0446\\u0430"}, | |
230 | {21.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "\\u0437\\u0430 21 \\u043c\\u0435\\u0441\\u0435\\u0446"} | |
231 | }; | |
232 | ||
b331163b A |
233 | static WithQuantityExpected kSerbianNarrow[] = { |
234 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "\\u0437\\u0430 0 \\u043c\\u0435\\u0441."}, | |
235 | {1.2, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "\\u0437\\u0430 1,2 \\u043c\\u0435\\u0441."}, | |
236 | {21.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "\\u0437\\u0430 21 \\u043c\\u0435\\u0441."} | |
237 | }; | |
238 | ||
57a6839d A |
239 | static WithoutQuantityExpected kEnglishNoQuantity[] = { |
240 | {UDAT_DIRECTION_NEXT_2, UDAT_ABSOLUTE_DAY, ""}, | |
241 | ||
242 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_DAY, "tomorrow"}, | |
243 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_WEEK, "next week"}, | |
244 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_MONTH, "next month"}, | |
245 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_YEAR, "next year"}, | |
246 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_MONDAY, "next Monday"}, | |
247 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_TUESDAY, "next Tuesday"}, | |
248 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_WEDNESDAY, "next Wednesday"}, | |
249 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_THURSDAY, "next Thursday"}, | |
250 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_FRIDAY, "next Friday"}, | |
251 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_SATURDAY, "next Saturday"}, | |
252 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_SUNDAY, "next Sunday"}, | |
253 | ||
254 | {UDAT_DIRECTION_LAST_2, UDAT_ABSOLUTE_DAY, ""}, | |
255 | ||
256 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_DAY, "yesterday"}, | |
257 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_WEEK, "last week"}, | |
258 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_MONTH, "last month"}, | |
259 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_YEAR, "last year"}, | |
260 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_MONDAY, "last Monday"}, | |
261 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_TUESDAY, "last Tuesday"}, | |
262 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_WEDNESDAY, "last Wednesday"}, | |
263 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_THURSDAY, "last Thursday"}, | |
264 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_FRIDAY, "last Friday"}, | |
265 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_SATURDAY, "last Saturday"}, | |
266 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_SUNDAY, "last Sunday"}, | |
267 | ||
268 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_DAY, "today"}, | |
269 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_WEEK, "this week"}, | |
270 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_MONTH, "this month"}, | |
271 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_YEAR, "this year"}, | |
272 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_MONDAY, "this Monday"}, | |
273 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_TUESDAY, "this Tuesday"}, | |
274 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_WEDNESDAY, "this Wednesday"}, | |
275 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_THURSDAY, "this Thursday"}, | |
276 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_FRIDAY, "this Friday"}, | |
277 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_SATURDAY, "this Saturday"}, | |
278 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_SUNDAY, "this Sunday"}, | |
279 | ||
280 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_DAY, "day"}, | |
281 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_WEEK, "week"}, | |
282 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_MONTH, "month"}, | |
283 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_YEAR, "year"}, | |
284 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_MONDAY, "Monday"}, | |
285 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_TUESDAY, "Tuesday"}, | |
286 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_WEDNESDAY, "Wednesday"}, | |
287 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_THURSDAY, "Thursday"}, | |
288 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_FRIDAY, "Friday"}, | |
289 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_SATURDAY, "Saturday"}, | |
290 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_SUNDAY, "Sunday"}, | |
291 | ||
292 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_NOW, "now"} | |
293 | }; | |
294 | ||
b331163b A |
295 | static WithoutQuantityExpected kEnglishNoQuantityCaps[] = { |
296 | {UDAT_DIRECTION_NEXT_2, UDAT_ABSOLUTE_DAY, ""}, | |
297 | ||
298 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_DAY, "Tomorrow"}, | |
299 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_WEEK, "Next week"}, | |
300 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_MONTH, "Next month"}, | |
301 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_YEAR, "Next year"}, | |
302 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_MONDAY, "Next Monday"}, | |
303 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_TUESDAY, "Next Tuesday"}, | |
304 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_WEDNESDAY, "Next Wednesday"}, | |
305 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_THURSDAY, "Next Thursday"}, | |
306 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_FRIDAY, "Next Friday"}, | |
307 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_SATURDAY, "Next Saturday"}, | |
308 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_SUNDAY, "Next Sunday"}, | |
309 | ||
310 | {UDAT_DIRECTION_LAST_2, UDAT_ABSOLUTE_DAY, ""}, | |
311 | ||
312 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_DAY, "Yesterday"}, | |
313 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_WEEK, "Last week"}, | |
314 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_MONTH, "Last month"}, | |
315 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_YEAR, "Last year"}, | |
316 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_MONDAY, "Last Monday"}, | |
317 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_TUESDAY, "Last Tuesday"}, | |
318 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_WEDNESDAY, "Last Wednesday"}, | |
319 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_THURSDAY, "Last Thursday"}, | |
320 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_FRIDAY, "Last Friday"}, | |
321 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_SATURDAY, "Last Saturday"}, | |
322 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_SUNDAY, "Last Sunday"}, | |
323 | ||
324 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_DAY, "Today"}, | |
325 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_WEEK, "This week"}, | |
326 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_MONTH, "This month"}, | |
327 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_YEAR, "This year"}, | |
328 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_MONDAY, "This Monday"}, | |
329 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_TUESDAY, "This Tuesday"}, | |
330 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_WEDNESDAY, "This Wednesday"}, | |
331 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_THURSDAY, "This Thursday"}, | |
332 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_FRIDAY, "This Friday"}, | |
333 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_SATURDAY, "This Saturday"}, | |
334 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_SUNDAY, "This Sunday"}, | |
335 | ||
336 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_DAY, "Day"}, | |
337 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_WEEK, "Week"}, | |
338 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_MONTH, "Month"}, | |
339 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_YEAR, "Year"}, | |
340 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_MONDAY, "Monday"}, | |
341 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_TUESDAY, "Tuesday"}, | |
342 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_WEDNESDAY, "Wednesday"}, | |
343 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_THURSDAY, "Thursday"}, | |
344 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_FRIDAY, "Friday"}, | |
345 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_SATURDAY, "Saturday"}, | |
346 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_SUNDAY, "Sunday"}, | |
347 | ||
348 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_NOW, "Now"} | |
349 | }; | |
350 | ||
351 | static WithoutQuantityExpected kEnglishNoQuantityShort[] = { | |
352 | {UDAT_DIRECTION_NEXT_2, UDAT_ABSOLUTE_DAY, ""}, | |
353 | ||
354 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_DAY, "tomorrow"}, | |
355 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_WEEK, "next wk."}, | |
356 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_MONTH, "next mo."}, | |
357 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_YEAR, "next yr."}, | |
358 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_MONDAY, "next Mon."}, | |
359 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_TUESDAY, "next Tue."}, | |
360 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_WEDNESDAY, "next Wed."}, | |
361 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_THURSDAY, "next Thu."}, | |
362 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_FRIDAY, "next Fri."}, | |
363 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_SATURDAY, "next Sat."}, | |
364 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_SUNDAY, "next Sun."}, | |
365 | ||
366 | {UDAT_DIRECTION_LAST_2, UDAT_ABSOLUTE_DAY, ""}, | |
367 | ||
368 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_DAY, "yesterday"}, | |
369 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_WEEK, "last wk."}, | |
370 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_MONTH, "last mo."}, | |
371 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_YEAR, "last yr."}, | |
372 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_MONDAY, "last Mon."}, | |
373 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_TUESDAY, "last Tue."}, | |
374 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_WEDNESDAY, "last Wed."}, | |
375 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_THURSDAY, "last Thu."}, | |
376 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_FRIDAY, "last Fri."}, | |
377 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_SATURDAY, "last Sat."}, | |
378 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_SUNDAY, "last Sun."}, | |
379 | ||
380 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_DAY, "today"}, | |
381 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_WEEK, "this wk."}, | |
382 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_MONTH, "this mo."}, | |
383 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_YEAR, "this yr."}, | |
384 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_MONDAY, "this Mon."}, | |
385 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_TUESDAY, "this Tue."}, | |
386 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_WEDNESDAY, "this Wed."}, | |
387 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_THURSDAY, "this Thu."}, | |
388 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_FRIDAY, "this Fri."}, | |
389 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_SATURDAY, "this Sat."}, | |
390 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_SUNDAY, "this Sun."}, | |
391 | ||
392 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_DAY, "day"}, | |
393 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_WEEK, "wk."}, | |
394 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_MONTH, "mo."}, | |
395 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_YEAR, "yr."}, | |
396 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_MONDAY, "Mo"}, | |
397 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_TUESDAY, "Tu"}, | |
398 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_WEDNESDAY, "We"}, | |
399 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_THURSDAY, "Th"}, | |
400 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_FRIDAY, "Fr"}, | |
401 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_SATURDAY, "Sa"}, | |
402 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_SUNDAY, "Su"}, | |
403 | ||
404 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_NOW, "now"} | |
405 | }; | |
406 | ||
407 | static WithoutQuantityExpected kEnglishNoQuantityNarrow[] = { | |
408 | {UDAT_DIRECTION_NEXT_2, UDAT_ABSOLUTE_DAY, ""}, | |
409 | ||
410 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_DAY, "tomorrow"}, | |
411 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_WEEK, "next wk."}, | |
412 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_MONTH, "next mo."}, | |
413 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_YEAR, "next yr."}, | |
414 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_MONDAY, "next M"}, | |
415 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_TUESDAY, "next Tu"}, | |
416 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_WEDNESDAY, "next W"}, | |
417 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_THURSDAY, "next Th"}, | |
418 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_FRIDAY, "next F"}, | |
419 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_SATURDAY, "next Sa"}, | |
420 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_SUNDAY, "next Su"}, | |
421 | ||
422 | {UDAT_DIRECTION_LAST_2, UDAT_ABSOLUTE_DAY, ""}, | |
423 | ||
424 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_DAY, "yesterday"}, | |
425 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_WEEK, "last wk."}, | |
426 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_MONTH, "last mo."}, | |
427 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_YEAR, "last yr."}, | |
428 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_MONDAY, "last M"}, | |
429 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_TUESDAY, "last Tu"}, | |
430 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_WEDNESDAY, "last W"}, | |
431 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_THURSDAY, "last Th"}, | |
432 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_FRIDAY, "last F"}, | |
433 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_SATURDAY, "last Sa"}, | |
434 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_SUNDAY, "last Su"}, | |
435 | ||
436 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_DAY, "today"}, | |
437 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_WEEK, "this wk."}, | |
438 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_MONTH, "this mo."}, | |
439 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_YEAR, "this yr."}, | |
440 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_MONDAY, "this M"}, | |
441 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_TUESDAY, "this Tu"}, | |
442 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_WEDNESDAY, "this W"}, | |
443 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_THURSDAY, "this Th"}, | |
444 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_FRIDAY, "this F"}, | |
445 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_SATURDAY, "this Sa"}, | |
446 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_SUNDAY, "this Su"}, | |
447 | ||
448 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_DAY, "day"}, | |
449 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_WEEK, "wk."}, | |
450 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_MONTH, "mo."}, | |
451 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_YEAR, "yr."}, | |
452 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_MONDAY, "M"}, | |
453 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_TUESDAY, "T"}, | |
454 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_WEDNESDAY, "W"}, | |
455 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_THURSDAY, "T"}, | |
456 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_FRIDAY, "F"}, | |
457 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_SATURDAY, "S"}, | |
458 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_SUNDAY, "S"}, | |
459 | ||
460 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_NOW, "now"} | |
461 | }; | |
462 | ||
57a6839d A |
463 | static WithoutQuantityExpected kSpanishNoQuantity[] = { |
464 | {UDAT_DIRECTION_NEXT_2, UDAT_ABSOLUTE_DAY, "pasado ma\\u00F1ana"}, | |
b331163b | 465 | {UDAT_DIRECTION_LAST_2, UDAT_ABSOLUTE_DAY, "anteayer"} |
57a6839d A |
466 | }; |
467 | ||
468 | class RelativeDateTimeFormatterTest : public IntlTest { | |
469 | public: | |
470 | RelativeDateTimeFormatterTest() { | |
471 | } | |
472 | ||
473 | void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par=0); | |
474 | private: | |
475 | void TestEnglish(); | |
b331163b A |
476 | void TestEnglishCaps(); |
477 | void TestEnglishShort(); | |
478 | void TestEnglishNarrow(); | |
57a6839d | 479 | void TestSerbian(); |
b331163b | 480 | void TestSerbianFallback(); |
57a6839d | 481 | void TestEnglishNoQuantity(); |
b331163b A |
482 | void TestEnglishNoQuantityCaps(); |
483 | void TestEnglishNoQuantityShort(); | |
484 | void TestEnglishNoQuantityNarrow(); | |
57a6839d A |
485 | void TestSpanishNoQuantity(); |
486 | void TestFormatWithQuantityIllegalArgument(); | |
487 | void TestFormatWithoutQuantityIllegalArgument(); | |
488 | void TestCustomNumberFormat(); | |
b331163b | 489 | void TestGetters(); |
57a6839d | 490 | void TestCombineDateAndTime(); |
b331163b A |
491 | void TestBadDisplayContext(); |
492 | void RunTest( | |
493 | const Locale& locale, | |
494 | const WithQuantityExpected* expectedResults, | |
495 | int32_t expectedResultLength); | |
57a6839d A |
496 | void RunTest( |
497 | const Locale& locale, | |
b331163b | 498 | UDateRelativeDateTimeFormatterStyle style, |
57a6839d A |
499 | const WithQuantityExpected* expectedResults, |
500 | int32_t expectedResultLength); | |
501 | void RunTest( | |
502 | const Locale& locale, | |
503 | const WithoutQuantityExpected* expectedResults, | |
504 | int32_t expectedResultLength); | |
b331163b A |
505 | void RunTest( |
506 | const Locale& locale, | |
507 | UDateRelativeDateTimeFormatterStyle style, | |
508 | const WithoutQuantityExpected* expectedResults, | |
509 | int32_t expectedResultLength); | |
57a6839d A |
510 | void RunTest( |
511 | const RelativeDateTimeFormatter& fmt, | |
512 | const WithQuantityExpected* expectedResults, | |
513 | int32_t expectedResultLength, | |
514 | const char *description); | |
515 | void RunTest( | |
516 | const RelativeDateTimeFormatter& fmt, | |
517 | const WithoutQuantityExpected* expectedResults, | |
518 | int32_t expectedResultLength, | |
519 | const char *description); | |
520 | void CheckExpectedResult( | |
521 | const RelativeDateTimeFormatter& fmt, | |
522 | const WithQuantityExpected& expectedResult, | |
523 | const char* description); | |
524 | void CheckExpectedResult( | |
525 | const RelativeDateTimeFormatter& fmt, | |
526 | const WithoutQuantityExpected& expectedResult, | |
527 | const char* description); | |
528 | void VerifyIllegalArgument( | |
529 | const RelativeDateTimeFormatter& fmt, | |
530 | UDateDirection direction, | |
531 | UDateRelativeUnit unit); | |
532 | void VerifyIllegalArgument( | |
533 | const RelativeDateTimeFormatter& fmt, | |
534 | UDateDirection direction, | |
535 | UDateAbsoluteUnit unit); | |
536 | }; | |
537 | ||
538 | void RelativeDateTimeFormatterTest::runIndexedTest( | |
539 | int32_t index, UBool exec, const char *&name, char *) { | |
540 | if (exec) { | |
541 | logln("TestSuite RelativeDateTimeFormatterTest: "); | |
542 | } | |
543 | TESTCASE_AUTO_BEGIN; | |
544 | TESTCASE_AUTO(TestEnglish); | |
b331163b A |
545 | TESTCASE_AUTO(TestEnglishCaps); |
546 | TESTCASE_AUTO(TestEnglishShort); | |
547 | TESTCASE_AUTO(TestEnglishNarrow); | |
57a6839d | 548 | TESTCASE_AUTO(TestSerbian); |
b331163b | 549 | TESTCASE_AUTO(TestSerbianFallback); |
57a6839d | 550 | TESTCASE_AUTO(TestEnglishNoQuantity); |
b331163b A |
551 | TESTCASE_AUTO(TestEnglishNoQuantityCaps); |
552 | TESTCASE_AUTO(TestEnglishNoQuantityShort); | |
553 | TESTCASE_AUTO(TestEnglishNoQuantityNarrow); | |
57a6839d A |
554 | TESTCASE_AUTO(TestSpanishNoQuantity); |
555 | TESTCASE_AUTO(TestFormatWithQuantityIllegalArgument); | |
556 | TESTCASE_AUTO(TestFormatWithoutQuantityIllegalArgument); | |
557 | TESTCASE_AUTO(TestCustomNumberFormat); | |
b331163b | 558 | TESTCASE_AUTO(TestGetters); |
57a6839d | 559 | TESTCASE_AUTO(TestCombineDateAndTime); |
b331163b | 560 | TESTCASE_AUTO(TestBadDisplayContext); |
57a6839d A |
561 | TESTCASE_AUTO_END; |
562 | } | |
563 | ||
564 | void RelativeDateTimeFormatterTest::TestEnglish() { | |
b331163b A |
565 | RunTest("en", kEnglish, UPRV_LENGTHOF(kEnglish)); |
566 | } | |
567 | ||
568 | void RelativeDateTimeFormatterTest::TestEnglishCaps() { | |
569 | UErrorCode status = U_ZERO_ERROR; | |
570 | RelativeDateTimeFormatter fmt( | |
571 | "en", | |
572 | NULL, | |
573 | UDAT_STYLE_LONG, | |
574 | UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, | |
575 | status); | |
576 | if (U_FAILURE(status)) { | |
577 | dataerrln("Failed call to RelativeDateTimeFormatter(\"en\", NULL, UDAT_STYLE_LONG, UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, status); : %s", u_errorName(status)); | |
578 | return; | |
579 | } | |
580 | RelativeDateTimeFormatter fmt3(status); | |
581 | ||
582 | // Test assignment and copy constructor with capitalization on. | |
583 | RelativeDateTimeFormatter fmt2(fmt); | |
584 | fmt3 = fmt2; | |
585 | assertSuccess("", status); | |
586 | RunTest(fmt3, kEnglishCaps, UPRV_LENGTHOF(kEnglishCaps), "en caps"); | |
587 | } | |
588 | ||
589 | void RelativeDateTimeFormatterTest::TestEnglishShort() { | |
590 | RunTest("en", UDAT_STYLE_SHORT, kEnglishShort, UPRV_LENGTHOF(kEnglishShort)); | |
591 | } | |
592 | ||
593 | void RelativeDateTimeFormatterTest::TestEnglishNarrow() { | |
594 | RunTest("en", UDAT_STYLE_NARROW, kEnglishShort, UPRV_LENGTHOF(kEnglishShort)); | |
57a6839d A |
595 | } |
596 | ||
597 | void RelativeDateTimeFormatterTest::TestSerbian() { | |
b331163b A |
598 | RunTest("sr", kSerbian, UPRV_LENGTHOF(kSerbian)); |
599 | } | |
600 | ||
601 | void RelativeDateTimeFormatterTest::TestSerbianFallback() { | |
602 | RunTest("sr", UDAT_STYLE_NARROW, kSerbianNarrow, UPRV_LENGTHOF(kSerbianNarrow)); | |
57a6839d A |
603 | } |
604 | ||
605 | void RelativeDateTimeFormatterTest::TestEnglishNoQuantity() { | |
b331163b A |
606 | RunTest("en", kEnglishNoQuantity, UPRV_LENGTHOF(kEnglishNoQuantity)); |
607 | } | |
608 | ||
609 | void RelativeDateTimeFormatterTest::TestEnglishNoQuantityCaps() { | |
610 | UErrorCode status = U_ZERO_ERROR; | |
611 | RelativeDateTimeFormatter fmt( | |
612 | "en", | |
613 | NULL, | |
614 | UDAT_STYLE_LONG, | |
615 | UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, | |
616 | status); | |
617 | if (assertSuccess("RelativeDateTimeFormatter", status, TRUE) == FALSE) { | |
618 | return; | |
619 | } | |
620 | RunTest( | |
621 | fmt, | |
622 | kEnglishNoQuantityCaps, | |
623 | UPRV_LENGTHOF(kEnglishNoQuantityCaps), | |
624 | "en caps no quantity"); | |
625 | } | |
626 | ||
627 | void RelativeDateTimeFormatterTest::TestEnglishNoQuantityShort() { | |
628 | RunTest( | |
629 | "en", | |
630 | UDAT_STYLE_SHORT, | |
631 | kEnglishNoQuantityShort, | |
632 | UPRV_LENGTHOF(kEnglishNoQuantityShort)); | |
633 | } | |
634 | ||
635 | void RelativeDateTimeFormatterTest::TestEnglishNoQuantityNarrow() { | |
636 | RunTest( | |
637 | "en", | |
638 | UDAT_STYLE_NARROW, | |
639 | kEnglishNoQuantityNarrow, | |
640 | UPRV_LENGTHOF(kEnglishNoQuantityNarrow)); | |
57a6839d A |
641 | } |
642 | ||
643 | void RelativeDateTimeFormatterTest::TestSpanishNoQuantity() { | |
b331163b | 644 | RunTest("es", kSpanishNoQuantity, UPRV_LENGTHOF(kSpanishNoQuantity)); |
57a6839d A |
645 | } |
646 | ||
647 | void RelativeDateTimeFormatterTest::TestFormatWithQuantityIllegalArgument() { | |
648 | UErrorCode status = U_ZERO_ERROR; | |
649 | RelativeDateTimeFormatter fmt("en", status); | |
650 | if (U_FAILURE(status)) { | |
651 | dataerrln("Failure creating format object - %s", u_errorName(status)); | |
652 | return; | |
653 | } | |
654 | VerifyIllegalArgument(fmt, UDAT_DIRECTION_PLAIN, UDAT_RELATIVE_DAYS); | |
655 | VerifyIllegalArgument(fmt, UDAT_DIRECTION_THIS, UDAT_RELATIVE_DAYS); | |
656 | } | |
657 | ||
658 | void RelativeDateTimeFormatterTest::TestFormatWithoutQuantityIllegalArgument() { | |
659 | UErrorCode status = U_ZERO_ERROR; | |
660 | RelativeDateTimeFormatter fmt("en", status); | |
661 | if (U_FAILURE(status)) { | |
662 | dataerrln("Failure creating format object - %s", u_errorName(status)); | |
663 | return; | |
664 | } | |
665 | VerifyIllegalArgument(fmt, UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_NOW); | |
666 | VerifyIllegalArgument(fmt, UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_NOW); | |
667 | VerifyIllegalArgument(fmt, UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_NOW); | |
668 | } | |
669 | ||
670 | void RelativeDateTimeFormatterTest::TestCustomNumberFormat() { | |
671 | NumberFormat *nf; | |
672 | UErrorCode status = U_ZERO_ERROR; | |
673 | { | |
674 | RelativeDateTimeFormatter fmt("en", status); | |
675 | if (U_FAILURE(status)) { | |
676 | dataerrln( | |
677 | "Failure creating format object - %s", u_errorName(status)); | |
678 | return; | |
679 | } | |
680 | nf = (NumberFormat *) fmt.getNumberFormat().clone(); | |
681 | } | |
682 | nf->setMinimumFractionDigits(1); | |
683 | nf->setMaximumFractionDigits(1); | |
684 | RelativeDateTimeFormatter fmt("en", nf, status); | |
685 | ||
686 | // Test copy constructor. | |
687 | RelativeDateTimeFormatter fmt2(fmt); | |
b331163b | 688 | RunTest(fmt2, kEnglishDecimal, UPRV_LENGTHOF(kEnglishDecimal), "en decimal digits"); |
57a6839d A |
689 | |
690 | // Test assignment | |
691 | fmt = RelativeDateTimeFormatter("es", status); | |
b331163b A |
692 | RunTest(fmt, kSpanishNoQuantity, UPRV_LENGTHOF(kSpanishNoQuantity), "assignment operator"); |
693 | ||
694 | } | |
695 | ||
696 | void RelativeDateTimeFormatterTest::TestGetters() { | |
697 | UErrorCode status = U_ZERO_ERROR; | |
698 | RelativeDateTimeFormatter fmt( | |
699 | "en", | |
700 | NULL, | |
701 | UDAT_STYLE_NARROW, | |
702 | UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, | |
703 | status); | |
704 | if (U_FAILURE(status)) { | |
705 | dataerrln("Failed call to RelativeDateTimeFormatter(\"en\", NULL, UDAT_STYLE_NARROW, UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, status);) : %s", u_errorName(status)); | |
706 | return; | |
707 | } | |
708 | RelativeDateTimeFormatter fmt3(status); | |
57a6839d | 709 | |
b331163b A |
710 | // copy and assignment. |
711 | RelativeDateTimeFormatter fmt2(fmt); | |
712 | fmt3 = fmt2; | |
713 | assertEquals("style", UDAT_STYLE_NARROW, fmt3.getFormatStyle()); | |
714 | assertEquals( | |
715 | "context", | |
716 | UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, | |
717 | fmt3.getCapitalizationContext()); | |
718 | assertSuccess("", status); | |
57a6839d A |
719 | } |
720 | ||
721 | void RelativeDateTimeFormatterTest::TestCombineDateAndTime() { | |
722 | UErrorCode status = U_ZERO_ERROR; | |
723 | RelativeDateTimeFormatter fmt("en", status); | |
724 | if (U_FAILURE(status)) { | |
725 | dataerrln("Failure creating format object - %s", u_errorName(status)); | |
726 | return; | |
727 | } | |
728 | UnicodeString actual; | |
729 | fmt.combineDateAndTime( | |
730 | UnicodeString("yesterday"), | |
731 | UnicodeString("3:50"), | |
732 | actual, | |
733 | status); | |
734 | UnicodeString expected("yesterday, 3:50"); | |
735 | if (expected != actual) { | |
736 | errln("Expected "+expected+", got "+actual); | |
737 | } | |
738 | } | |
739 | ||
b331163b A |
740 | void RelativeDateTimeFormatterTest::TestBadDisplayContext() { |
741 | UErrorCode status = U_ZERO_ERROR; | |
742 | RelativeDateTimeFormatter fmt( | |
743 | "en", NULL, UDAT_STYLE_LONG, UDISPCTX_STANDARD_NAMES, status); | |
744 | if (status != U_ILLEGAL_ARGUMENT_ERROR) { | |
745 | errln("Expected U_ILLEGAL_ARGUMENT_ERROR, got %s", u_errorName(status)); | |
746 | } | |
747 | } | |
748 | ||
749 | ||
57a6839d A |
750 | |
751 | void RelativeDateTimeFormatterTest::RunTest( | |
752 | const Locale& locale, | |
753 | const WithQuantityExpected* expectedResults, | |
754 | int32_t expectedResultLength) { | |
755 | UErrorCode status = U_ZERO_ERROR; | |
756 | RelativeDateTimeFormatter fmt(locale, status); | |
757 | if (U_FAILURE(status)) { | |
758 | dataerrln("Unable to create format object - %s", u_errorName(status)); | |
759 | return; | |
b331163b A |
760 | } |
761 | RunTest(fmt, expectedResults, expectedResultLength, locale.getName()); | |
762 | } | |
763 | ||
764 | void RelativeDateTimeFormatterTest::RunTest( | |
765 | const Locale& locale, | |
766 | UDateRelativeDateTimeFormatterStyle style, | |
767 | const WithQuantityExpected* expectedResults, | |
768 | int32_t expectedResultLength) { | |
769 | UErrorCode status = U_ZERO_ERROR; | |
770 | RelativeDateTimeFormatter fmt( | |
771 | locale, NULL, style, UDISPCTX_CAPITALIZATION_NONE, status); | |
772 | if (U_FAILURE(status)) { | |
773 | dataerrln("Unable to create format object - %s", u_errorName(status)); | |
774 | return; | |
775 | } | |
57a6839d A |
776 | RunTest(fmt, expectedResults, expectedResultLength, locale.getName()); |
777 | } | |
778 | ||
779 | void RelativeDateTimeFormatterTest::RunTest( | |
780 | const Locale& locale, | |
781 | const WithoutQuantityExpected* expectedResults, | |
782 | int32_t expectedResultLength) { | |
783 | UErrorCode status = U_ZERO_ERROR; | |
784 | RelativeDateTimeFormatter fmt(locale, status); | |
785 | if (U_FAILURE(status)) { | |
786 | dataerrln("Unable to create format object - %s", u_errorName(status)); | |
787 | return; | |
788 | } | |
789 | RunTest(fmt, expectedResults, expectedResultLength, locale.getName()); | |
790 | } | |
791 | ||
b331163b A |
792 | void RelativeDateTimeFormatterTest::RunTest( |
793 | const Locale& locale, | |
794 | UDateRelativeDateTimeFormatterStyle style, | |
795 | const WithoutQuantityExpected* expectedResults, | |
796 | int32_t expectedResultLength) { | |
797 | UErrorCode status = U_ZERO_ERROR; | |
798 | RelativeDateTimeFormatter fmt( | |
799 | locale, NULL, style, UDISPCTX_CAPITALIZATION_NONE, status); | |
800 | if (U_FAILURE(status)) { | |
801 | dataerrln("Unable to create format object - %s", u_errorName(status)); | |
802 | return; | |
803 | } | |
804 | RunTest(fmt, expectedResults, expectedResultLength, locale.getName()); | |
805 | } | |
806 | ||
57a6839d A |
807 | void RelativeDateTimeFormatterTest::RunTest( |
808 | const RelativeDateTimeFormatter& fmt, | |
809 | const WithQuantityExpected* expectedResults, | |
810 | int32_t expectedResultLength, | |
811 | const char *description) { | |
812 | for (int32_t i = 0; i < expectedResultLength; ++i) { | |
813 | CheckExpectedResult(fmt, expectedResults[i], description); | |
814 | } | |
815 | } | |
816 | ||
817 | void RelativeDateTimeFormatterTest::RunTest( | |
818 | const RelativeDateTimeFormatter& fmt, | |
819 | const WithoutQuantityExpected* expectedResults, | |
820 | int32_t expectedResultLength, | |
821 | const char *description) { | |
822 | for (int32_t i = 0; i < expectedResultLength; ++i) { | |
823 | CheckExpectedResult(fmt, expectedResults[i], description); | |
824 | } | |
825 | } | |
826 | ||
827 | void RelativeDateTimeFormatterTest::CheckExpectedResult( | |
828 | const RelativeDateTimeFormatter& fmt, | |
829 | const WithQuantityExpected& expectedResult, | |
830 | const char* description) { | |
831 | UErrorCode status = U_ZERO_ERROR; | |
832 | UnicodeString actual; | |
833 | fmt.format(expectedResult.value, expectedResult.direction, expectedResult.unit, actual, status); | |
834 | UnicodeString expected(expectedResult.expected, -1, US_INV); | |
835 | expected = expected.unescape(); | |
836 | char buffer[256]; | |
837 | sprintf( | |
838 | buffer, | |
839 | "%s, %f, %s, %s", | |
840 | description, | |
841 | expectedResult.value, | |
842 | DirectionStr(expectedResult.direction), | |
843 | RelativeUnitStr(expectedResult.unit)); | |
844 | if (actual != expected) { | |
845 | errln(UnicodeString("Fail: Expected: ") + expected | |
846 | + ", Got: " + actual | |
847 | + ", For: " + buffer); | |
848 | } | |
849 | } | |
850 | ||
851 | void RelativeDateTimeFormatterTest::CheckExpectedResult( | |
852 | const RelativeDateTimeFormatter& fmt, | |
853 | const WithoutQuantityExpected& expectedResult, | |
854 | const char* description) { | |
855 | UErrorCode status = U_ZERO_ERROR; | |
856 | UnicodeString actual; | |
857 | fmt.format(expectedResult.direction, expectedResult.unit, actual, status); | |
858 | UnicodeString expected(expectedResult.expected, -1, US_INV); | |
859 | expected = expected.unescape(); | |
860 | char buffer[256]; | |
861 | sprintf( | |
862 | buffer, | |
863 | "%s, %s, %s", | |
864 | description, | |
865 | DirectionStr(expectedResult.direction), | |
866 | AbsoluteUnitStr(expectedResult.unit)); | |
867 | if (actual != expected) { | |
868 | errln(UnicodeString("Fail: Expected: ") + expected | |
869 | + ", Got: " + actual | |
870 | + ", For: " + buffer); | |
871 | } | |
872 | } | |
873 | ||
874 | void RelativeDateTimeFormatterTest::VerifyIllegalArgument( | |
875 | const RelativeDateTimeFormatter& fmt, | |
876 | UDateDirection direction, | |
877 | UDateRelativeUnit unit) { | |
878 | UnicodeString appendTo; | |
879 | UErrorCode status = U_ZERO_ERROR; | |
880 | fmt.format(1.0, direction, unit, appendTo, status); | |
881 | if (status != U_ILLEGAL_ARGUMENT_ERROR) { | |
882 | errln("Expected U_ILLEGAL_ARGUMENT_ERROR, got %s", u_errorName(status)); | |
883 | } | |
884 | } | |
885 | ||
886 | void RelativeDateTimeFormatterTest::VerifyIllegalArgument( | |
887 | const RelativeDateTimeFormatter& fmt, | |
888 | UDateDirection direction, | |
889 | UDateAbsoluteUnit unit) { | |
890 | UnicodeString appendTo; | |
891 | UErrorCode status = U_ZERO_ERROR; | |
892 | fmt.format(direction, unit, appendTo, status); | |
893 | if (status != U_ILLEGAL_ARGUMENT_ERROR) { | |
894 | errln("Expected U_ILLEGAL_ARGUMENT_ERROR, got %s", u_errorName(status)); | |
895 | } | |
896 | } | |
897 | ||
898 | static const char *kLast2 = "Last_2"; | |
899 | static const char *kLast = "Last"; | |
900 | static const char *kThis = "This"; | |
901 | static const char *kNext = "Next"; | |
902 | static const char *kNext2 = "Next_2"; | |
903 | static const char *kPlain = "Plain"; | |
904 | ||
905 | static const char *kSeconds = "Seconds"; | |
906 | static const char *kMinutes = "Minutes"; | |
907 | static const char *kHours = "Hours"; | |
908 | static const char *kDays = "Days"; | |
909 | static const char *kWeeks = "Weeks"; | |
910 | static const char *kMonths = "Months"; | |
911 | static const char *kYears = "Years"; | |
912 | ||
913 | static const char *kSunday = "Sunday"; | |
914 | static const char *kMonday = "Monday"; | |
915 | static const char *kTuesday = "Tuesday"; | |
916 | static const char *kWednesday = "Wednesday"; | |
917 | static const char *kThursday = "Thursday"; | |
918 | static const char *kFriday = "Friday"; | |
919 | static const char *kSaturday = "Saturday"; | |
920 | static const char *kDay = "Day"; | |
921 | static const char *kWeek = "Week"; | |
922 | static const char *kMonth = "Month"; | |
923 | static const char *kYear = "Year"; | |
924 | static const char *kNow = "Now"; | |
925 | ||
926 | static const char *kUndefined = "Undefined"; | |
927 | ||
928 | static const char *DirectionStr( | |
929 | UDateDirection direction) { | |
930 | switch (direction) { | |
931 | case UDAT_DIRECTION_LAST_2: | |
932 | return kLast2; | |
933 | case UDAT_DIRECTION_LAST: | |
934 | return kLast; | |
935 | case UDAT_DIRECTION_THIS: | |
936 | return kThis; | |
937 | case UDAT_DIRECTION_NEXT: | |
938 | return kNext; | |
939 | case UDAT_DIRECTION_NEXT_2: | |
940 | return kNext2; | |
941 | case UDAT_DIRECTION_PLAIN: | |
942 | return kPlain; | |
943 | default: | |
944 | return kUndefined; | |
945 | } | |
946 | return kUndefined; | |
947 | } | |
948 | ||
949 | static const char *RelativeUnitStr( | |
950 | UDateRelativeUnit unit) { | |
951 | switch (unit) { | |
952 | case UDAT_RELATIVE_SECONDS: | |
953 | return kSeconds; | |
954 | case UDAT_RELATIVE_MINUTES: | |
955 | return kMinutes; | |
956 | case UDAT_RELATIVE_HOURS: | |
957 | return kHours; | |
958 | case UDAT_RELATIVE_DAYS: | |
959 | return kDays; | |
960 | case UDAT_RELATIVE_WEEKS: | |
961 | return kWeeks; | |
962 | case UDAT_RELATIVE_MONTHS: | |
963 | return kMonths; | |
964 | case UDAT_RELATIVE_YEARS: | |
965 | return kYears; | |
966 | default: | |
967 | return kUndefined; | |
968 | } | |
969 | return kUndefined; | |
970 | } | |
971 | ||
972 | static const char *AbsoluteUnitStr( | |
973 | UDateAbsoluteUnit unit) { | |
974 | switch (unit) { | |
975 | case UDAT_ABSOLUTE_SUNDAY: | |
976 | return kSunday; | |
977 | case UDAT_ABSOLUTE_MONDAY: | |
978 | return kMonday; | |
979 | case UDAT_ABSOLUTE_TUESDAY: | |
980 | return kTuesday; | |
981 | case UDAT_ABSOLUTE_WEDNESDAY: | |
982 | return kWednesday; | |
983 | case UDAT_ABSOLUTE_THURSDAY: | |
984 | return kThursday; | |
985 | case UDAT_ABSOLUTE_FRIDAY: | |
986 | return kFriday; | |
987 | case UDAT_ABSOLUTE_SATURDAY: | |
988 | return kSaturday; | |
989 | case UDAT_ABSOLUTE_DAY: | |
990 | return kDay; | |
991 | case UDAT_ABSOLUTE_WEEK: | |
992 | return kWeek; | |
993 | case UDAT_ABSOLUTE_MONTH: | |
994 | return kMonth; | |
995 | case UDAT_ABSOLUTE_YEAR: | |
996 | return kYear; | |
997 | case UDAT_ABSOLUTE_NOW: | |
998 | return kNow; | |
999 | default: | |
1000 | return kUndefined; | |
1001 | } | |
1002 | return kUndefined; | |
1003 | } | |
1004 | ||
1005 | extern IntlTest *createRelativeDateTimeFormatterTest() { | |
1006 | return new RelativeDateTimeFormatterTest(); | |
1007 | } | |
1008 | ||
1009 | #endif |