]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | /******************************************************************** |
2 | * COPYRIGHT: | |
3 | * Copyright (c) 1997-2003, International Business Machines Corporation and | |
4 | * others. All Rights Reserved. | |
5 | ********************************************************************/ | |
6 | /******************************************************************************** | |
7 | * | |
8 | * File CCALTST.C | |
9 | * | |
10 | * Modification History: | |
11 | * Name Description | |
12 | * Madhu Katragadda Creation | |
13 | *********************************************************************************/ | |
14 | ||
15 | /* C API AND FUNCTIONALITY TEST FOR CALENDAR (ucol.h)*/ | |
16 | ||
17 | #include "unicode/utypes.h" | |
18 | ||
19 | #if !UCONFIG_NO_FORMATTING | |
20 | ||
21 | #include <stdlib.h> | |
22 | ||
23 | #include "unicode/uloc.h" | |
24 | #include "unicode/ucal.h" | |
25 | #include "unicode/udat.h" | |
26 | #include "unicode/ustring.h" | |
27 | #include "cintltst.h" | |
28 | #include "ccaltst.h" | |
29 | #include "cformtst.h" | |
30 | ||
31 | void addCalTest(TestNode** root); | |
32 | ||
33 | void addCalTest(TestNode** root) | |
34 | { | |
35 | ||
36 | addTest(root, &TestCalendar, "tsformat/ccaltst/TestCalendar"); | |
37 | addTest(root, &TestGetSetDateAPI, "tsformat/ccaltst/TestGetSetDateAPI"); | |
38 | addTest(root, &TestFieldGetSet, "tsformat/ccaltst/TestFieldGetSet"); | |
39 | addTest(root, &TestAddRollExtensive, "tsformat/ccaltst/TestAddRollExtensive"); | |
40 | addTest(root, &TestGetLimits, "tsformat/ccaltst/TestGetLimits"); | |
41 | addTest(root, &TestDOWProgression, "tsformat/ccaltst/TestDOWProgression"); | |
42 | addTest(root, &TestGMTvsLocal, "tsformat/ccaltst/TestGMTvsLocal"); | |
43 | ||
44 | } | |
45 | ||
46 | /* "GMT" */ | |
47 | static const UChar fgGMTID [] = { 0x0047, 0x004d, 0x0054, 0x0000 }; | |
48 | ||
49 | /* "PST" */ | |
50 | static const UChar PST[] = {0x50, 0x53, 0x54, 0x00}; /* "PST" */ | |
51 | ||
52 | static const UChar EUROPE_PARIS[] = {0x45, 0x75, 0x72, 0x6F, 0x70, 0x65, 0x2F, 0x50, 0x61, 0x72, 0x69, 0x73, 0x00}; /* "Europe/Paris" */ | |
53 | ||
54 | static void TestCalendar() | |
55 | { | |
56 | UCalendar *caldef = 0, *caldef2 = 0, *calfr = 0, *calit = 0; | |
57 | UEnumeration* uenum = NULL; | |
374ca955 | 58 | int32_t count, count2, i,j; |
b75a7d8f A |
59 | UChar *tzID = 0; |
60 | UChar *tzdname = 0; | |
61 | UErrorCode status = U_ZERO_ERROR; | |
62 | UDate now; | |
63 | UDateFormat *datdef = 0; | |
64 | UChar *result = 0; | |
65 | int32_t resultlength, resultlengthneeded; | |
66 | char tempMsgBuf[256]; | |
67 | UChar zone1[32], zone2[32]; | |
68 | ||
374ca955 | 69 | #ifdef U_USE_UCAL_OBSOLETE_2_8 |
b75a7d8f | 70 | /*Testing countAvailableTimeZones*/ |
374ca955 | 71 | int32_t offset=0; |
b75a7d8f A |
72 | log_verbose("\nTesting ucal_countAvailableTZIDs\n"); |
73 | count=ucal_countAvailableTZIDs(offset); | |
74 | log_verbose("The number of timezone id's present with offset 0 are %d:\n", count); | |
75 | if(count < 5) /* Don't hard code an exact == test here! */ | |
76 | log_err("FAIL: error in the ucal_countAvailableTZIDs - got %d expected at least 5 total\n", count); | |
77 | ||
78 | /*Testing getAvailableTZIDs*/ | |
79 | log_verbose("\nTesting ucal_getAvailableTZIDs"); | |
80 | for(i=0;i<count;i++){ | |
81 | ucal_getAvailableTZIDs(offset, i, &status); | |
82 | if(U_FAILURE(status)){ | |
83 | log_err("FAIL: ucal_getAvailableTZIDs returned %s\n", u_errorName(status)); | |
84 | } | |
85 | log_verbose("%s\n", u_austrcpy(tempMsgBuf, ucal_getAvailableTZIDs(offset, i, &status))); | |
86 | } | |
87 | /*get Illegal TZID where index >= count*/ | |
88 | ucal_getAvailableTZIDs(offset, i, &status); | |
89 | if(status != U_INDEX_OUTOFBOUNDS_ERROR){ | |
90 | log_err("FAIL:for TZID index >= count Expected INDEX_OUTOFBOUNDS_ERROR Got %s\n", u_errorName(status)); | |
91 | } | |
92 | status=U_ZERO_ERROR; | |
374ca955 | 93 | #endif |
b75a7d8f A |
94 | |
95 | /*Test ucal_openTimeZones & ucal_openCountryTimeZones*/ | |
96 | for (j=0; j<2; ++j) { | |
97 | const char* api = (j==0) ? "ucal_openTimeZones()" : | |
98 | "ucal_openCountryTimeZones(US)"; | |
99 | uenum = (j==0) ? ucal_openTimeZones(&status) : | |
100 | ucal_openCountryTimeZones("US", &status); | |
101 | if (U_FAILURE(status)) { | |
102 | log_err("FAIL: %s failed with %s", api, | |
103 | u_errorName(status)); | |
104 | } else { | |
105 | const char* id; | |
106 | int32_t len; | |
107 | count = uenum_count(uenum, &status); | |
108 | log_verbose("%s returned %d timezone id's:\n", api, count); | |
109 | if (count < 5) { /* Don't hard code an exact == test here! */ | |
110 | log_err("FAIL: in %s, got %d, expected at least 5\n", api, count); | |
111 | } | |
112 | uenum_reset(uenum, &status); | |
113 | if (U_FAILURE(status)){ | |
114 | log_err("FAIL: uenum_reset for %s returned %s\n", | |
115 | api, u_errorName(status)); | |
116 | } | |
117 | for (i=0; i<count; i++) { | |
118 | id = uenum_next(uenum, &len, &status); | |
119 | if (U_FAILURE(status)){ | |
120 | log_err("FAIL: uenum_next for %s returned %s\n", | |
121 | api, u_errorName(status)); | |
122 | } else { | |
123 | log_verbose("%s\n", id); | |
124 | } | |
125 | } | |
126 | /* Next one should be NULL */ | |
127 | id = uenum_next(uenum, &len, &status); | |
128 | if (id != NULL) { | |
129 | log_err("FAIL: uenum_next for %s returned %s, expected NULL\n", | |
130 | api, id); | |
131 | } | |
132 | } | |
133 | uenum_close(uenum); | |
134 | } | |
135 | ||
136 | /*Test ucal_getDSTSavings*/ | |
137 | status = U_ZERO_ERROR; | |
138 | i = ucal_getDSTSavings(fgGMTID, &status); | |
139 | if (U_FAILURE(status)) { | |
140 | log_err("FAIL: ucal_getDSTSavings(GMT) => %s\n", | |
141 | u_errorName(status)); | |
142 | } else if (i != 0) { | |
143 | log_err("FAIL: ucal_getDSTSavings(GMT) => %d, expect 0\n", i); | |
144 | } | |
145 | i = ucal_getDSTSavings(PST, &status); | |
146 | if (U_FAILURE(status)) { | |
147 | log_err("FAIL: ucal_getDSTSavings(PST) => %s\n", | |
148 | u_errorName(status)); | |
149 | } else if (i != 1*60*60*1000) { | |
150 | log_err("FAIL: ucal_getDSTSavings(PST) => %d, expect %d\n", i, 1*60*60*1000); | |
151 | } | |
152 | ||
153 | /*Test ucal_set/getDefaultTimeZone*/ | |
154 | status = U_ZERO_ERROR; | |
155 | i = ucal_getDefaultTimeZone(zone1, sizeof(zone1)/sizeof(zone1[0]), &status); | |
156 | if (U_FAILURE(status)) { | |
157 | log_err("FAIL: ucal_getDefaultTimeZone() => %s\n", | |
158 | u_errorName(status)); | |
159 | } else { | |
160 | ucal_setDefaultTimeZone(EUROPE_PARIS, &status); | |
161 | if (U_FAILURE(status)) { | |
162 | log_err("FAIL: ucal_setDefaultTimeZone(Europe/Paris) => %s\n", | |
163 | u_errorName(status)); | |
164 | } else { | |
165 | i = ucal_getDefaultTimeZone(zone2, sizeof(zone2)/sizeof(zone2[0]), &status); | |
166 | if (U_FAILURE(status)) { | |
167 | log_err("FAIL: ucal_getDefaultTimeZone() => %s\n", | |
168 | u_errorName(status)); | |
169 | } else { | |
170 | if (u_strcmp(zone2, EUROPE_PARIS) != 0) { | |
171 | log_err("FAIL: ucal_getDefaultTimeZone() did not return Europe/Paris\n"); | |
172 | } | |
173 | } | |
174 | } | |
175 | status = U_ZERO_ERROR; | |
176 | ucal_setDefaultTimeZone(zone1, &status); | |
177 | } | |
178 | ||
179 | /*Testing the ucal_open() function*/ | |
180 | log_verbose("\nTesting the ucal_open()\n"); | |
181 | tzID=(UChar*)malloc(sizeof(UChar) * 4); | |
182 | u_uastrcpy(tzID, "PST"); | |
183 | caldef=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status); | |
184 | if(U_FAILURE(status)){ | |
185 | log_err("FAIL: error in ucal_open caldef : %s\n", u_errorName(status)); | |
186 | } | |
187 | ||
188 | caldef2=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status); | |
189 | if(U_FAILURE(status)){ | |
190 | log_err("FAIL: error in ucal_open caldef : %s\n", u_errorName(status)); | |
191 | } | |
192 | u_strcpy(tzID, fgGMTID); | |
193 | calfr=ucal_open(tzID, u_strlen(tzID), "fr_FR", UCAL_TRADITIONAL, &status); | |
194 | if(U_FAILURE(status)){ | |
195 | log_err("FAIL: error in ucal_open calfr : %s\n", u_errorName(status)); | |
196 | } | |
197 | calit=ucal_open(tzID, u_strlen(tzID), "it_IT", UCAL_TRADITIONAL, &status); | |
198 | if(U_FAILURE(status)) { | |
199 | log_err("FAIL: error in ucal_open calit : %s\n", u_errorName(status)); | |
200 | } | |
201 | ||
202 | ||
203 | /*Testing udat_getAvailable() and udat_countAvailable()*/ | |
204 | log_verbose("\nTesting getAvailableLocales and countAvailable()\n"); | |
205 | count=ucal_countAvailable(); | |
206 | /* use something sensible w/o hardcoding the count */ | |
207 | if(count > 0) { | |
208 | log_verbose("PASS: ucal_countAvailable() works fine\n"); | |
209 | log_verbose("The no: of locales for which calendars are avilable are %d\n", count); | |
210 | } else { | |
211 | log_data_err("FAIL: Error in countAvailable()\n"); | |
212 | } | |
213 | ||
214 | for(i=0;i<count;i++) { | |
215 | log_verbose("%s\n", ucal_getAvailable(i)); | |
216 | } | |
217 | ||
218 | ||
219 | /*Testing the equality between calendar's*/ | |
220 | log_verbose("\nTesting ucal_equivalentTo()\n"); | |
221 | if(caldef && caldef2 && calfr && calit) { | |
222 | if(ucal_equivalentTo(caldef, caldef2) == FALSE || ucal_equivalentTo(caldef, calfr)== TRUE || | |
223 | ucal_equivalentTo(caldef, calit)== TRUE) { | |
224 | log_err("FAIL: Error. equivalentTo test failed\n"); | |
225 | } else { | |
226 | log_verbose("PASS: equivalentTo test passed\n"); | |
227 | } | |
228 | } | |
229 | ||
230 | ||
231 | /*Testing the current time and date using ucal_getnow()*/ | |
232 | log_verbose("\nTesting the ucal_getNow function to check if it is fetching tbe current time\n"); | |
233 | now=ucal_getNow(); | |
234 | /* open the date format and format the date to check the output */ | |
235 | datdef=udat_open(UDAT_FULL,UDAT_FULL ,NULL, NULL, 0,NULL,0,&status); | |
236 | if(U_FAILURE(status)){ | |
237 | log_err("FAIL: error in creating the dateformat : %s\n", u_errorName(status)); | |
238 | return; | |
239 | } | |
240 | log_verbose("PASS: The current date and time fetched is %s\n", u_austrcpy(tempMsgBuf, myDateFormat(datdef, now)) ); | |
241 | ||
242 | ||
243 | /*Testing the TimeZoneDisplayName */ | |
244 | log_verbose("\nTesting the fetching of time zone display name\n"); | |
245 | /*for the US locale */ | |
246 | resultlength=0; | |
247 | resultlengthneeded=ucal_getTimeZoneDisplayName(caldef, UCAL_DST, "en_US", NULL, resultlength, &status); | |
248 | ||
249 | if(status==U_BUFFER_OVERFLOW_ERROR) | |
250 | { | |
251 | status=U_ZERO_ERROR; | |
252 | resultlength=resultlengthneeded+1; | |
253 | result=(UChar*)malloc(sizeof(UChar) * resultlength); | |
254 | ucal_getTimeZoneDisplayName(caldef, UCAL_DST, "en_US", result, resultlength, &status); | |
255 | } | |
256 | if(U_FAILURE(status)) { | |
257 | log_err("FAIL: Error in getting the timezone display name : %s\n", u_errorName(status)); | |
258 | } | |
259 | else{ | |
260 | log_verbose("PASS: getting the time zone display name successful : %s, %d needed \n", | |
261 | u_errorName(status), resultlengthneeded); | |
262 | } | |
263 | ||
264 | ||
265 | #define expectPDT "Pacific Daylight Time" | |
266 | ||
267 | tzdname=(UChar*)malloc(sizeof(UChar) * (sizeof(expectPDT)+1)); | |
268 | u_uastrcpy(tzdname, expectPDT); | |
269 | if(u_strcmp(tzdname, result)==0){ | |
270 | log_verbose("PASS: got the correct time zone display name %s\n", u_austrcpy(tempMsgBuf, result) ); | |
271 | } | |
272 | else{ | |
273 | log_err("FAIL: got the wrong time zone(DST) display name %s, wanted %s\n", austrdup(result) , expectPDT); | |
274 | } | |
275 | ||
276 | ucal_getTimeZoneDisplayName(caldef, UCAL_SHORT_DST, "en_US", result, resultlength, &status); | |
277 | u_uastrcpy(tzdname, "PDT"); | |
278 | if(u_strcmp(tzdname, result) != 0){ | |
279 | log_err("FAIL: got the wrong time zone(SHORT_DST) display name %s, wanted %s\n", austrdup(result), austrdup(tzdname)); | |
280 | } | |
281 | ||
282 | ucal_getTimeZoneDisplayName(caldef, UCAL_STANDARD, "en_US", result, resultlength, &status); | |
283 | u_uastrcpy(tzdname, "Pacific Standard Time"); | |
284 | if(u_strcmp(tzdname, result) != 0){ | |
285 | log_err("FAIL: got the wrong time zone(STANDARD) display name %s, wanted %s\n", austrdup(result), austrdup(tzdname)); | |
286 | } | |
287 | ||
288 | ucal_getTimeZoneDisplayName(caldef, UCAL_SHORT_STANDARD, "en_US", result, resultlength, &status); | |
289 | u_uastrcpy(tzdname, "PST"); | |
290 | if(u_strcmp(tzdname, result) != 0){ | |
291 | log_err("FAIL: got the wrong time zone(SHORT_STANDARD) display name %s, wanted %s\n", austrdup(result), austrdup(tzdname)); | |
292 | } | |
293 | ||
294 | ||
295 | /*testing the setAttributes and getAttributes of a UCalendar*/ | |
296 | log_verbose("\nTesting the getAttributes and set Attributes\n"); | |
297 | count=ucal_getAttribute(calit, UCAL_LENIENT); | |
298 | count2=ucal_getAttribute(calfr, UCAL_LENIENT); | |
299 | ucal_setAttribute(calit, UCAL_LENIENT, 0); | |
300 | ucal_setAttribute(caldef, UCAL_LENIENT, count2); | |
301 | if( ucal_getAttribute(calit, UCAL_LENIENT) !=0 || | |
302 | ucal_getAttribute(calfr, UCAL_LENIENT)!=ucal_getAttribute(caldef, UCAL_LENIENT) ) | |
303 | log_err("FAIL: there is an error in getAttributes or setAttributes\n"); | |
304 | else | |
305 | log_verbose("PASS: attribute set and got successfully\n"); | |
306 | /*set it back to orginal value */ | |
307 | log_verbose("Setting it back to normal\n"); | |
308 | ucal_setAttribute(calit, UCAL_LENIENT, count); | |
309 | if(ucal_getAttribute(calit, UCAL_LENIENT)!=count) | |
310 | log_err("FAIL: Error in setting the attribute back to normal\n"); | |
311 | ||
312 | /*setting the first day of the week to other values */ | |
313 | count=ucal_getAttribute(calit, UCAL_FIRST_DAY_OF_WEEK); | |
314 | for (i=1; i<=7; ++i) { | |
315 | ucal_setAttribute(calit, UCAL_FIRST_DAY_OF_WEEK,i); | |
316 | if (ucal_getAttribute(calit, UCAL_FIRST_DAY_OF_WEEK) != i) | |
317 | log_err("FAIL: set/getFirstDayOfWeek failed\n"); | |
318 | } | |
319 | /*get bogus Attribute*/ | |
320 | count=ucal_getAttribute(calit, (UCalendarAttribute)99); /* BOGUS_ATTRIBUTE */ | |
321 | if(count != -1){ | |
322 | log_err("FAIL: get/bogus attribute should return -1\n"); | |
323 | } | |
324 | ||
325 | /*set it back to normal */ | |
326 | ucal_setAttribute(calit, UCAL_FIRST_DAY_OF_WEEK,count); | |
327 | /*setting minimal days of the week to other values */ | |
328 | count=ucal_getAttribute(calit, UCAL_MINIMAL_DAYS_IN_FIRST_WEEK); | |
329 | for (i=1; i<=7; ++i) { | |
330 | ucal_setAttribute(calit, UCAL_MINIMAL_DAYS_IN_FIRST_WEEK,i); | |
331 | if (ucal_getAttribute(calit, UCAL_MINIMAL_DAYS_IN_FIRST_WEEK) != i) | |
332 | log_err("FAIL: set/getMinimalDaysInFirstWeek failed\n"); | |
333 | } | |
334 | /*set it back to normal */ | |
335 | ucal_setAttribute(calit, UCAL_MINIMAL_DAYS_IN_FIRST_WEEK,count); | |
336 | ||
337 | ||
338 | /*testing if the UCalendar's timezone is currently in day light saving's time*/ | |
339 | log_verbose("\nTesting if the UCalendar is currently in daylight saving's time\n"); | |
340 | ucal_setDateTime(caldef, 1999, UCAL_MARCH, 3, 10, 45, 20, &status); | |
341 | ucal_inDaylightTime(caldef, &status ); | |
342 | if(U_FAILURE(status)) { | |
343 | log_err("Error in ucal_inDaylightTime: %s\n", u_errorName(status)); | |
344 | } | |
345 | if(!ucal_inDaylightTime(caldef, &status)) | |
346 | log_verbose("PASS: It is not in daylight saving's time\n"); | |
347 | else | |
348 | log_err("FAIL: It is not in daylight saving's time\n"); | |
349 | ||
350 | ||
351 | ||
352 | /*closing the UCalendar*/ | |
353 | ucal_close(caldef); | |
354 | ucal_close(caldef2); | |
355 | ucal_close(calfr); | |
356 | ucal_close(calit); | |
357 | /*closing the UDateFormat used */ | |
358 | udat_close(datdef); | |
359 | free(tzID); | |
360 | free(result); | |
361 | free(tzdname); | |
362 | ||
363 | } | |
364 | ||
365 | /*------------------------------------------------------*/ | |
366 | /*Testing the getMillis, setMillis, setDate and setDateTime functions extensively*/ | |
367 | ||
368 | static void TestGetSetDateAPI() | |
369 | { | |
370 | UCalendar *caldef = 0, *caldef2 = 0; | |
371 | UChar *tzID =0; | |
372 | UDate d1; | |
373 | int32_t hour; | |
374 | int32_t zoneOffset; | |
375 | UDateFormat *datdef = 0; | |
376 | UErrorCode status=U_ZERO_ERROR; | |
377 | UDate d2= 837039928046.0; | |
378 | UChar temp[30]; | |
379 | ||
380 | log_verbose("\nOpening the calendars()\n"); | |
381 | tzID=(UChar*)malloc(sizeof(UChar) * 4); | |
382 | u_strcpy(tzID, fgGMTID); | |
383 | /*open the calendars used */ | |
384 | caldef=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status); | |
385 | caldef2=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status); | |
386 | /*open the dateformat */ | |
387 | /* this is supposed to open default date format, but later on it treats it like it is "en_US" | |
388 | - very bad if you try to run the tests on machine where default locale is NOT "en_US" */ | |
389 | /*datdef=udat_open(UDAT_DEFAULT,UDAT_DEFAULT ,NULL,fgGMTID,-1, &status);*/ | |
390 | datdef=udat_open(UDAT_DEFAULT,UDAT_DEFAULT ,"en_US",fgGMTID,-1,NULL,0, &status); | |
391 | if(U_FAILURE(status)) | |
392 | { | |
393 | log_err("error in creating the dateformat : %s\n", u_errorName(status)); | |
394 | return; | |
395 | } | |
396 | ||
397 | ||
398 | /*Testing getMillis and setMillis */ | |
399 | log_verbose("\nTesting the date and time fetched in millis for a calendar using getMillis\n"); | |
400 | d1=ucal_getMillis(caldef, &status); | |
401 | if(U_FAILURE(status)){ | |
402 | log_err("Error in getMillis : %s\n", u_errorName(status)); | |
403 | } | |
404 | ||
405 | /*testing setMillis */ | |
406 | log_verbose("\nTesting the set date and time function using setMillis\n"); | |
407 | ucal_setMillis(caldef, d2, &status); | |
408 | if(U_FAILURE(status)){ | |
409 | log_err("Error in setMillis : %s\n", u_errorName(status)); | |
410 | } | |
411 | ||
412 | /*testing if the calendar date is set properly or not */ | |
413 | d1=ucal_getMillis(caldef, &status); | |
414 | if(u_strcmp(myDateFormat(datdef, d1), myDateFormat(datdef, d2))!=0) | |
415 | log_err("error in setMillis or getMillis\n"); | |
416 | /*-------------------*/ | |
417 | ||
418 | ||
419 | ||
374ca955 A |
420 | ctest_setTimeZone(NULL, &status); |
421 | ||
b75a7d8f A |
422 | /*testing ucal_setTimeZone() function*/ |
423 | log_verbose("\nTesting if the function ucal_setTimeZone() works fine\n"); | |
424 | ucal_setMillis(caldef2, d2, &status); | |
425 | if(U_FAILURE(status)){ | |
426 | log_err("Error in getMillis : %s\n", u_errorName(status));; | |
427 | } | |
428 | hour=ucal_get(caldef2, UCAL_HOUR_OF_DAY, &status); | |
429 | ||
430 | u_uastrcpy(tzID, "PST"); | |
431 | ucal_setTimeZone(caldef2,tzID, 3, &status); | |
432 | if(U_FAILURE(status)){ | |
433 | log_err("Error in setting the time zone using ucal_setTimeZone(): %s\n", u_errorName(status)); | |
434 | } | |
435 | else | |
436 | log_verbose("ucal_setTimeZone worked fine\n"); | |
437 | if(hour == ucal_get(caldef2, UCAL_HOUR_OF_DAY, &status)) | |
438 | log_err("FAIL: Error setting the time zone doesn't change the represented time\n"); | |
439 | else if((hour-8 + 1) != ucal_get(caldef2, UCAL_HOUR_OF_DAY, &status)) /*because it is not in daylight savings time */ | |
440 | log_err("FAIL: Error setTimeZone doesn't change the represented time correctly with 8 hour offset\n"); | |
441 | else | |
442 | log_verbose("PASS: setTimeZone works fine\n"); | |
443 | ||
444 | /*testing setTimeZone roundtrip */ | |
445 | log_verbose("\nTesting setTimeZone() roundtrip\n"); | |
446 | u_strcpy(tzID, fgGMTID); | |
447 | ucal_setTimeZone(caldef2, tzID, 3, &status); | |
448 | if(U_FAILURE(status)){ | |
449 | log_err("Error in setting the time zone using ucal_setTimeZone(): %s\n", u_errorName(status)); | |
450 | } | |
451 | if(d2==ucal_getMillis(caldef2, &status)) | |
452 | log_verbose("PASS: setTimeZone roundtrip test passed\n"); | |
453 | else | |
454 | log_err("FAIL: setTimeZone roundtrip test failed\n"); | |
455 | ||
456 | zoneOffset = ucal_get(caldef2, UCAL_ZONE_OFFSET, &status); | |
457 | if(U_FAILURE(status)){ | |
458 | log_err("Error in getting the time zone using ucal_get() after using ucal_setTimeZone(): %s\n", u_errorName(status)); | |
459 | } | |
460 | else if (zoneOffset != 0) { | |
461 | log_err("Error in getting the time zone using ucal_get() after using ucal_setTimeZone() offset=%d\n", zoneOffset); | |
462 | } | |
463 | ||
464 | ucal_setTimeZone(caldef2, NULL, -1, &status); | |
465 | if(U_FAILURE(status)){ | |
466 | log_err("Error in setting the time zone using ucal_setTimeZone(): %s\n", u_errorName(status)); | |
467 | } | |
468 | if(ucal_getMillis(caldef2, &status)) | |
469 | log_verbose("PASS: setTimeZone roundtrip test passed\n"); | |
470 | else | |
471 | log_err("FAIL: setTimeZone roundtrip test failed\n"); | |
472 | ||
473 | zoneOffset = ucal_get(caldef2, UCAL_ZONE_OFFSET, &status); | |
474 | if(U_FAILURE(status)){ | |
475 | log_err("Error in getting the time zone using ucal_get() after using ucal_setTimeZone(): %s\n", u_errorName(status)); | |
476 | } | |
477 | else if (zoneOffset != -28800000) { | |
478 | log_err("Error in getting the time zone using ucal_get() after using ucal_setTimeZone() offset=%d\n", zoneOffset); | |
479 | } | |
374ca955 A |
480 | |
481 | ctest_resetTimeZone(); | |
482 | ||
b75a7d8f A |
483 | /*----------------------------* */ |
484 | ||
485 | ||
486 | ||
487 | /*Testing if setDate works fine */ | |
488 | log_verbose("\nTesting the ucal_setDate() function \n"); | |
489 | u_uastrcpy(temp, "Dec 17, 1971 11:05:28 PM"); | |
490 | ucal_setDate(caldef,1971, UCAL_DECEMBER, 17, &status); | |
491 | if(U_FAILURE(status)){ | |
492 | log_err("error in setting the calendar date : %s\n", u_errorName(status)); | |
493 | } | |
494 | /*checking if the calendar date is set properly or not */ | |
495 | d1=ucal_getMillis(caldef, &status); | |
496 | if(u_strcmp(myDateFormat(datdef, d1), temp)==0) | |
497 | log_verbose("PASS:setDate works fine\n"); | |
498 | else | |
499 | log_err("FAIL:Error in setDate()\n"); | |
500 | ||
501 | ||
502 | /* Testing setDate Extensively with various input values */ | |
503 | log_verbose("\nTesting ucal_setDate() extensively\n"); | |
504 | ucal_setDate(caldef, 1999, UCAL_JANUARY, 10, &status); | |
505 | verify1("1999 10th day of January is :", caldef, datdef, 1999, UCAL_JANUARY, 10); | |
506 | ucal_setDate(caldef, 1999, UCAL_DECEMBER, 3, &status); | |
507 | verify1("1999 3rd day of December is :", caldef, datdef, 1999, UCAL_DECEMBER, 3); | |
508 | ucal_setDate(caldef, 2000, UCAL_MAY, 3, &status); | |
509 | verify1("2000 3rd day of May is :", caldef, datdef, 2000, UCAL_MAY, 3); | |
510 | ucal_setDate(caldef, 1999, UCAL_AUGUST, 32, &status); | |
511 | verify1("1999 32th day of August is :", caldef, datdef, 1999, UCAL_SEPTEMBER, 1); | |
512 | ucal_setDate(caldef, 1999, UCAL_MARCH, 0, &status); | |
513 | verify1("1999 0th day of March is :", caldef, datdef, 1999, UCAL_FEBRUARY, 28); | |
514 | ucal_setDate(caldef, 0, UCAL_MARCH, 12, &status); | |
515 | ||
516 | /*--------------------*/ | |
517 | ||
518 | /*Testing if setDateTime works fine */ | |
519 | log_verbose("\nTesting the ucal_setDateTime() function \n"); | |
520 | u_uastrcpy(temp, "May 3, 1972 4:30:42 PM"); | |
521 | ucal_setDateTime(caldef,1972, UCAL_MAY, 3, 16, 30, 42, &status); | |
522 | if(U_FAILURE(status)){ | |
523 | log_err("error in setting the calendar date : %s\n", u_errorName(status)); | |
524 | } | |
525 | /*checking if the calendar date is set properly or not */ | |
526 | d1=ucal_getMillis(caldef, &status); | |
527 | if(u_strcmp(myDateFormat(datdef, d1), temp)==0) | |
528 | log_verbose("PASS: setDateTime works fine\n"); | |
529 | else | |
530 | log_err("FAIL: Error in setDateTime\n"); | |
531 | ||
532 | ||
533 | ||
534 | /*Testing setDateTime extensively with various input values*/ | |
535 | log_verbose("\nTesting ucal_setDateTime() function extensively\n"); | |
536 | ucal_setDateTime(caldef, 1999, UCAL_OCTOBER, 10, 6, 45, 30, &status); | |
537 | verify2("1999 10th day of October at 6:45:30 is :", caldef, datdef, 1999, UCAL_OCTOBER, 10, 6, 45, 30, 0 ); | |
538 | ucal_setDateTime(caldef, 1999, UCAL_MARCH, 3, 15, 10, 55, &status); | |
539 | verify2("1999 3rd day of March at 15:10:55 is :", caldef, datdef, 1999, UCAL_MARCH, 3, 3, 10, 55, 1); | |
540 | ucal_setDateTime(caldef, 1999, UCAL_MAY, 3, 25, 30, 45, &status); | |
541 | verify2("1999 3rd day of May at 25:30:45 is :", caldef, datdef, 1999, UCAL_MAY, 4, 1, 30, 45, 0); | |
542 | ucal_setDateTime(caldef, 1999, UCAL_AUGUST, 32, 22, 65, 40, &status); | |
543 | verify2("1999 32th day of August at 22:65:40 is :", caldef, datdef, 1999, UCAL_SEPTEMBER, 1, 11, 5, 40,1); | |
544 | ucal_setDateTime(caldef, 1999, UCAL_MARCH, 12, 0, 0, 0,&status); | |
545 | verify2("1999 12th day of March at 0:0:0 is :", caldef, datdef, 1999, UCAL_MARCH, 12, 0, 0, 0, 0); | |
546 | ucal_setDateTime(caldef, 1999, UCAL_MARCH, 12, -10, -10,0, &status); | |
547 | verify2("1999 12th day of March is at -10:-10:0 :", caldef, datdef, 1999, UCAL_MARCH, 11, 1, 50, 0, 1); | |
548 | ||
549 | ||
550 | ||
551 | /*close caldef and datdef*/ | |
552 | ucal_close(caldef); | |
553 | ucal_close(caldef2); | |
554 | udat_close(datdef); | |
555 | free(tzID); | |
556 | ||
557 | } | |
558 | ||
559 | /*----------------------------------------------------------- */ | |
560 | /** | |
561 | * Confirm the functioning of the calendar field related functions. | |
562 | */ | |
563 | static void TestFieldGetSet() | |
564 | { | |
565 | UCalendar *cal = 0; | |
566 | UChar *tzID = 0; | |
567 | UDateFormat *datdef = 0; | |
568 | UDate d1; | |
569 | UErrorCode status=U_ZERO_ERROR; | |
570 | log_verbose("\nFetching pointer to UCalendar using the ucal_open()\n"); | |
571 | tzID=(UChar*)malloc(sizeof(UChar) * 4); | |
572 | u_strcpy(tzID, fgGMTID); | |
573 | /*open the calendar used */ | |
574 | cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status); | |
575 | if (U_FAILURE(status)) { | |
576 | log_err("ucal_open failed: %s\n", u_errorName(status)); | |
577 | return; | |
578 | } | |
579 | datdef=udat_open(UDAT_SHORT,UDAT_SHORT ,NULL,fgGMTID,-1,NULL, 0, &status); | |
580 | if(U_FAILURE(status)) | |
581 | { | |
582 | log_err("error in creating the dateformat : %s\n", u_errorName(status)); | |
583 | } | |
584 | ||
585 | /*Testing ucal_get()*/ | |
586 | log_verbose("\nTesting the ucal_get() function of Calendar\n"); | |
587 | ucal_setDateTime(cal, 1999, UCAL_MARCH, 12, 5, 25, 30, &status); | |
588 | if(U_FAILURE(status)){ | |
589 | log_err("error in the setDateTime() : %s\n", u_errorName(status)); | |
590 | } | |
591 | if(ucal_get(cal, UCAL_YEAR, &status)!=1999 || ucal_get(cal, UCAL_MONTH, &status)!=2 || | |
592 | ucal_get(cal, UCAL_DATE, &status)!=12 || ucal_get(cal, UCAL_HOUR, &status)!=5) | |
593 | log_err("error in ucal_get()\n"); | |
594 | else if(ucal_get(cal, UCAL_DAY_OF_WEEK_IN_MONTH, &status)!=2 || ucal_get(cal, UCAL_DAY_OF_WEEK, &status)!=6 | |
595 | || ucal_get(cal, UCAL_WEEK_OF_MONTH, &status)!=2 || ucal_get(cal, UCAL_WEEK_OF_YEAR, &status)!= 11) | |
596 | log_err("FAIL: error in ucal_get()\n"); | |
597 | else | |
598 | log_verbose("PASS: ucal_get() works fine\n"); | |
599 | ||
600 | /*Testing the ucal_set() , ucal_clear() functions of calendar*/ | |
601 | log_verbose("\nTesting the set, and clear field functions of calendar\n"); | |
602 | ucal_setAttribute(cal, UCAL_LENIENT, 0); | |
603 | ucal_clear(cal); | |
604 | ucal_set(cal, UCAL_YEAR, 1997); | |
605 | ucal_set(cal, UCAL_MONTH, UCAL_JUNE); | |
606 | ucal_set(cal, UCAL_DATE, 3); | |
607 | verify1("1997 third day of June = ", cal, datdef, 1997, UCAL_JUNE, 3); | |
608 | ucal_clear(cal); | |
609 | ucal_set(cal, UCAL_YEAR, 1997); | |
610 | ucal_set(cal, UCAL_DAY_OF_WEEK, UCAL_TUESDAY); | |
611 | ucal_set(cal, UCAL_MONTH, UCAL_JUNE); | |
612 | ucal_set(cal, UCAL_DAY_OF_WEEK_IN_MONTH, 1); | |
613 | verify1("1997 first Tuesday in June = ", cal, datdef, 1997, UCAL_JUNE, 3); | |
614 | ucal_clear(cal); | |
615 | ucal_set(cal, UCAL_YEAR, 1997); | |
616 | ucal_set(cal, UCAL_DAY_OF_WEEK, UCAL_TUESDAY); | |
617 | ucal_set(cal, UCAL_MONTH, UCAL_JUNE); | |
618 | ucal_set(cal, UCAL_DAY_OF_WEEK_IN_MONTH, - 1); | |
619 | verify1("1997 last Tuesday in June = ", cal, datdef,1997, UCAL_JUNE, 24); | |
620 | /*give undesirable input */ | |
621 | status = U_ZERO_ERROR; | |
622 | ucal_clear(cal); | |
623 | ucal_set(cal, UCAL_YEAR, 1997); | |
624 | ucal_set(cal, UCAL_DAY_OF_WEEK, UCAL_TUESDAY); | |
625 | ucal_set(cal, UCAL_MONTH, UCAL_JUNE); | |
626 | ucal_set(cal, UCAL_DAY_OF_WEEK_IN_MONTH, 0); | |
627 | d1=ucal_getMillis(cal,&status); | |
628 | if (status != U_ILLEGAL_ARGUMENT_ERROR){ | |
629 | log_err("FAIL: No IllegalArgumentError for :"); | |
630 | log_err("1997 zero-th Tuesday in June \n"); | |
631 | } | |
632 | else | |
633 | log_verbose("PASS: IllegalArgumentError as expected\n"); | |
634 | ||
635 | ucal_clear(cal); | |
636 | ucal_set(cal, UCAL_YEAR, 1997); | |
637 | ucal_set(cal, UCAL_DAY_OF_WEEK, UCAL_TUESDAY); | |
638 | ucal_set(cal, UCAL_MONTH, UCAL_JUNE); | |
639 | ucal_set(cal, UCAL_WEEK_OF_MONTH, 1); | |
640 | verify1("1997 Tuesday in week 1 of June = ", cal,datdef, 1997, UCAL_JUNE, 3); | |
641 | ucal_clear(cal); | |
642 | ucal_set(cal, UCAL_YEAR, 1997); | |
643 | ucal_set(cal, UCAL_DAY_OF_WEEK, UCAL_TUESDAY); | |
644 | ucal_set(cal, UCAL_MONTH, UCAL_JUNE); | |
645 | ucal_set(cal, UCAL_WEEK_OF_MONTH, 5); | |
646 | verify1("1997 Tuesday in week 5 of June = ", cal,datdef, 1997, UCAL_JULY, 1); | |
647 | status = U_ZERO_ERROR; | |
648 | ucal_clear(cal); | |
649 | ucal_set(cal, UCAL_YEAR, 1997); | |
650 | ucal_set(cal, UCAL_DAY_OF_WEEK, UCAL_TUESDAY); | |
651 | ucal_set(cal, UCAL_MONTH, UCAL_JUNE); | |
652 | ucal_set(cal, UCAL_WEEK_OF_MONTH, 0); | |
653 | verify1("1997 Tuesday in week 0 of June = ", cal, datdef , 1997, UCAL_MAY, 27); | |
654 | ucal_clear(cal); | |
655 | ucal_set(cal, UCAL_YEAR_WOY, 1997); | |
656 | ucal_set(cal, UCAL_DAY_OF_WEEK, UCAL_TUESDAY); | |
657 | ucal_set(cal, UCAL_WEEK_OF_YEAR, 1); | |
658 | verify1("1997 Tuesday in week 1 of year = ", cal, datdef,1996, UCAL_DECEMBER, 31); | |
659 | ucal_clear(cal); | |
660 | ucal_set(cal, UCAL_YEAR, 1997); | |
661 | ucal_set(cal, UCAL_DAY_OF_WEEK, UCAL_TUESDAY); | |
662 | ucal_set(cal, UCAL_WEEK_OF_YEAR, 10); | |
663 | verify1("1997 Tuesday in week 10 of year = ", cal,datdef, 1997, UCAL_MARCH, 4); | |
664 | ucal_clear(cal); | |
665 | ucal_set(cal, UCAL_YEAR, 1999); | |
666 | ucal_set(cal, UCAL_DAY_OF_YEAR, 1); | |
667 | verify1("1999 1st day of the year =", cal, datdef, 1999, UCAL_JANUARY, 1); | |
668 | ucal_set(cal, UCAL_MONTH, -3); | |
669 | d1=ucal_getMillis(cal,&status); | |
670 | if (status != U_ILLEGAL_ARGUMENT_ERROR){ | |
671 | log_err("FAIL: No IllegalArgumentError for :\"1999 -3th month \" "); | |
672 | } | |
673 | else | |
674 | log_verbose("PASS: IllegalArgumentError as expected\n"); | |
675 | ||
676 | ucal_setAttribute(cal, UCAL_LENIENT, 1); | |
677 | ||
678 | ucal_set(cal, UCAL_MONTH, -3); | |
679 | verify1("1999 -3th month should be", cal, datdef, 1998, UCAL_OCTOBER, 1); | |
680 | ||
681 | ||
682 | /*testing isSet and clearField()*/ | |
683 | if(!ucal_isSet(cal, UCAL_WEEK_OF_YEAR)) | |
684 | log_err("FAIL: error in isSet\n"); | |
685 | else | |
686 | log_verbose("PASS: isSet working fine\n"); | |
687 | ucal_clearField(cal, UCAL_WEEK_OF_YEAR); | |
688 | if(ucal_isSet(cal, UCAL_WEEK_OF_YEAR)) | |
689 | log_err("FAIL: there is an error in clearField or isSet\n"); | |
690 | else | |
691 | log_verbose("PASS :clearField working fine\n"); | |
692 | ||
693 | /*-------------------------------*/ | |
694 | ||
695 | ucal_close(cal); | |
696 | udat_close(datdef); | |
697 | free(tzID); | |
698 | ||
699 | } | |
700 | ||
701 | ||
702 | ||
703 | /* ------------------------------------- */ | |
704 | /** | |
705 | * Execute adding and rolling in Calendar extensively, | |
706 | */ | |
707 | static void TestAddRollExtensive() | |
708 | { | |
709 | UCalendar *cal = 0; | |
710 | int32_t i,limit; | |
711 | UChar* tzID = 0; | |
712 | UCalendarDateFields e; | |
713 | int32_t y,m,d,hr,min,sec,ms; | |
714 | int32_t maxlimit = 40; | |
715 | UErrorCode status = U_ZERO_ERROR; | |
716 | y = 1997; m = UCAL_FEBRUARY; d = 1; hr = 1; min = 1; sec = 0; ms = 0; | |
717 | ||
718 | log_verbose("Testing add and roll extensively\n"); | |
719 | ||
720 | tzID=(UChar*)malloc(sizeof(UChar) * 4); | |
721 | u_uastrcpy(tzID, "PST"); | |
722 | /*open the calendar used */ | |
723 | cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_GREGORIAN, &status);; | |
724 | if (U_FAILURE(status)) { | |
725 | log_err("ucal_open() failed : %s\n", u_errorName(status)); | |
726 | return; | |
727 | } | |
728 | ||
729 | ucal_set(cal, UCAL_YEAR, y); | |
730 | ucal_set(cal, UCAL_MONTH, m); | |
731 | ucal_set(cal, UCAL_DATE, d); | |
732 | ||
733 | /* Confirm that adding to various fields works.*/ | |
734 | log_verbose("\nTesting to confirm that adding to various fields works with ucal_add()\n"); | |
735 | checkDate(cal, y, m, d); | |
736 | ucal_add(cal,UCAL_YEAR, 1, &status); | |
737 | if (U_FAILURE(status)) { log_err("ucal_add failed: %s\n", u_errorName(status)); return; } | |
738 | y++; | |
739 | checkDate(cal, y, m, d); | |
740 | ucal_add(cal,UCAL_MONTH, 12, &status); | |
741 | if (U_FAILURE(status)) { log_err("ucal_add failed: %s\n", u_errorName(status) ); return; } | |
742 | y+=1; | |
743 | checkDate(cal, y, m, d); | |
744 | ucal_add(cal,UCAL_DATE, 1, &status); | |
745 | if (U_FAILURE(status)) { log_err("ucal_add failed: %s\n", u_errorName(status) ); return; } | |
746 | d++; | |
747 | checkDate(cal, y, m, d); | |
748 | ucal_add(cal,UCAL_DATE, 2, &status); | |
749 | if (U_FAILURE(status)) { log_err("ucal_add failed: %s\n", u_errorName(status) ); return; } | |
750 | d += 2; | |
751 | checkDate(cal, y, m, d); | |
752 | ucal_add(cal,UCAL_DATE, 28, &status); | |
753 | if (U_FAILURE(status)) { log_err("ucal_add failed: %s\n", u_errorName(status) ); return; } | |
754 | ++m; | |
755 | checkDate(cal, y, m, d); | |
756 | ucal_add(cal, (UCalendarDateFields)-1, 10, &status); | |
757 | if(status==U_ILLEGAL_ARGUMENT_ERROR) | |
758 | log_verbose("Pass: Illegal argument error as expected\n"); | |
759 | else{ | |
760 | log_err("Fail: No, illegal argument error as expected. Got....: %s\n", u_errorName(status)); | |
761 | } | |
762 | status=U_ZERO_ERROR; | |
763 | ||
764 | ||
765 | /*confirm that applying roll to various fields works fine*/ | |
766 | log_verbose("\nTesting to confirm that ucal_roll() works\n"); | |
767 | ucal_roll(cal, UCAL_DATE, -1, &status); | |
768 | if (U_FAILURE(status)) { log_err("ucal_roll failed: %s\n", u_errorName(status) ); return; } | |
769 | d -=1; | |
770 | checkDate(cal, y, m, d); | |
771 | ucal_roll(cal, UCAL_MONTH, -2, &status); | |
772 | if (U_FAILURE(status)) { log_err("ucal_roll failed: %s\n", u_errorName(status) ); return; } | |
773 | m -=2; | |
774 | checkDate(cal, y, m, d); | |
775 | ucal_roll(cal, UCAL_DATE, 1, &status); | |
776 | if (U_FAILURE(status)) { log_err("ucal_roll failed: %s\n", u_errorName(status) ); return; } | |
777 | d +=1; | |
778 | checkDate(cal, y, m, d); | |
779 | ucal_roll(cal, UCAL_MONTH, -12, &status); | |
780 | if (U_FAILURE(status)) { log_err("ucal_roll failed: %s\n", u_errorName(status) ); return; } | |
781 | checkDate(cal, y, m, d); | |
782 | ucal_roll(cal, UCAL_YEAR, -1, &status); | |
783 | if (U_FAILURE(status)) { log_err("ucal_roll failed: %s\n", u_errorName(status) ); return; } | |
784 | y -=1; | |
785 | checkDate(cal, y, m, d); | |
786 | ucal_roll(cal, UCAL_DATE, 29, &status); | |
787 | if (U_FAILURE(status)) { log_err("ucal_roll failed: %s\n", u_errorName(status) ); return; } | |
788 | d = 2; | |
789 | checkDate(cal, y, m, d); | |
790 | ucal_roll(cal, (UCalendarDateFields)-1, 10, &status); | |
791 | if(status==U_ILLEGAL_ARGUMENT_ERROR) | |
792 | log_verbose("Pass: illegal arguement error as expected\n"); | |
793 | else{ | |
794 | log_err("Fail: no illegal argument error got..: %s\n", u_errorName(status)); | |
795 | return; | |
796 | } | |
797 | status=U_ZERO_ERROR; | |
798 | ucal_setDateTime(cal, 1999, UCAL_FEBRUARY, 28, 10, 30, 45, &status); | |
799 | if(U_FAILURE(status)){ | |
800 | log_err("error is setting the datetime: %s\n", u_errorName(status)); | |
801 | } | |
802 | ucal_add(cal, UCAL_MONTH, 1, &status); | |
803 | checkDate(cal, 1999, UCAL_MARCH, 28); | |
804 | ucal_add(cal, UCAL_MILLISECOND, 1000, &status); | |
805 | checkDateTime(cal, 1999, UCAL_MARCH, 28, 10, 30, 46, 0, UCAL_MILLISECOND); | |
806 | ||
807 | ucal_close(cal); | |
808 | /*--------------- */ | |
809 | status=U_ZERO_ERROR; | |
810 | /* Testing add and roll extensively */ | |
811 | log_verbose("\nTesting the ucal_add() and ucal_roll() functions extensively\n"); | |
812 | y = 1997; m = UCAL_FEBRUARY; d = 1; hr = 1; min = 1; sec = 0; ms = 0; | |
813 | cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status); | |
814 | if (U_FAILURE(status)) { | |
815 | log_err("ucal_open failed: %s\n", u_errorName(status)); | |
816 | return; | |
817 | } | |
818 | ucal_set(cal, UCAL_YEAR, y); | |
819 | ucal_set(cal, UCAL_MONTH, m); | |
820 | ucal_set(cal, UCAL_DATE, d); | |
821 | ucal_set(cal, UCAL_HOUR, hr); | |
822 | ucal_set(cal, UCAL_MINUTE, min); | |
823 | ucal_set(cal, UCAL_SECOND,sec); | |
824 | ucal_set(cal, UCAL_MILLISECOND, ms); | |
825 | status=U_ZERO_ERROR; | |
826 | ||
827 | log_verbose("\nTesting UCalendar add...\n"); | |
828 | for(e = UCAL_YEAR;e < UCAL_FIELD_COUNT; e=(UCalendarDateFields)((int32_t)e + 1)) { | |
829 | limit = maxlimit; | |
830 | status = U_ZERO_ERROR; | |
831 | for (i = 0; i < limit; i++) { | |
832 | ucal_add(cal, e, 1, &status); | |
833 | if (U_FAILURE(status)) { limit = i; status = U_ZERO_ERROR; } | |
834 | } | |
835 | for (i = 0; i < limit; i++) { | |
836 | ucal_add(cal, e, -1, &status); | |
837 | if (U_FAILURE(status)) { | |
838 | log_err("ucal_add -1 failed: %s\n", u_errorName(status)); | |
839 | return; | |
840 | } | |
841 | } | |
842 | checkDateTime(cal, y, m, d, hr, min, sec, ms, e); | |
843 | } | |
844 | log_verbose("\nTesting calendar ucal_roll()...\n"); | |
845 | for(e = UCAL_YEAR;e < UCAL_FIELD_COUNT; e=(UCalendarDateFields)((int32_t)e + 1)) { | |
846 | limit = maxlimit; | |
847 | status = U_ZERO_ERROR; | |
848 | for (i = 0; i < limit; i++) { | |
849 | ucal_roll(cal, e, 1, &status); | |
850 | if (U_FAILURE(status)) { | |
851 | limit = i; | |
852 | status = U_ZERO_ERROR; | |
853 | } | |
854 | } | |
855 | for (i = 0; i < limit; i++) { | |
856 | ucal_roll(cal, e, -1, &status); | |
857 | if (U_FAILURE(status)) { | |
858 | log_err("ucal_roll -1 failed: %s\n", u_errorName(status)); | |
859 | return; | |
860 | } | |
861 | } | |
862 | checkDateTime(cal, y, m, d, hr, min, sec, ms, e); | |
863 | } | |
864 | ||
865 | ucal_close(cal); | |
866 | free(tzID); | |
867 | } | |
868 | ||
869 | /*------------------------------------------------------ */ | |
870 | /*Testing the Limits for various Fields of Calendar*/ | |
871 | static void TestGetLimits() | |
872 | { | |
873 | UCalendar *cal = 0; | |
874 | int32_t min, max, gr_min, le_max, ac_min, ac_max, val; | |
875 | UChar* tzID = 0; | |
876 | UErrorCode status = U_ZERO_ERROR; | |
877 | ||
878 | ||
879 | tzID=(UChar*)malloc(sizeof(UChar) * 4); | |
880 | u_uastrcpy(tzID, "PST"); | |
881 | /*open the calendar used */ | |
882 | cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_GREGORIAN, &status);; | |
883 | if (U_FAILURE(status)) { | |
884 | log_err("ucal_open() for gregorian calendar failed in TestGetLimits: %s\n", u_errorName(status)); | |
885 | return; | |
886 | } | |
887 | ||
888 | log_verbose("\nTesting the getLimits function for various fields\n"); | |
889 | ||
890 | ||
891 | ||
892 | ucal_setDate(cal, 1999, UCAL_MARCH, 5, &status); /* Set the date to be March 5, 1999 */ | |
893 | val = ucal_get(cal, UCAL_DAY_OF_WEEK, &status); | |
894 | min = ucal_getLimit(cal, UCAL_DAY_OF_WEEK, UCAL_MINIMUM, &status); | |
895 | max = ucal_getLimit(cal, UCAL_DAY_OF_WEEK, UCAL_MAXIMUM, &status); | |
896 | if ( (min != UCAL_SUNDAY || max != UCAL_SATURDAY ) && (min > val > max) && (val != UCAL_FRIDAY)){ | |
897 | log_err("FAIL: Min/max bad\n"); | |
898 | log_err("FAIL: Day of week %d out of range\n", val); | |
899 | log_err("FAIL: FAIL: Day of week should be SUNDAY Got %d\n", val); | |
900 | } | |
901 | else | |
902 | log_verbose("getLimits successful\n"); | |
903 | ||
904 | val = ucal_get(cal, UCAL_DAY_OF_WEEK_IN_MONTH, &status); | |
905 | min = ucal_getLimit(cal, UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_MINIMUM, &status); | |
906 | max = ucal_getLimit(cal, UCAL_DAY_OF_WEEK_IN_MONTH, UCAL_MAXIMUM, &status); | |
907 | if ( (min != 0 || max != 5 ) && (min > val > max) && (val != 1)){ | |
908 | log_err("FAIL: Min/max bad\n"); | |
909 | log_err("FAIL: Day of week in month %d out of range\n", val); | |
910 | log_err("FAIL: FAIL: Day of week in month should be SUNDAY Got %d\n", val); | |
911 | ||
912 | } | |
913 | else | |
914 | log_verbose("getLimits successful\n"); | |
915 | ||
916 | min=ucal_getLimit(cal, UCAL_MONTH, UCAL_MINIMUM, &status); | |
917 | max=ucal_getLimit(cal, UCAL_MONTH, UCAL_MAXIMUM, &status); | |
918 | gr_min=ucal_getLimit(cal, UCAL_MONTH, UCAL_GREATEST_MINIMUM, &status); | |
919 | le_max=ucal_getLimit(cal, UCAL_MONTH, UCAL_LEAST_MAXIMUM, &status); | |
920 | ac_min=ucal_getLimit(cal, UCAL_MONTH, UCAL_ACTUAL_MINIMUM, &status); | |
921 | ac_max=ucal_getLimit(cal, UCAL_MONTH, UCAL_ACTUAL_MAXIMUM, &status); | |
922 | if(U_FAILURE(status)){ | |
923 | log_err("Error in getLimits: %s\n", u_errorName(status)); | |
924 | } | |
925 | if(min!=0 || max!=11 || gr_min!=0 || le_max!=11 || ac_min!=0 || ac_max!=11) | |
926 | log_err("There is and error in getLimits in fetching the values\n"); | |
927 | else | |
928 | log_verbose("getLimits successful\n"); | |
929 | ||
930 | ucal_setDateTime(cal, 1999, UCAL_MARCH, 5, 4, 10, 35, &status); | |
931 | val=ucal_get(cal, UCAL_HOUR_OF_DAY, &status); | |
932 | min=ucal_getLimit(cal, UCAL_HOUR_OF_DAY, UCAL_MINIMUM, &status); | |
933 | max=ucal_getLimit(cal, UCAL_HOUR_OF_DAY, UCAL_MAXIMUM, &status); | |
934 | gr_min=ucal_getLimit(cal, UCAL_MINUTE, UCAL_GREATEST_MINIMUM, &status); | |
935 | le_max=ucal_getLimit(cal, UCAL_MINUTE, UCAL_LEAST_MAXIMUM, &status); | |
936 | ac_min=ucal_getLimit(cal, UCAL_MINUTE, UCAL_ACTUAL_MINIMUM, &status); | |
937 | ac_max=ucal_getLimit(cal, UCAL_SECOND, UCAL_ACTUAL_MAXIMUM, &status); | |
938 | if( (min!=0 || max!= 11 || gr_min!=0 || le_max!=60 || ac_min!=0 || ac_max!=60) && | |
939 | (min>val>max) && val!=4){ | |
940 | ||
941 | log_err("FAIL: Min/max bad\n"); | |
942 | log_err("FAIL: Hour of Day %d out of range\n", val); | |
943 | log_err("FAIL: HOUR_OF_DAY should be 4 Got %d\n", val); | |
944 | } | |
945 | else | |
946 | log_verbose("getLimits successful\n"); | |
947 | ||
948 | ||
949 | /*get BOGUS_LIMIT type*/ | |
950 | val=ucal_getLimit(cal, UCAL_SECOND, (UCalendarLimitType)99, &status); | |
951 | if(val != -1){ | |
952 | log_err("FAIL: ucal_getLimit() with BOGUS type should return -1\n"); | |
953 | } | |
954 | status=U_ZERO_ERROR; | |
955 | ||
956 | ||
957 | ucal_close(cal); | |
958 | free(tzID); | |
959 | } | |
960 | ||
961 | ||
962 | ||
963 | /* ------------------------------------- */ | |
964 | ||
965 | /** | |
966 | * Test that the days of the week progress properly when add is called repeatedly | |
967 | * for increments of 24 days. | |
968 | */ | |
969 | static void TestDOWProgression() | |
970 | { | |
971 | int32_t initialDOW, DOW, newDOW, expectedDOW; | |
972 | UCalendar *cal = 0; | |
973 | UDateFormat *datfor = 0; | |
974 | UDate date1; | |
975 | int32_t delta=24; | |
976 | UErrorCode status = U_ZERO_ERROR; | |
977 | UChar* tzID = 0; | |
978 | char tempMsgBuf[256]; | |
979 | tzID=(UChar*)malloc(sizeof(UChar) * 4); | |
980 | u_strcpy(tzID, fgGMTID); | |
981 | /*open the calendar used */ | |
982 | cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status);; | |
983 | if (U_FAILURE(status)) { | |
984 | log_err("ucal_open failed: %s\n", u_errorName(status)); | |
985 | return; | |
986 | } | |
987 | ||
988 | datfor=udat_open(UDAT_MEDIUM,UDAT_MEDIUM ,NULL, fgGMTID,-1,NULL, 0, &status); | |
989 | if(U_FAILURE(status)){ | |
990 | log_err("error in creating the dateformat : %s\n", u_errorName(status)); | |
991 | } | |
992 | ||
993 | ||
994 | ucal_setDate(cal, 1999, UCAL_JANUARY, 1, &status); | |
995 | ||
996 | log_verbose("\nTesting the DOW progression\n"); | |
997 | ||
998 | initialDOW = ucal_get(cal, UCAL_DAY_OF_WEEK, &status); | |
999 | if (U_FAILURE(status)) { log_err("ucal_get() failed: %s\n", u_errorName(status) ); return; } | |
1000 | newDOW = initialDOW; | |
1001 | do { | |
1002 | DOW = newDOW; | |
1003 | log_verbose("DOW = %d...\n", DOW); | |
1004 | date1=ucal_getMillis(cal, &status); | |
1005 | if(U_FAILURE(status)){ log_err("ucal_getMiilis() failed: %s\n", u_errorName(status)); return;} | |
1006 | log_verbose("%s\n", u_austrcpy(tempMsgBuf, myDateFormat(datfor, date1))); | |
1007 | ||
1008 | ucal_add(cal,UCAL_DAY_OF_WEEK, delta, &status); | |
1009 | if (U_FAILURE(status)) { log_err("ucal_add() failed: %s\n", u_errorName(status)); return; } | |
1010 | ||
1011 | newDOW = ucal_get(cal, UCAL_DAY_OF_WEEK, &status); | |
1012 | if (U_FAILURE(status)) { log_err("ucal_get() failed: %s\n", u_errorName(status)); return; } | |
1013 | expectedDOW = 1 + (DOW + delta - 1) % 7; | |
1014 | date1=ucal_getMillis(cal, &status); | |
1015 | if(U_FAILURE(status)){ log_err("ucal_getMiilis() failed: %s\n", u_errorName(status)); return;} | |
1016 | if (newDOW != expectedDOW) { | |
1017 | log_err("Day of week should be %d instead of %d on %s", expectedDOW, newDOW, | |
1018 | u_austrcpy(tempMsgBuf, myDateFormat(datfor, date1)) ); | |
1019 | return; | |
1020 | } | |
1021 | } | |
1022 | while (newDOW != initialDOW); | |
1023 | ||
1024 | ucal_close(cal); | |
1025 | udat_close(datfor); | |
1026 | free(tzID); | |
1027 | ||
1028 | } | |
1029 | ||
1030 | /* ------------------------------------- */ | |
1031 | ||
1032 | /** | |
1033 | * Confirm that the offset between local time and GMT behaves as expected. | |
1034 | */ | |
1035 | static void TestGMTvsLocal() | |
1036 | { | |
1037 | log_verbose("\nTesting the offset between the GMT and local time\n"); | |
1038 | testZones(1999, 1, 1, 12, 0, 0); | |
1039 | testZones(1999, 4, 16, 18, 30, 0); | |
1040 | testZones(1998, 12, 17, 19, 0, 0); | |
1041 | } | |
1042 | ||
1043 | /* ------------------------------------- */ | |
1044 | ||
1045 | static void testZones(int32_t yr, int32_t mo, int32_t dt, int32_t hr, int32_t mn, int32_t sc) | |
1046 | { | |
1047 | int32_t offset,utc, expected; | |
1048 | UCalendar *gmtcal = 0, *cal = 0; | |
1049 | UDate date1; | |
1050 | double temp; | |
1051 | UDateFormat *datfor = 0; | |
1052 | UErrorCode status = U_ZERO_ERROR; | |
1053 | UChar* tzID = 0; | |
1054 | char tempMsgBuf[256]; | |
1055 | ||
1056 | tzID=(UChar*)malloc(sizeof(UChar) * 4); | |
1057 | u_strcpy(tzID, fgGMTID); | |
1058 | gmtcal=ucal_open(tzID, 3, "en_US", UCAL_TRADITIONAL, &status);; | |
1059 | if (U_FAILURE(status)) { | |
1060 | log_err("ucal_open failed: %s\n", u_errorName(status)); | |
1061 | return; | |
1062 | } | |
1063 | u_uastrcpy(tzID, "PST"); | |
1064 | cal = ucal_open(tzID, 3, "en_US", UCAL_TRADITIONAL, &status); | |
1065 | if (U_FAILURE(status)) { | |
1066 | log_err("ucal_open failed: %s\n", u_errorName(status)); | |
1067 | return; | |
1068 | } | |
1069 | ||
1070 | datfor=udat_open(UDAT_MEDIUM,UDAT_MEDIUM ,NULL, fgGMTID,-1,NULL, 0, &status); | |
1071 | if(U_FAILURE(status)){ | |
1072 | log_err("error in creating the dateformat : %s\n", u_errorName(status)); | |
1073 | } | |
1074 | ||
1075 | ucal_setDateTime(gmtcal, yr, mo - 1, dt, hr, mn, sc, &status); | |
1076 | if (U_FAILURE(status)) { | |
1077 | log_err("ucal_setDateTime failed: %s\n", u_errorName(status)); | |
1078 | return; | |
1079 | } | |
1080 | ucal_set(gmtcal, UCAL_MILLISECOND, 0); | |
1081 | date1 = ucal_getMillis(gmtcal, &status); | |
1082 | if (U_FAILURE(status)) { | |
1083 | log_err("ucal_getMillis failed: %s\n", u_errorName(status)); | |
1084 | return; | |
1085 | } | |
1086 | log_verbose("date = %s\n", u_austrcpy(tempMsgBuf, myDateFormat(datfor, date1)) ); | |
1087 | ||
1088 | ||
1089 | ucal_setMillis(cal, date1, &status); | |
1090 | if (U_FAILURE(status)) { | |
1091 | log_err("ucal_setMillis() failed: %s\n", u_errorName(status)); | |
1092 | return; | |
1093 | } | |
1094 | ||
1095 | offset = ucal_get(cal, UCAL_ZONE_OFFSET, &status); | |
1096 | offset += ucal_get(cal, UCAL_DST_OFFSET, &status); | |
1097 | ||
1098 | if (U_FAILURE(status)) { | |
1099 | log_err("ucal_get() failed: %s\n", u_errorName(status)); | |
1100 | return; | |
1101 | } | |
1102 | temp=(double)((double)offset / 1000.0 / 60.0 / 60.0); | |
1103 | /*printf("offset for %s %f hr\n", austrdup(myDateFormat(datfor, date1)), temp);*/ | |
1104 | ||
1105 | utc = ((ucal_get(cal, UCAL_HOUR_OF_DAY, &status) * 60 + | |
1106 | ucal_get(cal, UCAL_MINUTE, &status)) * 60 + | |
1107 | ucal_get(cal, UCAL_SECOND, &status)) * 1000 + | |
1108 | ucal_get(cal, UCAL_MILLISECOND, &status) - offset; | |
1109 | if (U_FAILURE(status)) { | |
1110 | log_err("ucal_get() failed: %s\n", u_errorName(status)); | |
1111 | return; | |
1112 | } | |
1113 | ||
1114 | expected = ((hr * 60 + mn) * 60 + sc) * 1000; | |
1115 | if (utc != expected) { | |
1116 | temp=(double)(utc - expected)/ 1000 / 60 / 60.0; | |
1117 | log_err("FAIL: Discrepancy of %d millis = %fhr\n", utc-expected, temp ); | |
1118 | } | |
1119 | else | |
1120 | log_verbose("PASS: the offset between local and GMT is correct\n"); | |
1121 | ucal_close(gmtcal); | |
1122 | ucal_close(cal); | |
1123 | udat_close(datfor); | |
1124 | free(tzID); | |
1125 | } | |
1126 | ||
1127 | /* ------------------------------------- */ | |
1128 | ||
1129 | ||
1130 | ||
1131 | ||
1132 | /* INTERNAL FUNCTIONS USED */ | |
1133 | /*------------------------------------------------------------------------------------------- */ | |
1134 | ||
1135 | /* ------------------------------------- */ | |
1136 | static void checkDateTime(UCalendar* c, | |
1137 | int32_t y, int32_t m, int32_t d, | |
1138 | int32_t hr, int32_t min, int32_t sec, | |
1139 | int32_t ms, UCalendarDateFields field) | |
1140 | ||
1141 | { | |
1142 | UErrorCode status = U_ZERO_ERROR; | |
1143 | if (ucal_get(c, UCAL_YEAR, &status) != y || | |
1144 | ucal_get(c, UCAL_MONTH, &status) != m || | |
1145 | ucal_get(c, UCAL_DATE, &status) != d || | |
1146 | ucal_get(c, UCAL_HOUR, &status) != hr || | |
1147 | ucal_get(c, UCAL_MINUTE, &status) != min || | |
1148 | ucal_get(c, UCAL_SECOND, &status) != sec || | |
1149 | ucal_get(c, UCAL_MILLISECOND, &status) != ms) { | |
1150 | log_err("U_FAILURE for field %d, Expected y/m/d h:m:s:ms of %d/%d/%d %d:%d:%d:%d got %d/%d/%d %d:%d:%d:%d\n", | |
1151 | (int32_t)field, y, m + 1, d, hr, min, sec, ms, | |
1152 | ucal_get(c, UCAL_YEAR, &status), | |
1153 | ucal_get(c, UCAL_MONTH, &status) + 1, | |
1154 | ucal_get(c, UCAL_DATE, &status), | |
1155 | ucal_get(c, UCAL_HOUR, &status), | |
1156 | ucal_get(c, UCAL_MINUTE, &status) + 1, | |
1157 | ucal_get(c, UCAL_SECOND, &status), | |
1158 | ucal_get(c, UCAL_MILLISECOND, &status) ); | |
1159 | ||
1160 | if (U_FAILURE(status)){ | |
1161 | log_err("ucal_get failed: %s\n", u_errorName(status)); | |
1162 | return; | |
1163 | } | |
1164 | ||
1165 | } | |
1166 | else | |
1167 | log_verbose("Confirmed: %d/%d/%d %d:%d:%d:%d\n", y, m + 1, d, hr, min, sec, ms); | |
1168 | ||
1169 | } | |
1170 | ||
1171 | /* ------------------------------------- */ | |
1172 | static void checkDate(UCalendar* c, int32_t y, int32_t m, int32_t d) | |
1173 | { | |
1174 | UErrorCode status = U_ZERO_ERROR; | |
1175 | if (ucal_get(c,UCAL_YEAR, &status) != y || | |
1176 | ucal_get(c, UCAL_MONTH, &status) != m || | |
1177 | ucal_get(c, UCAL_DATE, &status) != d) { | |
1178 | ||
1179 | log_err("FAILURE: Expected y/m/d of %d/%d/%d got %d/%d/%d\n", y, m + 1, d, | |
1180 | ucal_get(c, UCAL_YEAR, &status), | |
1181 | ucal_get(c, UCAL_MONTH, &status) + 1, | |
1182 | ucal_get(c, UCAL_DATE, &status) ); | |
1183 | ||
1184 | if (U_FAILURE(status)) { | |
1185 | log_err("ucal_get failed: %s\n", u_errorName(status)); | |
1186 | return; | |
1187 | } | |
1188 | } | |
1189 | else | |
1190 | log_verbose("Confirmed: %d/%d/%d\n", y, m + 1, d); | |
1191 | ||
1192 | ||
1193 | } | |
1194 | ||
1195 | /* ------------------------------------- */ | |
1196 | ||
1197 | /* ------------------------------------- */ | |
1198 | ||
1199 | static void verify1(const char* msg, UCalendar* c, UDateFormat* dat, int32_t year, int32_t month, int32_t day) | |
1200 | { | |
1201 | UDate d1; | |
1202 | UErrorCode status = U_ZERO_ERROR; | |
1203 | if (ucal_get(c, UCAL_YEAR, &status) == year && | |
1204 | ucal_get(c, UCAL_MONTH, &status) == month && | |
1205 | ucal_get(c, UCAL_DATE, &status) == day) { | |
1206 | if (U_FAILURE(status)) { | |
1207 | log_err("FAIL: Calendar::get failed: %s\n", u_errorName(status)); | |
1208 | return; | |
1209 | } | |
1210 | log_verbose("PASS: %s\n", msg); | |
1211 | d1=ucal_getMillis(c, &status); | |
1212 | if (U_FAILURE(status)) { | |
1213 | log_err("ucal_getMillis failed: %s\n", u_errorName(status)); | |
1214 | return; | |
1215 | } | |
1216 | /*log_verbose(austrdup(myDateFormat(dat, d1)) );*/ | |
1217 | } | |
1218 | else { | |
1219 | log_err("FAIL: %s\n", msg); | |
1220 | d1=ucal_getMillis(c, &status); | |
1221 | if (U_FAILURE(status)) { | |
1222 | log_err("ucal_getMillis failed: %s\n", u_errorName(status) ); | |
1223 | return; | |
1224 | } | |
1225 | log_err("Got %s Expected %d/%d/%d \n", austrdup(myDateFormat(dat, d1)), year, month + 1, day ); | |
1226 | return; | |
1227 | } | |
1228 | ||
1229 | ||
1230 | } | |
1231 | ||
1232 | /* ------------------------------------ */ | |
1233 | static void verify2(const char* msg, UCalendar* c, UDateFormat* dat, int32_t year, int32_t month, int32_t day, | |
1234 | int32_t hour, int32_t min, int32_t sec, int32_t am_pm) | |
1235 | { | |
1236 | UDate d1; | |
1237 | UErrorCode status = U_ZERO_ERROR; | |
1238 | char tempMsgBuf[256]; | |
1239 | ||
1240 | if (ucal_get(c, UCAL_YEAR, &status) == year && | |
1241 | ucal_get(c, UCAL_MONTH, &status) == month && | |
1242 | ucal_get(c, UCAL_DATE, &status) == day && | |
1243 | ucal_get(c, UCAL_HOUR, &status) == hour && | |
1244 | ucal_get(c, UCAL_MINUTE, &status) == min && | |
1245 | ucal_get(c, UCAL_SECOND, &status) == sec && | |
1246 | ucal_get(c, UCAL_AM_PM, &status) == am_pm ){ | |
1247 | if (U_FAILURE(status)) { | |
1248 | log_err("FAIL: Calendar::get failed: %s\n", u_errorName(status)); | |
1249 | return; | |
1250 | } | |
1251 | log_verbose("PASS: %s\n", msg); | |
1252 | d1=ucal_getMillis(c, &status); | |
1253 | if (U_FAILURE(status)) { | |
1254 | log_err("ucal_getMillis failed: %s\n", u_errorName(status)); | |
1255 | return; | |
1256 | } | |
1257 | log_verbose("%s\n" , u_austrcpy(tempMsgBuf, myDateFormat(dat, d1)) ); | |
1258 | } | |
1259 | else { | |
1260 | log_err("FAIL: %s\n", msg); | |
1261 | d1=ucal_getMillis(c, &status); | |
1262 | if (U_FAILURE(status)) { | |
1263 | log_err("ucal_getMillis failed: %s\n", u_errorName(status)); | |
1264 | return; | |
1265 | } | |
1266 | log_err("Got %s Expected %d/%d/%d/ %d:%d:%d %s\n", austrdup(myDateFormat(dat, d1)), | |
1267 | year, month + 1, day, hour, min, sec, (am_pm==0) ? "AM": "PM"); | |
1268 | ||
1269 | return; | |
1270 | } | |
1271 | ||
1272 | ||
1273 | } | |
1274 | ||
1275 | #endif /* #if !UCONFIG_NO_FORMATTING */ |