]>
Commit | Line | Data |
---|---|---|
f3c0d7a5 A |
1 | // © 2016 and later: Unicode, Inc. and others. |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
57a6839d A |
3 | /* |
4 | ******************************************************************************* | |
2ca993e8 A |
5 | * Copyright (C) 2013-2016, International Business Machines Corporation and |
6 | * others. All Rights Reserved. | |
57a6839d A |
7 | ******************************************************************************* |
8 | * | |
9 | * File RELDATEFMTTEST.CPP | |
10 | * | |
11 | ******************************************************************************* | |
12 | */ | |
3d1f044b | 13 | #include <memory> |
57a6839d A |
14 | #include <stdio.h> |
15 | #include <stdlib.h> | |
3d1f044b | 16 | #include <vector> |
57a6839d A |
17 | |
18 | #include "intltest.h" | |
19 | ||
b331163b | 20 | #if !UCONFIG_NO_FORMATTING && !UCONFIG_NO_BREAK_ITERATION |
57a6839d A |
21 | |
22 | #include "unicode/localpointer.h" | |
23 | #include "unicode/numfmt.h" | |
24 | #include "unicode/reldatefmt.h" | |
3d1f044b | 25 | #include "unicode/rbnf.h" |
b331163b | 26 | #include "cmemory.h" |
3d1f044b | 27 | #include "itformat.h" |
57a6839d A |
28 | |
29 | static const char *DirectionStr(UDateDirection direction); | |
30 | static const char *RelativeUnitStr(UDateRelativeUnit unit); | |
3d1f044b | 31 | static const char *RelativeDateTimeUnitStr(URelativeDateTimeUnit unit); |
57a6839d A |
32 | static const char *AbsoluteUnitStr(UDateAbsoluteUnit unit); |
33 | ||
34 | typedef struct WithQuantityExpected { | |
35 | double value; | |
36 | UDateDirection direction; | |
37 | UDateRelativeUnit unit; | |
38 | const char *expected; | |
39 | } WithQuantityExpected; | |
40 | ||
41 | typedef struct WithoutQuantityExpected { | |
42 | UDateDirection direction; | |
43 | UDateAbsoluteUnit unit; | |
44 | const char *expected; | |
45 | } WithoutQuantityExpected; | |
46 | ||
47 | static WithQuantityExpected kEnglish[] = { | |
48 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "in 0 seconds"}, | |
49 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "in 0.5 seconds"}, | |
50 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "in 1 second"}, | |
51 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "in 2 seconds"}, | |
52 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MINUTES, "in 0 minutes"}, | |
53 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MINUTES, "in 0.5 minutes"}, | |
54 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MINUTES, "in 1 minute"}, | |
55 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MINUTES, "in 2 minutes"}, | |
56 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_HOURS, "in 0 hours"}, | |
57 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_HOURS, "in 0.5 hours"}, | |
58 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_HOURS, "in 1 hour"}, | |
59 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_HOURS, "in 2 hours"}, | |
60 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, "in 0 days"}, | |
61 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, "in 0.5 days"}, | |
62 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, "in 1 day"}, | |
63 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, "in 2 days"}, | |
64 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_WEEKS, "in 0 weeks"}, | |
65 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_WEEKS, "in 0.5 weeks"}, | |
66 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_WEEKS, "in 1 week"}, | |
67 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_WEEKS, "in 2 weeks"}, | |
68 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "in 0 months"}, | |
69 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "in 0.5 months"}, | |
70 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "in 1 month"}, | |
71 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "in 2 months"}, | |
72 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_YEARS, "in 0 years"}, | |
73 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_YEARS, "in 0.5 years"}, | |
74 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_YEARS, "in 1 year"}, | |
75 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_YEARS, "in 2 years"}, | |
76 | ||
77 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_SECONDS, "0 seconds ago"}, | |
78 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_SECONDS, "0.5 seconds ago"}, | |
79 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_SECONDS, "1 second ago"}, | |
80 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_SECONDS, "2 seconds ago"}, | |
81 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES, "0 minutes ago"}, | |
82 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES, "0.5 minutes ago"}, | |
83 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES, "1 minute ago"}, | |
84 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES, "2 minutes ago"}, | |
85 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, "0 hours ago"}, | |
86 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, "0.5 hours ago"}, | |
87 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, "1 hour ago"}, | |
88 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, "2 hours ago"}, | |
89 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, "0 days ago"}, | |
90 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, "0.5 days ago"}, | |
91 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, "1 day ago"}, | |
92 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, "2 days ago"}, | |
93 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_WEEKS, "0 weeks ago"}, | |
94 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_WEEKS, "0.5 weeks ago"}, | |
95 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_WEEKS, "1 week ago"}, | |
96 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_WEEKS, "2 weeks ago"}, | |
97 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "0 months ago"}, | |
98 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "0.5 months ago"}, | |
99 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "1 month ago"}, | |
100 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "2 months ago"}, | |
101 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, "0 years ago"}, | |
102 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, "0.5 years ago"}, | |
103 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, "1 year ago"}, | |
104 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, "2 years ago"} | |
105 | }; | |
106 | ||
b331163b A |
107 | static WithQuantityExpected kEnglishCaps[] = { |
108 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "In 0 seconds"}, | |
109 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "In 0.5 seconds"}, | |
110 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "In 1 second"}, | |
111 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "In 2 seconds"}, | |
112 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MINUTES, "In 0 minutes"}, | |
113 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MINUTES, "In 0.5 minutes"}, | |
114 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MINUTES, "In 1 minute"}, | |
115 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MINUTES, "In 2 minutes"}, | |
116 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_HOURS, "In 0 hours"}, | |
117 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_HOURS, "In 0.5 hours"}, | |
118 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_HOURS, "In 1 hour"}, | |
119 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_HOURS, "In 2 hours"}, | |
120 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, "In 0 days"}, | |
121 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, "In 0.5 days"}, | |
122 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, "In 1 day"}, | |
123 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, "In 2 days"}, | |
124 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_WEEKS, "In 0 weeks"}, | |
125 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_WEEKS, "In 0.5 weeks"}, | |
126 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_WEEKS, "In 1 week"}, | |
127 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_WEEKS, "In 2 weeks"}, | |
128 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "In 0 months"}, | |
129 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "In 0.5 months"}, | |
130 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "In 1 month"}, | |
131 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "In 2 months"}, | |
132 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_YEARS, "In 0 years"}, | |
133 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_YEARS, "In 0.5 years"}, | |
134 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_YEARS, "In 1 year"}, | |
135 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_YEARS, "In 2 years"}, | |
136 | ||
137 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_SECONDS, "0 seconds ago"}, | |
138 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_SECONDS, "0.5 seconds ago"}, | |
139 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_SECONDS, "1 second ago"}, | |
140 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_SECONDS, "2 seconds ago"}, | |
141 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES, "0 minutes ago"}, | |
142 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES, "0.5 minutes ago"}, | |
143 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES, "1 minute ago"}, | |
144 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES, "2 minutes ago"}, | |
145 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, "0 hours ago"}, | |
146 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, "0.5 hours ago"}, | |
147 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, "1 hour ago"}, | |
148 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, "2 hours ago"}, | |
149 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, "0 days ago"}, | |
150 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, "0.5 days ago"}, | |
151 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, "1 day ago"}, | |
152 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, "2 days ago"}, | |
153 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_WEEKS, "0 weeks ago"}, | |
154 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_WEEKS, "0.5 weeks ago"}, | |
155 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_WEEKS, "1 week ago"}, | |
156 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_WEEKS, "2 weeks ago"}, | |
157 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "0 months ago"}, | |
158 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "0.5 months ago"}, | |
159 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "1 month ago"}, | |
160 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "2 months ago"}, | |
161 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, "0 years ago"}, | |
162 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, "0.5 years ago"}, | |
163 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, "1 year ago"}, | |
164 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, "2 years ago"} | |
165 | }; | |
166 | ||
167 | static WithQuantityExpected kEnglishShort[] = { | |
168 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "in 0 sec."}, | |
169 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "in 0.5 sec."}, | |
170 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "in 1 sec."}, | |
171 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "in 2 sec."}, | |
172 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MINUTES, "in 0 min."}, | |
173 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MINUTES, "in 0.5 min."}, | |
174 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MINUTES, "in 1 min."}, | |
175 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MINUTES, "in 2 min."}, | |
176 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_HOURS, "in 0 hr."}, | |
177 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_HOURS, "in 0.5 hr."}, | |
178 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_HOURS, "in 1 hr."}, | |
179 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_HOURS, "in 2 hr."}, | |
180 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, "in 0 days"}, | |
181 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, "in 0.5 days"}, | |
182 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, "in 1 day"}, | |
183 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_DAYS, "in 2 days"}, | |
184 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_WEEKS, "in 0 wk."}, | |
185 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_WEEKS, "in 0.5 wk."}, | |
186 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_WEEKS, "in 1 wk."}, | |
187 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_WEEKS, "in 2 wk."}, | |
188 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "in 0 mo."}, | |
189 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "in 0.5 mo."}, | |
190 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "in 1 mo."}, | |
191 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "in 2 mo."}, | |
192 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_YEARS, "in 0 yr."}, | |
193 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_YEARS, "in 0.5 yr."}, | |
194 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_YEARS, "in 1 yr."}, | |
195 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_YEARS, "in 2 yr."}, | |
196 | ||
197 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_SECONDS, "0 sec. ago"}, | |
198 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_SECONDS, "0.5 sec. ago"}, | |
199 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_SECONDS, "1 sec. ago"}, | |
200 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_SECONDS, "2 sec. ago"}, | |
201 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES, "0 min. ago"}, | |
202 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES, "0.5 min. ago"}, | |
203 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES, "1 min. ago"}, | |
204 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MINUTES, "2 min. ago"}, | |
205 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, "0 hr. ago"}, | |
206 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, "0.5 hr. ago"}, | |
207 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, "1 hr. ago"}, | |
208 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, "2 hr. ago"}, | |
209 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, "0 days ago"}, | |
210 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, "0.5 days ago"}, | |
211 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, "1 day ago"}, | |
212 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, "2 days ago"}, | |
213 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_WEEKS, "0 wk. ago"}, | |
214 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_WEEKS, "0.5 wk. ago"}, | |
215 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_WEEKS, "1 wk. ago"}, | |
216 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_WEEKS, "2 wk. ago"}, | |
217 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "0 mo. ago"}, | |
218 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "0.5 mo. ago"}, | |
219 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "1 mo. ago"}, | |
220 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "2 mo. ago"}, | |
221 | {0.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, "0 yr. ago"}, | |
222 | {0.5, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, "0.5 yr. ago"}, | |
223 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, "1 yr. ago"}, | |
224 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_YEARS, "2 yr. ago"} | |
225 | }; | |
226 | ||
57a6839d A |
227 | static WithQuantityExpected kEnglishDecimal[] = { |
228 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "in 0.0 seconds"}, | |
229 | {0.5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "in 0.5 seconds"}, | |
230 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "in 1.0 seconds"}, | |
231 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, "in 2.0 seconds"} | |
232 | }; | |
233 | ||
234 | static WithQuantityExpected kSerbian[] = { | |
235 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "\\u0437\\u0430 0 \\u043c\\u0435\\u0441\\u0435\\u0446\\u0438"}, | |
236 | {1.2, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "\\u0437\\u0430 1,2 \\u043c\\u0435\\u0441\\u0435\\u0446\\u0430"}, | |
237 | {21.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "\\u0437\\u0430 21 \\u043c\\u0435\\u0441\\u0435\\u0446"} | |
238 | }; | |
239 | ||
b331163b | 240 | static WithQuantityExpected kSerbianNarrow[] = { |
2ca993e8 A |
241 | {0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "\\u0437\\u0430 0 \\u043c."}, |
242 | {1.2, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "\\u0437\\u0430 1,2 \\u043c."}, | |
243 | {21.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "\\u0437\\u0430 21 \\u043c."} | |
b331163b A |
244 | }; |
245 | ||
57a6839d A |
246 | static WithoutQuantityExpected kEnglishNoQuantity[] = { |
247 | {UDAT_DIRECTION_NEXT_2, UDAT_ABSOLUTE_DAY, ""}, | |
248 | ||
249 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_DAY, "tomorrow"}, | |
250 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_WEEK, "next week"}, | |
251 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_MONTH, "next month"}, | |
3d1f044b | 252 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_QUARTER, "next quarter"}, |
57a6839d A |
253 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_YEAR, "next year"}, |
254 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_MONDAY, "next Monday"}, | |
255 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_TUESDAY, "next Tuesday"}, | |
256 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_WEDNESDAY, "next Wednesday"}, | |
257 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_THURSDAY, "next Thursday"}, | |
258 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_FRIDAY, "next Friday"}, | |
259 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_SATURDAY, "next Saturday"}, | |
260 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_SUNDAY, "next Sunday"}, | |
261 | ||
262 | {UDAT_DIRECTION_LAST_2, UDAT_ABSOLUTE_DAY, ""}, | |
263 | ||
264 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_DAY, "yesterday"}, | |
265 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_WEEK, "last week"}, | |
266 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_MONTH, "last month"}, | |
3d1f044b | 267 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_QUARTER, "last quarter"}, |
57a6839d A |
268 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_YEAR, "last year"}, |
269 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_MONDAY, "last Monday"}, | |
270 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_TUESDAY, "last Tuesday"}, | |
271 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_WEDNESDAY, "last Wednesday"}, | |
272 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_THURSDAY, "last Thursday"}, | |
273 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_FRIDAY, "last Friday"}, | |
274 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_SATURDAY, "last Saturday"}, | |
275 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_SUNDAY, "last Sunday"}, | |
276 | ||
277 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_DAY, "today"}, | |
278 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_WEEK, "this week"}, | |
279 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_MONTH, "this month"}, | |
3d1f044b | 280 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_QUARTER, "this quarter"}, |
57a6839d A |
281 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_YEAR, "this year"}, |
282 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_MONDAY, "this Monday"}, | |
283 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_TUESDAY, "this Tuesday"}, | |
284 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_WEDNESDAY, "this Wednesday"}, | |
285 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_THURSDAY, "this Thursday"}, | |
286 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_FRIDAY, "this Friday"}, | |
287 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_SATURDAY, "this Saturday"}, | |
288 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_SUNDAY, "this Sunday"}, | |
340931cb A |
289 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_HOUR, "this hour"}, |
290 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_MINUTE, "this minute"}, | |
57a6839d A |
291 | |
292 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_DAY, "day"}, | |
293 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_WEEK, "week"}, | |
294 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_MONTH, "month"}, | |
3d1f044b | 295 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_QUARTER, "quarter"}, |
57a6839d A |
296 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_YEAR, "year"}, |
297 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_MONDAY, "Monday"}, | |
298 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_TUESDAY, "Tuesday"}, | |
299 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_WEDNESDAY, "Wednesday"}, | |
300 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_THURSDAY, "Thursday"}, | |
301 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_FRIDAY, "Friday"}, | |
302 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_SATURDAY, "Saturday"}, | |
303 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_SUNDAY, "Sunday"}, | |
340931cb A |
304 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_HOUR, "hour"}, |
305 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_MINUTE, "minute"}, | |
57a6839d A |
306 | |
307 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_NOW, "now"} | |
308 | }; | |
309 | ||
b331163b A |
310 | static WithoutQuantityExpected kEnglishNoQuantityCaps[] = { |
311 | {UDAT_DIRECTION_NEXT_2, UDAT_ABSOLUTE_DAY, ""}, | |
312 | ||
313 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_DAY, "Tomorrow"}, | |
314 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_WEEK, "Next week"}, | |
315 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_MONTH, "Next month"}, | |
3d1f044b | 316 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_QUARTER, "Next quarter"}, |
b331163b A |
317 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_YEAR, "Next year"}, |
318 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_MONDAY, "Next Monday"}, | |
319 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_TUESDAY, "Next Tuesday"}, | |
320 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_WEDNESDAY, "Next Wednesday"}, | |
321 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_THURSDAY, "Next Thursday"}, | |
322 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_FRIDAY, "Next Friday"}, | |
323 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_SATURDAY, "Next Saturday"}, | |
324 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_SUNDAY, "Next Sunday"}, | |
325 | ||
326 | {UDAT_DIRECTION_LAST_2, UDAT_ABSOLUTE_DAY, ""}, | |
327 | ||
328 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_DAY, "Yesterday"}, | |
329 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_WEEK, "Last week"}, | |
330 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_MONTH, "Last month"}, | |
3d1f044b | 331 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_QUARTER, "Last quarter"}, |
b331163b A |
332 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_YEAR, "Last year"}, |
333 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_MONDAY, "Last Monday"}, | |
334 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_TUESDAY, "Last Tuesday"}, | |
335 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_WEDNESDAY, "Last Wednesday"}, | |
336 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_THURSDAY, "Last Thursday"}, | |
337 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_FRIDAY, "Last Friday"}, | |
338 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_SATURDAY, "Last Saturday"}, | |
339 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_SUNDAY, "Last Sunday"}, | |
340 | ||
341 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_DAY, "Today"}, | |
342 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_WEEK, "This week"}, | |
343 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_MONTH, "This month"}, | |
3d1f044b | 344 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_QUARTER, "This quarter"}, |
b331163b A |
345 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_YEAR, "This year"}, |
346 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_MONDAY, "This Monday"}, | |
347 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_TUESDAY, "This Tuesday"}, | |
348 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_WEDNESDAY, "This Wednesday"}, | |
349 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_THURSDAY, "This Thursday"}, | |
350 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_FRIDAY, "This Friday"}, | |
351 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_SATURDAY, "This Saturday"}, | |
352 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_SUNDAY, "This Sunday"}, | |
353 | ||
354 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_DAY, "Day"}, | |
355 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_WEEK, "Week"}, | |
356 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_MONTH, "Month"}, | |
3d1f044b | 357 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_QUARTER, "Quarter"}, |
b331163b A |
358 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_YEAR, "Year"}, |
359 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_MONDAY, "Monday"}, | |
360 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_TUESDAY, "Tuesday"}, | |
361 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_WEDNESDAY, "Wednesday"}, | |
362 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_THURSDAY, "Thursday"}, | |
363 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_FRIDAY, "Friday"}, | |
364 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_SATURDAY, "Saturday"}, | |
365 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_SUNDAY, "Sunday"}, | |
366 | ||
367 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_NOW, "Now"} | |
368 | }; | |
369 | ||
370 | static WithoutQuantityExpected kEnglishNoQuantityShort[] = { | |
371 | {UDAT_DIRECTION_NEXT_2, UDAT_ABSOLUTE_DAY, ""}, | |
372 | ||
373 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_DAY, "tomorrow"}, | |
374 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_WEEK, "next wk."}, | |
375 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_MONTH, "next mo."}, | |
3d1f044b | 376 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_QUARTER, "next qtr."}, |
b331163b A |
377 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_YEAR, "next yr."}, |
378 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_MONDAY, "next Mon."}, | |
379 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_TUESDAY, "next Tue."}, | |
380 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_WEDNESDAY, "next Wed."}, | |
381 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_THURSDAY, "next Thu."}, | |
382 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_FRIDAY, "next Fri."}, | |
383 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_SATURDAY, "next Sat."}, | |
384 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_SUNDAY, "next Sun."}, | |
385 | ||
386 | {UDAT_DIRECTION_LAST_2, UDAT_ABSOLUTE_DAY, ""}, | |
387 | ||
388 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_DAY, "yesterday"}, | |
389 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_WEEK, "last wk."}, | |
390 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_MONTH, "last mo."}, | |
3d1f044b | 391 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_QUARTER, "last qtr."}, |
b331163b A |
392 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_YEAR, "last yr."}, |
393 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_MONDAY, "last Mon."}, | |
394 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_TUESDAY, "last Tue."}, | |
395 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_WEDNESDAY, "last Wed."}, | |
396 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_THURSDAY, "last Thu."}, | |
397 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_FRIDAY, "last Fri."}, | |
398 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_SATURDAY, "last Sat."}, | |
399 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_SUNDAY, "last Sun."}, | |
400 | ||
401 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_DAY, "today"}, | |
402 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_WEEK, "this wk."}, | |
403 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_MONTH, "this mo."}, | |
3d1f044b | 404 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_QUARTER, "this qtr."}, |
b331163b A |
405 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_YEAR, "this yr."}, |
406 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_MONDAY, "this Mon."}, | |
407 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_TUESDAY, "this Tue."}, | |
408 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_WEDNESDAY, "this Wed."}, | |
409 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_THURSDAY, "this Thu."}, | |
410 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_FRIDAY, "this Fri."}, | |
411 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_SATURDAY, "this Sat."}, | |
412 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_SUNDAY, "this Sun."}, | |
413 | ||
414 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_DAY, "day"}, | |
415 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_WEEK, "wk."}, | |
416 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_MONTH, "mo."}, | |
3d1f044b | 417 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_QUARTER, "qtr."}, |
b331163b A |
418 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_YEAR, "yr."}, |
419 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_MONDAY, "Mo"}, | |
420 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_TUESDAY, "Tu"}, | |
421 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_WEDNESDAY, "We"}, | |
422 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_THURSDAY, "Th"}, | |
423 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_FRIDAY, "Fr"}, | |
424 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_SATURDAY, "Sa"}, | |
425 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_SUNDAY, "Su"}, | |
426 | ||
427 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_NOW, "now"} | |
428 | }; | |
429 | ||
430 | static WithoutQuantityExpected kEnglishNoQuantityNarrow[] = { | |
431 | {UDAT_DIRECTION_NEXT_2, UDAT_ABSOLUTE_DAY, ""}, | |
432 | ||
433 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_DAY, "tomorrow"}, | |
434 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_WEEK, "next wk."}, | |
435 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_MONTH, "next mo."}, | |
3d1f044b | 436 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_QUARTER, "next qtr."}, |
b331163b A |
437 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_YEAR, "next yr."}, |
438 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_MONDAY, "next M"}, | |
439 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_TUESDAY, "next Tu"}, | |
440 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_WEDNESDAY, "next W"}, | |
441 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_THURSDAY, "next Th"}, | |
442 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_FRIDAY, "next F"}, | |
443 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_SATURDAY, "next Sa"}, | |
444 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_SUNDAY, "next Su"}, | |
445 | ||
446 | {UDAT_DIRECTION_LAST_2, UDAT_ABSOLUTE_DAY, ""}, | |
447 | ||
448 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_DAY, "yesterday"}, | |
449 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_WEEK, "last wk."}, | |
450 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_MONTH, "last mo."}, | |
3d1f044b | 451 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_QUARTER, "last qtr."}, |
b331163b A |
452 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_YEAR, "last yr."}, |
453 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_MONDAY, "last M"}, | |
454 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_TUESDAY, "last Tu"}, | |
455 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_WEDNESDAY, "last W"}, | |
456 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_THURSDAY, "last Th"}, | |
457 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_FRIDAY, "last F"}, | |
458 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_SATURDAY, "last Sa"}, | |
459 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_SUNDAY, "last Su"}, | |
460 | ||
461 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_DAY, "today"}, | |
462 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_WEEK, "this wk."}, | |
463 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_MONTH, "this mo."}, | |
3d1f044b | 464 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_QUARTER, "this qtr."}, |
b331163b A |
465 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_YEAR, "this yr."}, |
466 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_MONDAY, "this M"}, | |
467 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_TUESDAY, "this Tu"}, | |
468 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_WEDNESDAY, "this W"}, | |
469 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_THURSDAY, "this Th"}, | |
470 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_FRIDAY, "this F"}, | |
471 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_SATURDAY, "this Sa"}, | |
472 | {UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_SUNDAY, "this Su"}, | |
473 | ||
474 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_DAY, "day"}, | |
475 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_WEEK, "wk."}, | |
476 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_MONTH, "mo."}, | |
3d1f044b | 477 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_QUARTER, "qtr."}, |
b331163b A |
478 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_YEAR, "yr."}, |
479 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_MONDAY, "M"}, | |
480 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_TUESDAY, "T"}, | |
481 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_WEDNESDAY, "W"}, | |
482 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_THURSDAY, "T"}, | |
483 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_FRIDAY, "F"}, | |
484 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_SATURDAY, "S"}, | |
485 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_SUNDAY, "S"}, | |
486 | ||
487 | {UDAT_DIRECTION_PLAIN, UDAT_ABSOLUTE_NOW, "now"} | |
488 | }; | |
489 | ||
57a6839d A |
490 | static WithoutQuantityExpected kSpanishNoQuantity[] = { |
491 | {UDAT_DIRECTION_NEXT_2, UDAT_ABSOLUTE_DAY, "pasado ma\\u00F1ana"}, | |
b331163b | 492 | {UDAT_DIRECTION_LAST_2, UDAT_ABSOLUTE_DAY, "anteayer"} |
57a6839d A |
493 | }; |
494 | ||
3d1f044b A |
495 | typedef struct WithQuantityExpectedRelativeDateTimeUnit { |
496 | double value; | |
497 | URelativeDateTimeUnit unit; | |
498 | const char *expected; | |
499 | } WithQuantityExpectedRelativeDateTimeUnit; | |
500 | ||
501 | static WithQuantityExpectedRelativeDateTimeUnit kEnglishFormatNumeric[] = { | |
502 | {0.0, UDAT_REL_UNIT_SECOND, "in 0 seconds"}, | |
503 | {0.5, UDAT_REL_UNIT_SECOND, "in 0.5 seconds"}, | |
504 | {1.0, UDAT_REL_UNIT_SECOND, "in 1 second"}, | |
505 | {2.0, UDAT_REL_UNIT_SECOND, "in 2 seconds"}, | |
506 | {0.0, UDAT_REL_UNIT_MINUTE, "in 0 minutes"}, | |
507 | {0.5, UDAT_REL_UNIT_MINUTE, "in 0.5 minutes"}, | |
508 | {1.0, UDAT_REL_UNIT_MINUTE, "in 1 minute"}, | |
509 | {2.0, UDAT_REL_UNIT_MINUTE, "in 2 minutes"}, | |
510 | {0.0, UDAT_REL_UNIT_HOUR, "in 0 hours"}, | |
511 | {0.5, UDAT_REL_UNIT_HOUR, "in 0.5 hours"}, | |
512 | {1.0, UDAT_REL_UNIT_HOUR, "in 1 hour"}, | |
513 | {2.0, UDAT_REL_UNIT_HOUR, "in 2 hours"}, | |
514 | {0.0, UDAT_REL_UNIT_DAY, "in 0 days"}, | |
515 | {0.5, UDAT_REL_UNIT_DAY, "in 0.5 days"}, | |
516 | {1.0, UDAT_REL_UNIT_DAY, "in 1 day"}, | |
517 | {2.0, UDAT_REL_UNIT_DAY, "in 2 days"}, | |
518 | {0.0, UDAT_REL_UNIT_WEEK, "in 0 weeks"}, | |
519 | {0.5, UDAT_REL_UNIT_WEEK, "in 0.5 weeks"}, | |
520 | {1.0, UDAT_REL_UNIT_WEEK, "in 1 week"}, | |
521 | {2.0, UDAT_REL_UNIT_WEEK, "in 2 weeks"}, | |
522 | {0.0, UDAT_REL_UNIT_MONTH, "in 0 months"}, | |
523 | {0.5, UDAT_REL_UNIT_MONTH, "in 0.5 months"}, | |
524 | {1.0, UDAT_REL_UNIT_MONTH, "in 1 month"}, | |
525 | {2.0, UDAT_REL_UNIT_MONTH, "in 2 months"}, | |
526 | {0.0, UDAT_REL_UNIT_QUARTER, "in 0 quarters"}, | |
527 | {0.5, UDAT_REL_UNIT_QUARTER, "in 0.5 quarters"}, | |
528 | {1.0, UDAT_REL_UNIT_QUARTER, "in 1 quarter"}, | |
529 | {2.0, UDAT_REL_UNIT_QUARTER, "in 2 quarters"}, | |
530 | {0.0, UDAT_REL_UNIT_YEAR, "in 0 years"}, | |
531 | {0.5, UDAT_REL_UNIT_YEAR, "in 0.5 years"}, | |
532 | {1.0, UDAT_REL_UNIT_YEAR, "in 1 year"}, | |
533 | {2.0, UDAT_REL_UNIT_YEAR, "in 2 years"}, | |
534 | {0.0, UDAT_REL_UNIT_SUNDAY, "in 0 Sundays"}, | |
535 | {0.5, UDAT_REL_UNIT_SUNDAY, "in 0.5 Sundays"}, | |
536 | {1.0, UDAT_REL_UNIT_SUNDAY, "in 1 Sunday"}, | |
537 | {2.0, UDAT_REL_UNIT_SUNDAY, "in 2 Sundays"}, | |
538 | {0.0, UDAT_REL_UNIT_MONDAY, "in 0 Mondays"}, | |
539 | {0.5, UDAT_REL_UNIT_MONDAY, "in 0.5 Mondays"}, | |
540 | {1.0, UDAT_REL_UNIT_MONDAY, "in 1 Monday"}, | |
541 | {2.0, UDAT_REL_UNIT_MONDAY, "in 2 Mondays"}, | |
542 | {0.0, UDAT_REL_UNIT_TUESDAY, "in 0 Tuesdays"}, | |
543 | {0.5, UDAT_REL_UNIT_TUESDAY, "in 0.5 Tuesdays"}, | |
544 | {1.0, UDAT_REL_UNIT_TUESDAY, "in 1 Tuesday"}, | |
545 | {2.0, UDAT_REL_UNIT_TUESDAY, "in 2 Tuesdays"}, | |
546 | {0.0, UDAT_REL_UNIT_WEDNESDAY, "in 0 Wednesdays"}, | |
547 | {0.5, UDAT_REL_UNIT_WEDNESDAY, "in 0.5 Wednesdays"}, | |
548 | {1.0, UDAT_REL_UNIT_WEDNESDAY, "in 1 Wednesday"}, | |
549 | {2.0, UDAT_REL_UNIT_WEDNESDAY, "in 2 Wednesdays"}, | |
550 | {0.0, UDAT_REL_UNIT_THURSDAY, "in 0 Thursdays"}, | |
551 | {0.5, UDAT_REL_UNIT_THURSDAY, "in 0.5 Thursdays"}, | |
552 | {1.0, UDAT_REL_UNIT_THURSDAY, "in 1 Thursday"}, | |
553 | {2.0, UDAT_REL_UNIT_THURSDAY, "in 2 Thursdays"}, | |
554 | {0.0, UDAT_REL_UNIT_FRIDAY, "in 0 Fridays"}, | |
555 | {0.5, UDAT_REL_UNIT_FRIDAY, "in 0.5 Fridays"}, | |
556 | {1.0, UDAT_REL_UNIT_FRIDAY, "in 1 Friday"}, | |
557 | {2.0, UDAT_REL_UNIT_FRIDAY, "in 2 Fridays"}, | |
558 | {0.0, UDAT_REL_UNIT_SATURDAY, "in 0 Saturdays"}, | |
559 | {0.5, UDAT_REL_UNIT_SATURDAY, "in 0.5 Saturdays"}, | |
560 | {1.0, UDAT_REL_UNIT_SATURDAY, "in 1 Saturday"}, | |
561 | {2.0, UDAT_REL_UNIT_SATURDAY, "in 2 Saturdays"}, | |
562 | ||
563 | {-0.0, UDAT_REL_UNIT_SECOND, "0 seconds ago"}, | |
564 | {-0.5, UDAT_REL_UNIT_SECOND, "0.5 seconds ago"}, | |
565 | {-1.0, UDAT_REL_UNIT_SECOND, "1 second ago"}, | |
566 | {-2.0, UDAT_REL_UNIT_SECOND, "2 seconds ago"}, | |
567 | {-0.0, UDAT_REL_UNIT_MINUTE, "0 minutes ago"}, | |
568 | {-0.5, UDAT_REL_UNIT_MINUTE, "0.5 minutes ago"}, | |
569 | {-1.0, UDAT_REL_UNIT_MINUTE, "1 minute ago"}, | |
570 | {-2.0, UDAT_REL_UNIT_MINUTE, "2 minutes ago"}, | |
571 | {-0.0, UDAT_REL_UNIT_HOUR, "0 hours ago"}, | |
572 | {-0.5, UDAT_REL_UNIT_HOUR, "0.5 hours ago"}, | |
573 | {-1.0, UDAT_REL_UNIT_HOUR, "1 hour ago"}, | |
574 | {-2.0, UDAT_REL_UNIT_HOUR, "2 hours ago"}, | |
575 | {-0.0, UDAT_REL_UNIT_DAY, "0 days ago"}, | |
576 | {-0.5, UDAT_REL_UNIT_DAY, "0.5 days ago"}, | |
577 | {-1.0, UDAT_REL_UNIT_DAY, "1 day ago"}, | |
578 | {-2.0, UDAT_REL_UNIT_DAY, "2 days ago"}, | |
579 | {-0.0, UDAT_REL_UNIT_WEEK, "0 weeks ago"}, | |
580 | {-0.5, UDAT_REL_UNIT_WEEK, "0.5 weeks ago"}, | |
581 | {-1.0, UDAT_REL_UNIT_WEEK, "1 week ago"}, | |
582 | {-2.0, UDAT_REL_UNIT_WEEK, "2 weeks ago"}, | |
583 | {-0.0, UDAT_REL_UNIT_MONTH, "0 months ago"}, | |
584 | {-0.5, UDAT_REL_UNIT_MONTH, "0.5 months ago"}, | |
585 | {-1.0, UDAT_REL_UNIT_MONTH, "1 month ago"}, | |
586 | {-2.0, UDAT_REL_UNIT_MONTH, "2 months ago"}, | |
587 | {-0.0, UDAT_REL_UNIT_QUARTER, "0 quarters ago"}, | |
588 | {-0.5, UDAT_REL_UNIT_QUARTER, "0.5 quarters ago"}, | |
589 | {-1.0, UDAT_REL_UNIT_QUARTER, "1 quarter ago"}, | |
590 | {-2.0, UDAT_REL_UNIT_QUARTER, "2 quarters ago"}, | |
591 | {-0.0, UDAT_REL_UNIT_YEAR, "0 years ago"}, | |
592 | {-0.5, UDAT_REL_UNIT_YEAR, "0.5 years ago"}, | |
593 | {-1.0, UDAT_REL_UNIT_YEAR, "1 year ago"}, | |
594 | {-2.0, UDAT_REL_UNIT_YEAR, "2 years ago"}, | |
595 | {-0.0, UDAT_REL_UNIT_SUNDAY, "0 Sundays ago"}, | |
596 | {-0.5, UDAT_REL_UNIT_SUNDAY, "0.5 Sundays ago"}, | |
597 | {-1.0, UDAT_REL_UNIT_SUNDAY, "1 Sunday ago"}, | |
598 | {-2.0, UDAT_REL_UNIT_SUNDAY, "2 Sundays ago"}, | |
599 | {-0.0, UDAT_REL_UNIT_MONDAY, "0 Mondays ago"}, | |
600 | {-0.5, UDAT_REL_UNIT_MONDAY, "0.5 Mondays ago"}, | |
601 | {-1.0, UDAT_REL_UNIT_MONDAY, "1 Monday ago"}, | |
602 | {-2.0, UDAT_REL_UNIT_MONDAY, "2 Mondays ago"}, | |
603 | {-0.0, UDAT_REL_UNIT_TUESDAY, "0 Tuesdays ago"}, | |
604 | {-0.5, UDAT_REL_UNIT_TUESDAY, "0.5 Tuesdays ago"}, | |
605 | {-1.0, UDAT_REL_UNIT_TUESDAY, "1 Tuesday ago"}, | |
606 | {-2.0, UDAT_REL_UNIT_TUESDAY, "2 Tuesdays ago"}, | |
607 | {-0.0, UDAT_REL_UNIT_WEDNESDAY, "0 Wednesdays ago"}, | |
608 | {-0.5, UDAT_REL_UNIT_WEDNESDAY, "0.5 Wednesdays ago"}, | |
609 | {-1.0, UDAT_REL_UNIT_WEDNESDAY, "1 Wednesday ago"}, | |
610 | {-2.0, UDAT_REL_UNIT_WEDNESDAY, "2 Wednesdays ago"}, | |
611 | {-0.0, UDAT_REL_UNIT_THURSDAY, "0 Thursdays ago"}, | |
612 | {-0.5, UDAT_REL_UNIT_THURSDAY, "0.5 Thursdays ago"}, | |
613 | {-1.0, UDAT_REL_UNIT_THURSDAY, "1 Thursday ago"}, | |
614 | {-2.0, UDAT_REL_UNIT_THURSDAY, "2 Thursdays ago"}, | |
615 | {-0.0, UDAT_REL_UNIT_FRIDAY, "0 Fridays ago"}, | |
616 | {-0.5, UDAT_REL_UNIT_FRIDAY, "0.5 Fridays ago"}, | |
617 | {-1.0, UDAT_REL_UNIT_FRIDAY, "1 Friday ago"}, | |
618 | {-2.0, UDAT_REL_UNIT_FRIDAY, "2 Fridays ago"}, | |
619 | {-0.0, UDAT_REL_UNIT_SATURDAY, "0 Saturdays ago"}, | |
620 | {-0.5, UDAT_REL_UNIT_SATURDAY, "0.5 Saturdays ago"}, | |
621 | {-1.0, UDAT_REL_UNIT_SATURDAY, "1 Saturday ago"}, | |
622 | {-2.0, UDAT_REL_UNIT_SATURDAY, "2 Saturdays ago"} | |
623 | }; | |
624 | ||
625 | static WithQuantityExpectedRelativeDateTimeUnit kEnglishFormat[] = { | |
626 | {0.0, UDAT_REL_UNIT_SECOND, "now"}, | |
627 | {0.5, UDAT_REL_UNIT_SECOND, "in 0.5 seconds"}, | |
628 | {1.0, UDAT_REL_UNIT_SECOND, "in 1 second"}, | |
629 | {2.0, UDAT_REL_UNIT_SECOND, "in 2 seconds"}, | |
340931cb | 630 | {0.0, UDAT_REL_UNIT_MINUTE, "this minute"}, |
3d1f044b A |
631 | {0.5, UDAT_REL_UNIT_MINUTE, "in 0.5 minutes"}, |
632 | {1.0, UDAT_REL_UNIT_MINUTE, "in 1 minute"}, | |
633 | {2.0, UDAT_REL_UNIT_MINUTE, "in 2 minutes"}, | |
340931cb | 634 | {0.0, UDAT_REL_UNIT_HOUR, "this hour"}, |
3d1f044b A |
635 | {0.5, UDAT_REL_UNIT_HOUR, "in 0.5 hours"}, |
636 | {1.0, UDAT_REL_UNIT_HOUR, "in 1 hour"}, | |
637 | {2.0, UDAT_REL_UNIT_HOUR, "in 2 hours"}, | |
638 | {0.0, UDAT_REL_UNIT_DAY, "today"}, | |
639 | {0.5, UDAT_REL_UNIT_DAY, "in 0.5 days"}, | |
640 | {1.0, UDAT_REL_UNIT_DAY, "tomorrow"}, | |
641 | {2.0, UDAT_REL_UNIT_DAY, "in 2 days"}, | |
642 | {0.0, UDAT_REL_UNIT_WEEK, "this week"}, | |
643 | {0.5, UDAT_REL_UNIT_WEEK, "in 0.5 weeks"}, | |
644 | {1.0, UDAT_REL_UNIT_WEEK, "next week"}, | |
645 | {2.0, UDAT_REL_UNIT_WEEK, "in 2 weeks"}, | |
646 | {0.0, UDAT_REL_UNIT_MONTH, "this month"}, | |
647 | {0.5, UDAT_REL_UNIT_MONTH, "in 0.5 months"}, | |
648 | {1.0, UDAT_REL_UNIT_MONTH, "next month"}, | |
649 | {2.0, UDAT_REL_UNIT_MONTH, "in 2 months"}, | |
650 | {0.0, UDAT_REL_UNIT_QUARTER, "this quarter"}, | |
651 | {0.5, UDAT_REL_UNIT_QUARTER, "in 0.5 quarters"}, | |
652 | {1.0, UDAT_REL_UNIT_QUARTER, "next quarter"}, | |
653 | {2.0, UDAT_REL_UNIT_QUARTER, "in 2 quarters"}, | |
654 | {0.0, UDAT_REL_UNIT_YEAR, "this year"}, | |
655 | {0.5, UDAT_REL_UNIT_YEAR, "in 0.5 years"}, | |
656 | {1.0, UDAT_REL_UNIT_YEAR, "next year"}, | |
657 | {2.0, UDAT_REL_UNIT_YEAR, "in 2 years"}, | |
658 | {0.0, UDAT_REL_UNIT_SUNDAY, "this Sunday"}, | |
659 | {0.5, UDAT_REL_UNIT_SUNDAY, "in 0.5 Sundays"}, | |
660 | {1.0, UDAT_REL_UNIT_SUNDAY, "next Sunday"}, | |
661 | {2.0, UDAT_REL_UNIT_SUNDAY, "in 2 Sundays"}, | |
662 | {0.0, UDAT_REL_UNIT_MONDAY, "this Monday"}, | |
663 | {0.5, UDAT_REL_UNIT_MONDAY, "in 0.5 Mondays"}, | |
664 | {1.0, UDAT_REL_UNIT_MONDAY, "next Monday"}, | |
665 | {2.0, UDAT_REL_UNIT_MONDAY, "in 2 Mondays"}, | |
666 | {0.0, UDAT_REL_UNIT_TUESDAY, "this Tuesday"}, | |
667 | {0.5, UDAT_REL_UNIT_TUESDAY, "in 0.5 Tuesdays"}, | |
668 | {1.0, UDAT_REL_UNIT_TUESDAY, "next Tuesday"}, | |
669 | {2.0, UDAT_REL_UNIT_TUESDAY, "in 2 Tuesdays"}, | |
670 | {0.0, UDAT_REL_UNIT_WEDNESDAY, "this Wednesday"}, | |
671 | {0.5, UDAT_REL_UNIT_WEDNESDAY, "in 0.5 Wednesdays"}, | |
672 | {1.0, UDAT_REL_UNIT_WEDNESDAY, "next Wednesday"}, | |
673 | {2.0, UDAT_REL_UNIT_WEDNESDAY, "in 2 Wednesdays"}, | |
674 | {0.0, UDAT_REL_UNIT_THURSDAY, "this Thursday"}, | |
675 | {0.5, UDAT_REL_UNIT_THURSDAY, "in 0.5 Thursdays"}, | |
676 | {1.0, UDAT_REL_UNIT_THURSDAY, "next Thursday"}, | |
677 | {2.0, UDAT_REL_UNIT_THURSDAY, "in 2 Thursdays"}, | |
678 | {0.0, UDAT_REL_UNIT_FRIDAY, "this Friday"}, | |
679 | {0.5, UDAT_REL_UNIT_FRIDAY, "in 0.5 Fridays"}, | |
680 | {1.0, UDAT_REL_UNIT_FRIDAY, "next Friday"}, | |
681 | {2.0, UDAT_REL_UNIT_FRIDAY, "in 2 Fridays"}, | |
682 | {0.0, UDAT_REL_UNIT_SATURDAY, "this Saturday"}, | |
683 | {0.5, UDAT_REL_UNIT_SATURDAY, "in 0.5 Saturdays"}, | |
684 | {1.0, UDAT_REL_UNIT_SATURDAY, "next Saturday"}, | |
685 | {2.0, UDAT_REL_UNIT_SATURDAY, "in 2 Saturdays"}, | |
686 | ||
687 | {-0.0, UDAT_REL_UNIT_SECOND, "now"}, | |
688 | {-0.5, UDAT_REL_UNIT_SECOND, "0.5 seconds ago"}, | |
689 | {-1.0, UDAT_REL_UNIT_SECOND, "1 second ago"}, | |
690 | {-2.0, UDAT_REL_UNIT_SECOND, "2 seconds ago"}, | |
340931cb | 691 | {-0.0, UDAT_REL_UNIT_MINUTE, "this minute"}, |
3d1f044b A |
692 | {-0.5, UDAT_REL_UNIT_MINUTE, "0.5 minutes ago"}, |
693 | {-1.0, UDAT_REL_UNIT_MINUTE, "1 minute ago"}, | |
694 | {-2.0, UDAT_REL_UNIT_MINUTE, "2 minutes ago"}, | |
340931cb | 695 | {-0.0, UDAT_REL_UNIT_HOUR, "this hour"}, |
3d1f044b A |
696 | {-0.5, UDAT_REL_UNIT_HOUR, "0.5 hours ago"}, |
697 | {-1.0, UDAT_REL_UNIT_HOUR, "1 hour ago"}, | |
698 | {-2.0, UDAT_REL_UNIT_HOUR, "2 hours ago"}, | |
699 | {-0.0, UDAT_REL_UNIT_DAY, "today"}, | |
700 | {-0.5, UDAT_REL_UNIT_DAY, "0.5 days ago"}, | |
701 | {-1.0, UDAT_REL_UNIT_DAY, "yesterday"}, | |
702 | {-2.0, UDAT_REL_UNIT_DAY, "2 days ago"}, | |
703 | {-0.0, UDAT_REL_UNIT_WEEK, "this week"}, | |
704 | {-0.5, UDAT_REL_UNIT_WEEK, "0.5 weeks ago"}, | |
705 | {-1.0, UDAT_REL_UNIT_WEEK, "last week"}, | |
706 | {-2.0, UDAT_REL_UNIT_WEEK, "2 weeks ago"}, | |
707 | {-0.0, UDAT_REL_UNIT_MONTH, "this month"}, | |
708 | {-0.5, UDAT_REL_UNIT_MONTH, "0.5 months ago"}, | |
709 | {-1.0, UDAT_REL_UNIT_MONTH, "last month"}, | |
710 | {-2.0, UDAT_REL_UNIT_MONTH, "2 months ago"}, | |
711 | {-0.0, UDAT_REL_UNIT_QUARTER, "this quarter"}, | |
712 | {-0.5, UDAT_REL_UNIT_QUARTER, "0.5 quarters ago"}, | |
713 | {-1.0, UDAT_REL_UNIT_QUARTER, "last quarter"}, | |
714 | {-2.0, UDAT_REL_UNIT_QUARTER, "2 quarters ago"}, | |
715 | {-0.0, UDAT_REL_UNIT_YEAR, "this year"}, | |
716 | {-0.5, UDAT_REL_UNIT_YEAR, "0.5 years ago"}, | |
717 | {-1.0, UDAT_REL_UNIT_YEAR, "last year"}, | |
718 | {-2.0, UDAT_REL_UNIT_YEAR, "2 years ago"}, | |
719 | {-0.0, UDAT_REL_UNIT_SUNDAY, "this Sunday"}, | |
720 | {-0.5, UDAT_REL_UNIT_SUNDAY, "0.5 Sundays ago"}, | |
721 | {-1.0, UDAT_REL_UNIT_SUNDAY, "last Sunday"}, | |
722 | {-2.0, UDAT_REL_UNIT_SUNDAY, "2 Sundays ago"}, | |
723 | {-0.0, UDAT_REL_UNIT_MONDAY, "this Monday"}, | |
724 | {-0.5, UDAT_REL_UNIT_MONDAY, "0.5 Mondays ago"}, | |
725 | {-1.0, UDAT_REL_UNIT_MONDAY, "last Monday"}, | |
726 | {-2.0, UDAT_REL_UNIT_MONDAY, "2 Mondays ago"}, | |
727 | {-0.0, UDAT_REL_UNIT_TUESDAY, "this Tuesday"}, | |
728 | {-0.5, UDAT_REL_UNIT_TUESDAY, "0.5 Tuesdays ago"}, | |
729 | {-1.0, UDAT_REL_UNIT_TUESDAY, "last Tuesday"}, | |
730 | {-2.0, UDAT_REL_UNIT_TUESDAY, "2 Tuesdays ago"}, | |
731 | {-0.0, UDAT_REL_UNIT_WEDNESDAY, "this Wednesday"}, | |
732 | {-0.5, UDAT_REL_UNIT_WEDNESDAY, "0.5 Wednesdays ago"}, | |
733 | {-1.0, UDAT_REL_UNIT_WEDNESDAY, "last Wednesday"}, | |
734 | {-2.0, UDAT_REL_UNIT_WEDNESDAY, "2 Wednesdays ago"}, | |
735 | {-0.0, UDAT_REL_UNIT_THURSDAY, "this Thursday"}, | |
736 | {-0.5, UDAT_REL_UNIT_THURSDAY, "0.5 Thursdays ago"}, | |
737 | {-1.0, UDAT_REL_UNIT_THURSDAY, "last Thursday"}, | |
738 | {-2.0, UDAT_REL_UNIT_THURSDAY, "2 Thursdays ago"}, | |
739 | {-0.0, UDAT_REL_UNIT_FRIDAY, "this Friday"}, | |
740 | {-0.5, UDAT_REL_UNIT_FRIDAY, "0.5 Fridays ago"}, | |
741 | {-1.0, UDAT_REL_UNIT_FRIDAY, "last Friday"}, | |
742 | {-2.0, UDAT_REL_UNIT_FRIDAY, "2 Fridays ago"}, | |
743 | {-0.0, UDAT_REL_UNIT_SATURDAY, "this Saturday"}, | |
744 | {-0.5, UDAT_REL_UNIT_SATURDAY, "0.5 Saturdays ago"}, | |
745 | {-1.0, UDAT_REL_UNIT_SATURDAY, "last Saturday"}, | |
746 | {-2.0, UDAT_REL_UNIT_SATURDAY, "2 Saturdays ago"} | |
747 | }; | |
748 | ||
340931cb A |
749 | static WithQuantityExpected kAfrikaans[] = { |
750 | {1.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "oor 1 maand"}, | |
751 | {2.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, "oor 2 maande"}, | |
752 | {1.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "1 maand gelede"}, | |
753 | {2.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_MONTHS, "2 maande gelede"}, | |
754 | }; | |
755 | ||
756 | static WithoutQuantityExpected kAfrikaansNoQuantity[] = { | |
757 | {UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_MONTH, "volgende maand"}, | |
758 | {UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_MONTH, "verlede maand"}, | |
759 | }; | |
760 | ||
761 | static WithQuantityExpectedRelativeDateTimeUnit kAfrikaansFormatNumeric[] = { | |
762 | {0.0, UDAT_REL_UNIT_MONTH, "oor 0 maande"}, | |
763 | {1.0, UDAT_REL_UNIT_MONTH, "oor 1 maand"}, | |
764 | {2.0, UDAT_REL_UNIT_MONTH, "oor 2 maande"}, | |
765 | {-0.0, UDAT_REL_UNIT_MONTH, "0 maande gelede"}, | |
766 | {-1.0, UDAT_REL_UNIT_MONTH, "1 maand gelede"}, | |
767 | {-2.0, UDAT_REL_UNIT_MONTH, "2 maande gelede"}, | |
768 | }; | |
3d1f044b A |
769 | |
770 | class RelativeDateTimeFormatterTest : public IntlTestWithFieldPosition { | |
57a6839d A |
771 | public: |
772 | RelativeDateTimeFormatterTest() { | |
773 | } | |
774 | ||
775 | void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par=0); | |
776 | private: | |
777 | void TestEnglish(); | |
b331163b A |
778 | void TestEnglishCaps(); |
779 | void TestEnglishShort(); | |
780 | void TestEnglishNarrow(); | |
57a6839d | 781 | void TestSerbian(); |
b331163b | 782 | void TestSerbianFallback(); |
57a6839d | 783 | void TestEnglishNoQuantity(); |
b331163b A |
784 | void TestEnglishNoQuantityCaps(); |
785 | void TestEnglishNoQuantityShort(); | |
786 | void TestEnglishNoQuantityNarrow(); | |
57a6839d | 787 | void TestSpanishNoQuantity(); |
340931cb | 788 | void TestAfrikaans(); |
57a6839d A |
789 | void TestFormatWithQuantityIllegalArgument(); |
790 | void TestFormatWithoutQuantityIllegalArgument(); | |
791 | void TestCustomNumberFormat(); | |
b331163b | 792 | void TestGetters(); |
57a6839d | 793 | void TestCombineDateAndTime(); |
b331163b | 794 | void TestBadDisplayContext(); |
3d1f044b A |
795 | void TestFormat(); |
796 | void TestFormatNumeric(); | |
797 | void TestLocales(); | |
798 | void TestFields(); | |
799 | void TestRBNF(); | |
800 | ||
b331163b A |
801 | void RunTest( |
802 | const Locale& locale, | |
803 | const WithQuantityExpected* expectedResults, | |
804 | int32_t expectedResultLength); | |
3d1f044b A |
805 | void RunTest( |
806 | const Locale& locale, | |
807 | const WithQuantityExpectedRelativeDateTimeUnit* expectedResults, | |
808 | int32_t expectedResultLength, | |
809 | bool numeric); | |
57a6839d A |
810 | void RunTest( |
811 | const Locale& locale, | |
b331163b | 812 | UDateRelativeDateTimeFormatterStyle style, |
57a6839d A |
813 | const WithQuantityExpected* expectedResults, |
814 | int32_t expectedResultLength); | |
815 | void RunTest( | |
816 | const Locale& locale, | |
817 | const WithoutQuantityExpected* expectedResults, | |
818 | int32_t expectedResultLength); | |
b331163b A |
819 | void RunTest( |
820 | const Locale& locale, | |
821 | UDateRelativeDateTimeFormatterStyle style, | |
822 | const WithoutQuantityExpected* expectedResults, | |
823 | int32_t expectedResultLength); | |
57a6839d A |
824 | void RunTest( |
825 | const RelativeDateTimeFormatter& fmt, | |
826 | const WithQuantityExpected* expectedResults, | |
827 | int32_t expectedResultLength, | |
828 | const char *description); | |
3d1f044b A |
829 | void RunTest( |
830 | const RelativeDateTimeFormatter& fmt, | |
831 | const WithQuantityExpectedRelativeDateTimeUnit* expectedResults, | |
832 | int32_t expectedResultLength, | |
833 | const char *description, | |
834 | bool numeric); | |
57a6839d A |
835 | void RunTest( |
836 | const RelativeDateTimeFormatter& fmt, | |
837 | const WithoutQuantityExpected* expectedResults, | |
838 | int32_t expectedResultLength, | |
839 | const char *description); | |
840 | void CheckExpectedResult( | |
841 | const RelativeDateTimeFormatter& fmt, | |
842 | const WithQuantityExpected& expectedResult, | |
843 | const char* description); | |
3d1f044b A |
844 | void CheckExpectedResult( |
845 | const RelativeDateTimeFormatter& fmt, | |
846 | const WithQuantityExpectedRelativeDateTimeUnit& expectedResults, | |
847 | const char* description, | |
848 | bool numeric); | |
57a6839d A |
849 | void CheckExpectedResult( |
850 | const RelativeDateTimeFormatter& fmt, | |
851 | const WithoutQuantityExpected& expectedResult, | |
852 | const char* description); | |
853 | void VerifyIllegalArgument( | |
854 | const RelativeDateTimeFormatter& fmt, | |
855 | UDateDirection direction, | |
856 | UDateRelativeUnit unit); | |
857 | void VerifyIllegalArgument( | |
858 | const RelativeDateTimeFormatter& fmt, | |
859 | UDateDirection direction, | |
860 | UDateAbsoluteUnit unit); | |
2ca993e8 | 861 | void TestSidewaysDataLoading(void); |
57a6839d A |
862 | }; |
863 | ||
864 | void RelativeDateTimeFormatterTest::runIndexedTest( | |
865 | int32_t index, UBool exec, const char *&name, char *) { | |
866 | if (exec) { | |
867 | logln("TestSuite RelativeDateTimeFormatterTest: "); | |
868 | } | |
869 | TESTCASE_AUTO_BEGIN; | |
870 | TESTCASE_AUTO(TestEnglish); | |
b331163b A |
871 | TESTCASE_AUTO(TestEnglishCaps); |
872 | TESTCASE_AUTO(TestEnglishShort); | |
873 | TESTCASE_AUTO(TestEnglishNarrow); | |
57a6839d | 874 | TESTCASE_AUTO(TestSerbian); |
b331163b | 875 | TESTCASE_AUTO(TestSerbianFallback); |
57a6839d | 876 | TESTCASE_AUTO(TestEnglishNoQuantity); |
b331163b A |
877 | TESTCASE_AUTO(TestEnglishNoQuantityCaps); |
878 | TESTCASE_AUTO(TestEnglishNoQuantityShort); | |
879 | TESTCASE_AUTO(TestEnglishNoQuantityNarrow); | |
57a6839d | 880 | TESTCASE_AUTO(TestSpanishNoQuantity); |
340931cb | 881 | TESTCASE_AUTO(TestAfrikaans); |
57a6839d A |
882 | TESTCASE_AUTO(TestFormatWithQuantityIllegalArgument); |
883 | TESTCASE_AUTO(TestFormatWithoutQuantityIllegalArgument); | |
884 | TESTCASE_AUTO(TestCustomNumberFormat); | |
b331163b | 885 | TESTCASE_AUTO(TestGetters); |
57a6839d | 886 | TESTCASE_AUTO(TestCombineDateAndTime); |
b331163b | 887 | TESTCASE_AUTO(TestBadDisplayContext); |
2ca993e8 | 888 | TESTCASE_AUTO(TestSidewaysDataLoading); |
3d1f044b A |
889 | TESTCASE_AUTO(TestFormat); |
890 | TESTCASE_AUTO(TestFormatNumeric); | |
891 | TESTCASE_AUTO(TestLocales); | |
892 | TESTCASE_AUTO(TestFields); | |
893 | TESTCASE_AUTO(TestRBNF); | |
57a6839d A |
894 | TESTCASE_AUTO_END; |
895 | } | |
896 | ||
897 | void RelativeDateTimeFormatterTest::TestEnglish() { | |
b331163b A |
898 | RunTest("en", kEnglish, UPRV_LENGTHOF(kEnglish)); |
899 | } | |
900 | ||
901 | void RelativeDateTimeFormatterTest::TestEnglishCaps() { | |
902 | UErrorCode status = U_ZERO_ERROR; | |
903 | RelativeDateTimeFormatter fmt( | |
904 | "en", | |
905 | NULL, | |
906 | UDAT_STYLE_LONG, | |
907 | UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, | |
908 | status); | |
909 | if (U_FAILURE(status)) { | |
910 | dataerrln("Failed call to RelativeDateTimeFormatter(\"en\", NULL, UDAT_STYLE_LONG, UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, status); : %s", u_errorName(status)); | |
911 | return; | |
912 | } | |
913 | RelativeDateTimeFormatter fmt3(status); | |
914 | ||
915 | // Test assignment and copy constructor with capitalization on. | |
916 | RelativeDateTimeFormatter fmt2(fmt); | |
917 | fmt3 = fmt2; | |
918 | assertSuccess("", status); | |
919 | RunTest(fmt3, kEnglishCaps, UPRV_LENGTHOF(kEnglishCaps), "en caps"); | |
920 | } | |
921 | ||
922 | void RelativeDateTimeFormatterTest::TestEnglishShort() { | |
923 | RunTest("en", UDAT_STYLE_SHORT, kEnglishShort, UPRV_LENGTHOF(kEnglishShort)); | |
924 | } | |
925 | ||
926 | void RelativeDateTimeFormatterTest::TestEnglishNarrow() { | |
927 | RunTest("en", UDAT_STYLE_NARROW, kEnglishShort, UPRV_LENGTHOF(kEnglishShort)); | |
57a6839d A |
928 | } |
929 | ||
930 | void RelativeDateTimeFormatterTest::TestSerbian() { | |
b331163b A |
931 | RunTest("sr", kSerbian, UPRV_LENGTHOF(kSerbian)); |
932 | } | |
933 | ||
934 | void RelativeDateTimeFormatterTest::TestSerbianFallback() { | |
935 | RunTest("sr", UDAT_STYLE_NARROW, kSerbianNarrow, UPRV_LENGTHOF(kSerbianNarrow)); | |
57a6839d A |
936 | } |
937 | ||
938 | void RelativeDateTimeFormatterTest::TestEnglishNoQuantity() { | |
b331163b A |
939 | RunTest("en", kEnglishNoQuantity, UPRV_LENGTHOF(kEnglishNoQuantity)); |
940 | } | |
941 | ||
942 | void RelativeDateTimeFormatterTest::TestEnglishNoQuantityCaps() { | |
943 | UErrorCode status = U_ZERO_ERROR; | |
944 | RelativeDateTimeFormatter fmt( | |
945 | "en", | |
946 | NULL, | |
947 | UDAT_STYLE_LONG, | |
948 | UDISPCTX_CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE, | |
949 | status); | |
950 | if (assertSuccess("RelativeDateTimeFormatter", status, TRUE) == FALSE) { | |
951 | return; | |
952 | } | |
953 | RunTest( | |
954 | fmt, | |
955 | kEnglishNoQuantityCaps, | |
956 | UPRV_LENGTHOF(kEnglishNoQuantityCaps), | |
957 | "en caps no quantity"); | |
958 | } | |
959 | ||
960 | void RelativeDateTimeFormatterTest::TestEnglishNoQuantityShort() { | |
961 | RunTest( | |
962 | "en", | |
963 | UDAT_STYLE_SHORT, | |
964 | kEnglishNoQuantityShort, | |
965 | UPRV_LENGTHOF(kEnglishNoQuantityShort)); | |
966 | } | |
967 | ||
968 | void RelativeDateTimeFormatterTest::TestEnglishNoQuantityNarrow() { | |
969 | RunTest( | |
970 | "en", | |
971 | UDAT_STYLE_NARROW, | |
972 | kEnglishNoQuantityNarrow, | |
973 | UPRV_LENGTHOF(kEnglishNoQuantityNarrow)); | |
57a6839d A |
974 | } |
975 | ||
976 | void RelativeDateTimeFormatterTest::TestSpanishNoQuantity() { | |
b331163b | 977 | RunTest("es", kSpanishNoQuantity, UPRV_LENGTHOF(kSpanishNoQuantity)); |
57a6839d A |
978 | } |
979 | ||
340931cb A |
980 | void RelativeDateTimeFormatterTest::TestAfrikaans() { |
981 | RunTest("af", kAfrikaans, UPRV_LENGTHOF(kAfrikaans)); | |
982 | RunTest("af", kAfrikaansNoQuantity, UPRV_LENGTHOF(kAfrikaansNoQuantity)); | |
983 | RunTest("af", kAfrikaansFormatNumeric, UPRV_LENGTHOF(kAfrikaansFormatNumeric), true); | |
984 | } | |
985 | ||
57a6839d A |
986 | void RelativeDateTimeFormatterTest::TestFormatWithQuantityIllegalArgument() { |
987 | UErrorCode status = U_ZERO_ERROR; | |
988 | RelativeDateTimeFormatter fmt("en", status); | |
989 | if (U_FAILURE(status)) { | |
990 | dataerrln("Failure creating format object - %s", u_errorName(status)); | |
991 | return; | |
992 | } | |
993 | VerifyIllegalArgument(fmt, UDAT_DIRECTION_PLAIN, UDAT_RELATIVE_DAYS); | |
994 | VerifyIllegalArgument(fmt, UDAT_DIRECTION_THIS, UDAT_RELATIVE_DAYS); | |
995 | } | |
996 | ||
997 | void RelativeDateTimeFormatterTest::TestFormatWithoutQuantityIllegalArgument() { | |
998 | UErrorCode status = U_ZERO_ERROR; | |
999 | RelativeDateTimeFormatter fmt("en", status); | |
1000 | if (U_FAILURE(status)) { | |
1001 | dataerrln("Failure creating format object - %s", u_errorName(status)); | |
1002 | return; | |
1003 | } | |
1004 | VerifyIllegalArgument(fmt, UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_NOW); | |
1005 | VerifyIllegalArgument(fmt, UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_NOW); | |
1006 | VerifyIllegalArgument(fmt, UDAT_DIRECTION_THIS, UDAT_ABSOLUTE_NOW); | |
1007 | } | |
1008 | ||
1009 | void RelativeDateTimeFormatterTest::TestCustomNumberFormat() { | |
1010 | NumberFormat *nf; | |
1011 | UErrorCode status = U_ZERO_ERROR; | |
1012 | { | |
1013 | RelativeDateTimeFormatter fmt("en", status); | |
1014 | if (U_FAILURE(status)) { | |
1015 | dataerrln( | |
1016 | "Failure creating format object - %s", u_errorName(status)); | |
1017 | return; | |
1018 | } | |
340931cb | 1019 | nf = fmt.getNumberFormat().clone(); |
57a6839d A |
1020 | } |
1021 | nf->setMinimumFractionDigits(1); | |
1022 | nf->setMaximumFractionDigits(1); | |
1023 | RelativeDateTimeFormatter fmt("en", nf, status); | |
1024 | ||
1025 | // Test copy constructor. | |
1026 | RelativeDateTimeFormatter fmt2(fmt); | |
b331163b | 1027 | RunTest(fmt2, kEnglishDecimal, UPRV_LENGTHOF(kEnglishDecimal), "en decimal digits"); |
57a6839d A |
1028 | |
1029 | // Test assignment | |
1030 | fmt = RelativeDateTimeFormatter("es", status); | |
b331163b A |
1031 | RunTest(fmt, kSpanishNoQuantity, UPRV_LENGTHOF(kSpanishNoQuantity), "assignment operator"); |
1032 | ||
1033 | } | |
1034 | ||
1035 | void RelativeDateTimeFormatterTest::TestGetters() { | |
1036 | UErrorCode status = U_ZERO_ERROR; | |
1037 | RelativeDateTimeFormatter fmt( | |
1038 | "en", | |
1039 | NULL, | |
1040 | UDAT_STYLE_NARROW, | |
1041 | UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, | |
1042 | status); | |
1043 | if (U_FAILURE(status)) { | |
1044 | dataerrln("Failed call to RelativeDateTimeFormatter(\"en\", NULL, UDAT_STYLE_NARROW, UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, status);) : %s", u_errorName(status)); | |
1045 | return; | |
1046 | } | |
1047 | RelativeDateTimeFormatter fmt3(status); | |
57a6839d | 1048 | |
b331163b A |
1049 | // copy and assignment. |
1050 | RelativeDateTimeFormatter fmt2(fmt); | |
1051 | fmt3 = fmt2; | |
f3c0d7a5 | 1052 | assertEquals("style", (int32_t)UDAT_STYLE_NARROW, fmt3.getFormatStyle()); |
b331163b A |
1053 | assertEquals( |
1054 | "context", | |
f3c0d7a5 | 1055 | (int32_t)UDISPCTX_CAPITALIZATION_FOR_MIDDLE_OF_SENTENCE, |
b331163b A |
1056 | fmt3.getCapitalizationContext()); |
1057 | assertSuccess("", status); | |
57a6839d A |
1058 | } |
1059 | ||
1060 | void RelativeDateTimeFormatterTest::TestCombineDateAndTime() { | |
1061 | UErrorCode status = U_ZERO_ERROR; | |
1062 | RelativeDateTimeFormatter fmt("en", status); | |
1063 | if (U_FAILURE(status)) { | |
1064 | dataerrln("Failure creating format object - %s", u_errorName(status)); | |
1065 | return; | |
1066 | } | |
1067 | UnicodeString actual; | |
1068 | fmt.combineDateAndTime( | |
1069 | UnicodeString("yesterday"), | |
1070 | UnicodeString("3:50"), | |
1071 | actual, | |
1072 | status); | |
1073 | UnicodeString expected("yesterday, 3:50"); | |
1074 | if (expected != actual) { | |
1075 | errln("Expected "+expected+", got "+actual); | |
1076 | } | |
1077 | } | |
1078 | ||
b331163b A |
1079 | void RelativeDateTimeFormatterTest::TestBadDisplayContext() { |
1080 | UErrorCode status = U_ZERO_ERROR; | |
1081 | RelativeDateTimeFormatter fmt( | |
1082 | "en", NULL, UDAT_STYLE_LONG, UDISPCTX_STANDARD_NAMES, status); | |
1083 | if (status != U_ILLEGAL_ARGUMENT_ERROR) { | |
1084 | errln("Expected U_ILLEGAL_ARGUMENT_ERROR, got %s", u_errorName(status)); | |
1085 | } | |
1086 | } | |
1087 | ||
1088 | ||
57a6839d A |
1089 | |
1090 | void RelativeDateTimeFormatterTest::RunTest( | |
1091 | const Locale& locale, | |
1092 | const WithQuantityExpected* expectedResults, | |
1093 | int32_t expectedResultLength) { | |
1094 | UErrorCode status = U_ZERO_ERROR; | |
1095 | RelativeDateTimeFormatter fmt(locale, status); | |
1096 | if (U_FAILURE(status)) { | |
1097 | dataerrln("Unable to create format object - %s", u_errorName(status)); | |
1098 | return; | |
b331163b A |
1099 | } |
1100 | RunTest(fmt, expectedResults, expectedResultLength, locale.getName()); | |
1101 | } | |
1102 | ||
3d1f044b A |
1103 | void RelativeDateTimeFormatterTest::RunTest( |
1104 | const Locale& locale, | |
1105 | const WithQuantityExpectedRelativeDateTimeUnit* expectedResults, | |
1106 | int32_t expectedResultLength, | |
1107 | bool numeric) { | |
1108 | UErrorCode status = U_ZERO_ERROR; | |
1109 | RelativeDateTimeFormatter fmt(locale, status); | |
1110 | if (U_FAILURE(status)) { | |
1111 | dataerrln("Unable to create format object - %s", u_errorName(status)); | |
1112 | return; | |
1113 | } | |
1114 | RunTest(fmt, expectedResults, expectedResultLength, locale.getName(), numeric); | |
1115 | } | |
1116 | ||
1117 | ||
b331163b A |
1118 | void RelativeDateTimeFormatterTest::RunTest( |
1119 | const Locale& locale, | |
1120 | UDateRelativeDateTimeFormatterStyle style, | |
1121 | const WithQuantityExpected* expectedResults, | |
1122 | int32_t expectedResultLength) { | |
1123 | UErrorCode status = U_ZERO_ERROR; | |
1124 | RelativeDateTimeFormatter fmt( | |
1125 | locale, NULL, style, UDISPCTX_CAPITALIZATION_NONE, status); | |
1126 | if (U_FAILURE(status)) { | |
1127 | dataerrln("Unable to create format object - %s", u_errorName(status)); | |
1128 | return; | |
1129 | } | |
57a6839d A |
1130 | RunTest(fmt, expectedResults, expectedResultLength, locale.getName()); |
1131 | } | |
1132 | ||
1133 | void RelativeDateTimeFormatterTest::RunTest( | |
1134 | const Locale& locale, | |
1135 | const WithoutQuantityExpected* expectedResults, | |
1136 | int32_t expectedResultLength) { | |
1137 | UErrorCode status = U_ZERO_ERROR; | |
1138 | RelativeDateTimeFormatter fmt(locale, status); | |
1139 | if (U_FAILURE(status)) { | |
1140 | dataerrln("Unable to create format object - %s", u_errorName(status)); | |
1141 | return; | |
1142 | } | |
1143 | RunTest(fmt, expectedResults, expectedResultLength, locale.getName()); | |
1144 | } | |
1145 | ||
b331163b A |
1146 | void RelativeDateTimeFormatterTest::RunTest( |
1147 | const Locale& locale, | |
1148 | UDateRelativeDateTimeFormatterStyle style, | |
1149 | const WithoutQuantityExpected* expectedResults, | |
1150 | int32_t expectedResultLength) { | |
1151 | UErrorCode status = U_ZERO_ERROR; | |
1152 | RelativeDateTimeFormatter fmt( | |
1153 | locale, NULL, style, UDISPCTX_CAPITALIZATION_NONE, status); | |
1154 | if (U_FAILURE(status)) { | |
1155 | dataerrln("Unable to create format object - %s", u_errorName(status)); | |
1156 | return; | |
1157 | } | |
1158 | RunTest(fmt, expectedResults, expectedResultLength, locale.getName()); | |
1159 | } | |
1160 | ||
57a6839d A |
1161 | void RelativeDateTimeFormatterTest::RunTest( |
1162 | const RelativeDateTimeFormatter& fmt, | |
1163 | const WithQuantityExpected* expectedResults, | |
1164 | int32_t expectedResultLength, | |
1165 | const char *description) { | |
1166 | for (int32_t i = 0; i < expectedResultLength; ++i) { | |
1167 | CheckExpectedResult(fmt, expectedResults[i], description); | |
1168 | } | |
1169 | } | |
1170 | ||
3d1f044b A |
1171 | void RelativeDateTimeFormatterTest::RunTest( |
1172 | const RelativeDateTimeFormatter& fmt, | |
1173 | const WithQuantityExpectedRelativeDateTimeUnit* expectedResults, | |
1174 | int32_t expectedResultLength, | |
1175 | const char *description, | |
1176 | bool numeric) { | |
1177 | for (int32_t i = 0; i < expectedResultLength; ++i) { | |
1178 | CheckExpectedResult(fmt, expectedResults[i], description, numeric); | |
1179 | } | |
1180 | } | |
1181 | ||
57a6839d A |
1182 | void RelativeDateTimeFormatterTest::RunTest( |
1183 | const RelativeDateTimeFormatter& fmt, | |
1184 | const WithoutQuantityExpected* expectedResults, | |
1185 | int32_t expectedResultLength, | |
1186 | const char *description) { | |
1187 | for (int32_t i = 0; i < expectedResultLength; ++i) { | |
1188 | CheckExpectedResult(fmt, expectedResults[i], description); | |
1189 | } | |
1190 | } | |
1191 | ||
1192 | void RelativeDateTimeFormatterTest::CheckExpectedResult( | |
1193 | const RelativeDateTimeFormatter& fmt, | |
1194 | const WithQuantityExpected& expectedResult, | |
1195 | const char* description) { | |
1196 | UErrorCode status = U_ZERO_ERROR; | |
1197 | UnicodeString actual; | |
1198 | fmt.format(expectedResult.value, expectedResult.direction, expectedResult.unit, actual, status); | |
1199 | UnicodeString expected(expectedResult.expected, -1, US_INV); | |
1200 | expected = expected.unescape(); | |
1201 | char buffer[256]; | |
1202 | sprintf( | |
1203 | buffer, | |
1204 | "%s, %f, %s, %s", | |
1205 | description, | |
1206 | expectedResult.value, | |
1207 | DirectionStr(expectedResult.direction), | |
1208 | RelativeUnitStr(expectedResult.unit)); | |
1209 | if (actual != expected) { | |
1210 | errln(UnicodeString("Fail: Expected: ") + expected | |
1211 | + ", Got: " + actual | |
1212 | + ", For: " + buffer); | |
1213 | } | |
1214 | } | |
1215 | ||
3d1f044b A |
1216 | void RelativeDateTimeFormatterTest::CheckExpectedResult( |
1217 | const RelativeDateTimeFormatter& fmt, | |
1218 | const WithQuantityExpectedRelativeDateTimeUnit& expectedResult, | |
1219 | const char* description, | |
1220 | bool numeric) { | |
1221 | UErrorCode status = U_ZERO_ERROR; | |
1222 | UnicodeString actual; | |
1223 | if (numeric) { | |
1224 | fmt.formatNumeric(expectedResult.value, expectedResult.unit, actual, status); | |
1225 | } else { | |
1226 | fmt.format(expectedResult.value, expectedResult.unit, actual, status); | |
1227 | } | |
1228 | UnicodeString expected(expectedResult.expected, -1, US_INV); | |
1229 | expected = expected.unescape(); | |
1230 | char buffer[256]; | |
1231 | sprintf( | |
1232 | buffer, | |
1233 | "%s, %f, %s", | |
1234 | description, | |
1235 | expectedResult.value, | |
1236 | RelativeDateTimeUnitStr(expectedResult.unit)); | |
1237 | if (actual != expected) { | |
1238 | errln(UnicodeString("Fail: Expected: ") + expected | |
1239 | + ", Got: " + actual | |
1240 | + ", For: " + buffer); | |
1241 | } | |
1242 | } | |
1243 | ||
57a6839d A |
1244 | void RelativeDateTimeFormatterTest::CheckExpectedResult( |
1245 | const RelativeDateTimeFormatter& fmt, | |
1246 | const WithoutQuantityExpected& expectedResult, | |
1247 | const char* description) { | |
1248 | UErrorCode status = U_ZERO_ERROR; | |
1249 | UnicodeString actual; | |
1250 | fmt.format(expectedResult.direction, expectedResult.unit, actual, status); | |
1251 | UnicodeString expected(expectedResult.expected, -1, US_INV); | |
1252 | expected = expected.unescape(); | |
1253 | char buffer[256]; | |
1254 | sprintf( | |
1255 | buffer, | |
1256 | "%s, %s, %s", | |
1257 | description, | |
1258 | DirectionStr(expectedResult.direction), | |
1259 | AbsoluteUnitStr(expectedResult.unit)); | |
1260 | if (actual != expected) { | |
1261 | errln(UnicodeString("Fail: Expected: ") + expected | |
1262 | + ", Got: " + actual | |
1263 | + ", For: " + buffer); | |
1264 | } | |
1265 | } | |
1266 | ||
1267 | void RelativeDateTimeFormatterTest::VerifyIllegalArgument( | |
1268 | const RelativeDateTimeFormatter& fmt, | |
1269 | UDateDirection direction, | |
1270 | UDateRelativeUnit unit) { | |
1271 | UnicodeString appendTo; | |
1272 | UErrorCode status = U_ZERO_ERROR; | |
1273 | fmt.format(1.0, direction, unit, appendTo, status); | |
1274 | if (status != U_ILLEGAL_ARGUMENT_ERROR) { | |
1275 | errln("Expected U_ILLEGAL_ARGUMENT_ERROR, got %s", u_errorName(status)); | |
1276 | } | |
1277 | } | |
1278 | ||
1279 | void RelativeDateTimeFormatterTest::VerifyIllegalArgument( | |
1280 | const RelativeDateTimeFormatter& fmt, | |
1281 | UDateDirection direction, | |
1282 | UDateAbsoluteUnit unit) { | |
1283 | UnicodeString appendTo; | |
1284 | UErrorCode status = U_ZERO_ERROR; | |
1285 | fmt.format(direction, unit, appendTo, status); | |
1286 | if (status != U_ILLEGAL_ARGUMENT_ERROR) { | |
1287 | errln("Expected U_ILLEGAL_ARGUMENT_ERROR, got %s", u_errorName(status)); | |
1288 | } | |
1289 | } | |
1290 | ||
2ca993e8 A |
1291 | /* Add tests to check "sideways" data loading. */ |
1292 | void RelativeDateTimeFormatterTest::TestSidewaysDataLoading(void) { | |
1293 | UErrorCode status = U_ZERO_ERROR; | |
1294 | UnicodeString actual; | |
1295 | UnicodeString expected; | |
1296 | Locale enGbLocale("en_GB"); | |
1297 | ||
1298 | RelativeDateTimeFormatter fmt(enGbLocale, NULL, UDAT_STYLE_NARROW, | |
1299 | UDISPCTX_CAPITALIZATION_NONE, status); | |
1300 | if (U_FAILURE(status)) { | |
1301 | dataerrln("Unable to create RelativeDateTimeFormatter - %s", u_errorName(status)); | |
1302 | return; | |
1303 | } | |
1304 | ||
1305 | status = U_ZERO_ERROR; | |
1306 | actual = ""; | |
1307 | fmt.format(3.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_MONTHS, actual, status); | |
1308 | expected = "in 3 mo"; | |
1309 | assertEquals("narrow in 3 mo", expected, actual); | |
1310 | ||
1311 | fmt.format(3.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, actual.remove(), status); | |
1312 | expected = "3 days ago"; | |
1313 | assertEquals("3 days ago (positive 3.0): ", expected, actual); | |
1314 | ||
1315 | expected = "-3 days ago"; | |
1316 | fmt.format(-3.0, UDAT_DIRECTION_LAST, UDAT_RELATIVE_DAYS, actual.remove(), status); | |
1317 | assertEquals("3 days ago (negative 3.0): ", expected, actual); | |
1318 | ||
340931cb | 1319 | expected = "next yr"; |
2ca993e8 A |
1320 | fmt.format(UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_YEAR, actual.remove(), status); |
1321 | assertEquals("next year: ", expected, actual); | |
1322 | ||
1323 | // Testing the SHORT style | |
1324 | RelativeDateTimeFormatter fmtshort(enGbLocale, NULL, UDAT_STYLE_SHORT, | |
1325 | UDISPCTX_CAPITALIZATION_NONE, status); | |
1326 | expected = "now"; | |
1327 | fmtshort.format(0.0, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, actual.remove(), status); | |
1328 | ||
340931cb | 1329 | expected = "next yr"; |
2ca993e8 A |
1330 | fmt.format(UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_YEAR, actual.remove(), status); |
1331 | assertEquals("next year: ", expected, actual); | |
1332 | } | |
1333 | ||
3d1f044b A |
1334 | void RelativeDateTimeFormatterTest::TestFormatNumeric() { |
1335 | RunTest("en", kEnglishFormatNumeric, UPRV_LENGTHOF(kEnglishFormatNumeric), true); | |
1336 | } | |
1337 | ||
1338 | void RelativeDateTimeFormatterTest::TestFormat() { | |
1339 | RunTest("en", kEnglishFormat, UPRV_LENGTHOF(kEnglishFormat), false); | |
1340 | } | |
1341 | ||
1342 | void RelativeDateTimeFormatterTest::TestLocales() { | |
1343 | int32_t numLocales = 0; | |
1344 | const Locale *availableLocales = Locale::getAvailableLocales(numLocales); | |
1345 | std::vector<std::unique_ptr<RelativeDateTimeFormatter>> allFormatters; | |
1346 | for (int localeIdx=0; localeIdx<numLocales; localeIdx++) { | |
1347 | const Locale &loc = availableLocales[localeIdx]; | |
1348 | UErrorCode status = U_ZERO_ERROR; | |
1349 | std::unique_ptr<RelativeDateTimeFormatter> rdtf(new RelativeDateTimeFormatter(loc, status)); | |
1350 | allFormatters.push_back(std::move(rdtf)); | |
1351 | assertSuccess(loc.getName(), status); | |
1352 | } | |
1353 | } | |
1354 | ||
1355 | void RelativeDateTimeFormatterTest::TestFields() { | |
1356 | IcuTestErrorCode status(*this, "TestFields"); | |
1357 | ||
1358 | RelativeDateTimeFormatter fmt("en-US", status); | |
1359 | ||
1360 | { | |
1361 | const char16_t* message = u"automatic absolute unit"; | |
1362 | FormattedRelativeDateTime fv = fmt.formatToValue(1, UDAT_REL_UNIT_DAY, status); | |
1363 | const char16_t* expectedString = u"tomorrow"; | |
1364 | static const UFieldPositionWithCategory expectedFieldPositions[] = { | |
1365 | {UFIELD_CATEGORY_RELATIVE_DATETIME, UDAT_REL_LITERAL_FIELD, 0, 8}}; | |
1366 | checkMixedFormattedValue( | |
1367 | message, | |
1368 | fv, | |
1369 | expectedString, | |
1370 | expectedFieldPositions, | |
1371 | UPRV_LENGTHOF(expectedFieldPositions)); | |
1372 | } | |
1373 | { | |
1374 | const char16_t* message = u"automatic numeric unit"; | |
1375 | FormattedRelativeDateTime fv = fmt.formatToValue(3, UDAT_REL_UNIT_DAY, status); | |
1376 | const char16_t* expectedString = u"in 3 days"; | |
1377 | static const UFieldPositionWithCategory expectedFieldPositions[] = { | |
1378 | {UFIELD_CATEGORY_RELATIVE_DATETIME, UDAT_REL_LITERAL_FIELD, 0, 2}, | |
1379 | {UFIELD_CATEGORY_NUMBER, UNUM_INTEGER_FIELD, 3, 4}, | |
1380 | {UFIELD_CATEGORY_RELATIVE_DATETIME, UDAT_REL_NUMERIC_FIELD, 3, 4}, | |
1381 | {UFIELD_CATEGORY_RELATIVE_DATETIME, UDAT_REL_LITERAL_FIELD, 5, 9}}; | |
1382 | checkMixedFormattedValue( | |
1383 | message, | |
1384 | fv, | |
1385 | expectedString, | |
1386 | expectedFieldPositions, | |
1387 | UPRV_LENGTHOF(expectedFieldPositions)); | |
1388 | } | |
1389 | { | |
1390 | const char16_t* message = u"manual absolute unit"; | |
1391 | FormattedRelativeDateTime fv = fmt.formatToValue(UDAT_DIRECTION_NEXT, UDAT_ABSOLUTE_MONDAY, status); | |
1392 | const char16_t* expectedString = u"next Monday"; | |
1393 | static const UFieldPositionWithCategory expectedFieldPositions[] = { | |
1394 | {UFIELD_CATEGORY_RELATIVE_DATETIME, UDAT_REL_LITERAL_FIELD, 0, 11}}; | |
1395 | checkMixedFormattedValue( | |
1396 | message, | |
1397 | fv, | |
1398 | expectedString, | |
1399 | expectedFieldPositions, | |
1400 | UPRV_LENGTHOF(expectedFieldPositions)); | |
1401 | } | |
1402 | { | |
1403 | const char16_t* message = u"manual numeric unit"; | |
1404 | FormattedRelativeDateTime fv = fmt.formatNumericToValue(1.5, UDAT_REL_UNIT_WEEK, status); | |
1405 | const char16_t* expectedString = u"in 1.5 weeks"; | |
1406 | static const UFieldPositionWithCategory expectedFieldPositions[] = { | |
1407 | {UFIELD_CATEGORY_RELATIVE_DATETIME, UDAT_REL_LITERAL_FIELD, 0, 2}, | |
1408 | {UFIELD_CATEGORY_NUMBER, UNUM_INTEGER_FIELD, 3, 4}, | |
1409 | {UFIELD_CATEGORY_NUMBER, UNUM_DECIMAL_SEPARATOR_FIELD, 4, 5}, | |
1410 | {UFIELD_CATEGORY_NUMBER, UNUM_FRACTION_FIELD, 5, 6}, | |
1411 | {UFIELD_CATEGORY_RELATIVE_DATETIME, UDAT_REL_NUMERIC_FIELD, 3, 6}, | |
1412 | {UFIELD_CATEGORY_RELATIVE_DATETIME, UDAT_REL_LITERAL_FIELD, 7, 12}}; | |
1413 | checkMixedFormattedValue( | |
1414 | message, | |
1415 | fv, | |
1416 | expectedString, | |
1417 | expectedFieldPositions, | |
1418 | UPRV_LENGTHOF(expectedFieldPositions)); | |
1419 | } | |
1420 | { | |
1421 | const char16_t* message = u"manual numeric resolved unit"; | |
1422 | FormattedRelativeDateTime fv = fmt.formatToValue(12, UDAT_DIRECTION_LAST, UDAT_RELATIVE_HOURS, status); | |
1423 | const char16_t* expectedString = u"12 hours ago"; | |
1424 | static const UFieldPositionWithCategory expectedFieldPositions[] = { | |
1425 | {UFIELD_CATEGORY_NUMBER, UNUM_INTEGER_FIELD, 0, 2}, | |
1426 | {UFIELD_CATEGORY_RELATIVE_DATETIME, UDAT_REL_NUMERIC_FIELD, 0, 2}, | |
1427 | {UFIELD_CATEGORY_RELATIVE_DATETIME, UDAT_REL_LITERAL_FIELD, 3, 12}}; | |
1428 | checkMixedFormattedValue( | |
1429 | message, | |
1430 | fv, | |
1431 | expectedString, | |
1432 | expectedFieldPositions, | |
1433 | UPRV_LENGTHOF(expectedFieldPositions)); | |
1434 | } | |
1435 | ||
1436 | // Test when the number field is at the end | |
1437 | fmt = RelativeDateTimeFormatter("sw", status); | |
1438 | { | |
1439 | const char16_t* message = u"numeric field at end"; | |
1440 | FormattedRelativeDateTime fv = fmt.formatToValue(12, UDAT_REL_UNIT_HOUR, status); | |
1441 | const char16_t* expectedString = u"baada ya saa 12"; | |
1442 | static const UFieldPositionWithCategory expectedFieldPositions[] = { | |
1443 | {UFIELD_CATEGORY_RELATIVE_DATETIME, UDAT_REL_LITERAL_FIELD, 0, 12}, | |
1444 | {UFIELD_CATEGORY_NUMBER, UNUM_INTEGER_FIELD, 13, 15}, | |
1445 | {UFIELD_CATEGORY_RELATIVE_DATETIME, UDAT_REL_NUMERIC_FIELD, 13, 15}}; | |
1446 | checkMixedFormattedValue( | |
1447 | message, | |
1448 | fv, | |
1449 | expectedString, | |
1450 | expectedFieldPositions, | |
1451 | UPRV_LENGTHOF(expectedFieldPositions)); | |
1452 | } | |
1453 | } | |
1454 | ||
1455 | void RelativeDateTimeFormatterTest::TestRBNF() { | |
1456 | IcuTestErrorCode status(*this, "TestRBNF"); | |
1457 | ||
1458 | LocalPointer<RuleBasedNumberFormat> rbnf(new RuleBasedNumberFormat(URBNF_SPELLOUT, "en-us", status)); | |
1459 | if (status.errIfFailureAndReset()) { return; } | |
1460 | RelativeDateTimeFormatter fmt("en-us", rbnf.orphan(), status); | |
1461 | UnicodeString result; | |
1462 | assertEquals("format (direction)", "in five seconds", | |
1463 | fmt.format(5, UDAT_DIRECTION_NEXT, UDAT_RELATIVE_SECONDS, result, status)); | |
1464 | assertEquals("formatNumeric", "one week ago", | |
1465 | fmt.formatNumeric(-1, UDAT_REL_UNIT_WEEK, result.remove(), status)); | |
1466 | assertEquals("format (absolute)", "yesterday", | |
1467 | fmt.format(UDAT_DIRECTION_LAST, UDAT_ABSOLUTE_DAY, result.remove(), status)); | |
1468 | assertEquals("format (relative)", "in forty-two months", | |
1469 | fmt.format(42, UDAT_REL_UNIT_MONTH, result.remove(), status)); | |
1470 | ||
1471 | { | |
1472 | const char16_t* message = u"formatToValue (relative)"; | |
1473 | FormattedRelativeDateTime fv = fmt.formatToValue(-100, UDAT_REL_UNIT_YEAR, status); | |
1474 | const char16_t* expectedString = u"one hundred years ago"; | |
1475 | static const UFieldPositionWithCategory expectedFieldPositions[] = { | |
1476 | {UFIELD_CATEGORY_RELATIVE_DATETIME, UDAT_REL_NUMERIC_FIELD, 0, 11}, | |
1477 | {UFIELD_CATEGORY_RELATIVE_DATETIME, UDAT_REL_LITERAL_FIELD, 12, 21}}; | |
1478 | checkMixedFormattedValue( | |
1479 | message, | |
1480 | fv, | |
1481 | expectedString, | |
1482 | expectedFieldPositions, | |
1483 | UPRV_LENGTHOF(expectedFieldPositions)); | |
1484 | } | |
1485 | } | |
1486 | ||
57a6839d A |
1487 | static const char *kLast2 = "Last_2"; |
1488 | static const char *kLast = "Last"; | |
1489 | static const char *kThis = "This"; | |
1490 | static const char *kNext = "Next"; | |
1491 | static const char *kNext2 = "Next_2"; | |
1492 | static const char *kPlain = "Plain"; | |
1493 | ||
1494 | static const char *kSeconds = "Seconds"; | |
1495 | static const char *kMinutes = "Minutes"; | |
1496 | static const char *kHours = "Hours"; | |
1497 | static const char *kDays = "Days"; | |
1498 | static const char *kWeeks = "Weeks"; | |
1499 | static const char *kMonths = "Months"; | |
3d1f044b | 1500 | static const char *kQuarters = "Quarters"; |
57a6839d | 1501 | static const char *kYears = "Years"; |
3d1f044b A |
1502 | static const char *kSundays = "Sundays"; |
1503 | static const char *kMondays = "Mondays"; | |
1504 | static const char *kTuesdays = "Tuesdays"; | |
1505 | static const char *kWednesdays = "Wednesdays"; | |
1506 | static const char *kThursdays = "Thursdays"; | |
1507 | static const char *kFridays = "Fridays"; | |
1508 | static const char *kSaturdays = "Saturdays"; | |
57a6839d A |
1509 | |
1510 | static const char *kSunday = "Sunday"; | |
1511 | static const char *kMonday = "Monday"; | |
1512 | static const char *kTuesday = "Tuesday"; | |
1513 | static const char *kWednesday = "Wednesday"; | |
1514 | static const char *kThursday = "Thursday"; | |
1515 | static const char *kFriday = "Friday"; | |
1516 | static const char *kSaturday = "Saturday"; | |
1517 | static const char *kDay = "Day"; | |
1518 | static const char *kWeek = "Week"; | |
1519 | static const char *kMonth = "Month"; | |
3d1f044b | 1520 | static const char *kQuarter = "Quarter"; |
57a6839d A |
1521 | static const char *kYear = "Year"; |
1522 | static const char *kNow = "Now"; | |
1523 | ||
1524 | static const char *kUndefined = "Undefined"; | |
1525 | ||
1526 | static const char *DirectionStr( | |
1527 | UDateDirection direction) { | |
1528 | switch (direction) { | |
1529 | case UDAT_DIRECTION_LAST_2: | |
1530 | return kLast2; | |
1531 | case UDAT_DIRECTION_LAST: | |
1532 | return kLast; | |
1533 | case UDAT_DIRECTION_THIS: | |
1534 | return kThis; | |
1535 | case UDAT_DIRECTION_NEXT: | |
1536 | return kNext; | |
1537 | case UDAT_DIRECTION_NEXT_2: | |
1538 | return kNext2; | |
1539 | case UDAT_DIRECTION_PLAIN: | |
1540 | return kPlain; | |
1541 | default: | |
1542 | return kUndefined; | |
1543 | } | |
1544 | return kUndefined; | |
1545 | } | |
1546 | ||
1547 | static const char *RelativeUnitStr( | |
1548 | UDateRelativeUnit unit) { | |
1549 | switch (unit) { | |
1550 | case UDAT_RELATIVE_SECONDS: | |
1551 | return kSeconds; | |
1552 | case UDAT_RELATIVE_MINUTES: | |
1553 | return kMinutes; | |
1554 | case UDAT_RELATIVE_HOURS: | |
1555 | return kHours; | |
1556 | case UDAT_RELATIVE_DAYS: | |
1557 | return kDays; | |
1558 | case UDAT_RELATIVE_WEEKS: | |
1559 | return kWeeks; | |
1560 | case UDAT_RELATIVE_MONTHS: | |
1561 | return kMonths; | |
1562 | case UDAT_RELATIVE_YEARS: | |
1563 | return kYears; | |
1564 | default: | |
1565 | return kUndefined; | |
1566 | } | |
1567 | return kUndefined; | |
1568 | } | |
1569 | ||
3d1f044b A |
1570 | static const char *RelativeDateTimeUnitStr( |
1571 | URelativeDateTimeUnit unit) { | |
1572 | switch (unit) { | |
1573 | case UDAT_REL_UNIT_SECOND: | |
1574 | return kSeconds; | |
1575 | case UDAT_REL_UNIT_MINUTE: | |
1576 | return kMinutes; | |
1577 | case UDAT_REL_UNIT_HOUR: | |
1578 | return kHours; | |
1579 | case UDAT_REL_UNIT_DAY: | |
1580 | return kDays; | |
1581 | case UDAT_REL_UNIT_WEEK: | |
1582 | return kWeeks; | |
1583 | case UDAT_REL_UNIT_MONTH: | |
1584 | return kMonths; | |
1585 | case UDAT_REL_UNIT_QUARTER: | |
1586 | return kQuarters; | |
1587 | case UDAT_REL_UNIT_YEAR: | |
1588 | return kYears; | |
1589 | case UDAT_REL_UNIT_SUNDAY: | |
1590 | return kSundays; | |
1591 | case UDAT_REL_UNIT_MONDAY: | |
1592 | return kMondays; | |
1593 | case UDAT_REL_UNIT_TUESDAY: | |
1594 | return kTuesdays; | |
1595 | case UDAT_REL_UNIT_WEDNESDAY: | |
1596 | return kWednesdays; | |
1597 | case UDAT_REL_UNIT_THURSDAY: | |
1598 | return kThursdays; | |
1599 | case UDAT_REL_UNIT_FRIDAY: | |
1600 | return kFridays; | |
1601 | case UDAT_REL_UNIT_SATURDAY: | |
1602 | return kSaturdays; | |
1603 | default: | |
1604 | return kUndefined; | |
1605 | } | |
1606 | return kUndefined; | |
1607 | } | |
1608 | ||
57a6839d A |
1609 | static const char *AbsoluteUnitStr( |
1610 | UDateAbsoluteUnit unit) { | |
1611 | switch (unit) { | |
1612 | case UDAT_ABSOLUTE_SUNDAY: | |
1613 | return kSunday; | |
1614 | case UDAT_ABSOLUTE_MONDAY: | |
1615 | return kMonday; | |
1616 | case UDAT_ABSOLUTE_TUESDAY: | |
1617 | return kTuesday; | |
1618 | case UDAT_ABSOLUTE_WEDNESDAY: | |
1619 | return kWednesday; | |
1620 | case UDAT_ABSOLUTE_THURSDAY: | |
1621 | return kThursday; | |
1622 | case UDAT_ABSOLUTE_FRIDAY: | |
1623 | return kFriday; | |
1624 | case UDAT_ABSOLUTE_SATURDAY: | |
1625 | return kSaturday; | |
1626 | case UDAT_ABSOLUTE_DAY: | |
1627 | return kDay; | |
1628 | case UDAT_ABSOLUTE_WEEK: | |
1629 | return kWeek; | |
1630 | case UDAT_ABSOLUTE_MONTH: | |
1631 | return kMonth; | |
3d1f044b A |
1632 | case UDAT_ABSOLUTE_QUARTER: |
1633 | return kQuarter; | |
57a6839d A |
1634 | case UDAT_ABSOLUTE_YEAR: |
1635 | return kYear; | |
1636 | case UDAT_ABSOLUTE_NOW: | |
1637 | return kNow; | |
1638 | default: | |
1639 | return kUndefined; | |
1640 | } | |
1641 | return kUndefined; | |
1642 | } | |
1643 | ||
1644 | extern IntlTest *createRelativeDateTimeFormatterTest() { | |
1645 | return new RelativeDateTimeFormatterTest(); | |
1646 | } | |
1647 | ||
1648 | #endif |