1 /********************************************************************
2 * Copyright (c) 1997-2016, International Business Machines
3 * Corporation and others. All Rights Reserved.
4 ********************************************************************/
6 #include "unicode/utypes.h"
8 #if !UCONFIG_NO_FORMATTING
10 #include "unicode/simpletz.h"
11 #include "unicode/smpdtfmt.h"
12 #include "unicode/strenum.h"
17 // *****************************************************************************
18 // class TimeZoneRegressionTest
19 // *****************************************************************************
20 #define CASE(id,test) case id: name = #test; if (exec) { logln(#test "---"); logln((UnicodeString)""); test(); } break
23 TimeZoneRegressionTest::runIndexedTest( int32_t index
, UBool exec
, const char* &name
, char* /*par*/ )
25 // if (exec) logln((UnicodeString)"TestSuite NumberFormatRegressionTest");
38 CASE(10, Test4154542
);
39 CASE(11, Test4154650
);
40 CASE(12, Test4154525
);
41 CASE(13, Test4162593
);
44 CASE(16, TestJDK12API
);
45 CASE(17, Test4176686
);
46 CASE(18, Test4184229
);
47 default: name
= ""; break;
52 TimeZoneRegressionTest::failure(UErrorCode status
, const char* msg
)
54 if(U_FAILURE(status
)) {
55 errln(UnicodeString("FAIL: ") + msg
+ " failed, error " + u_errorName(status
));
65 void TimeZoneRegressionTest:: Test4052967() {
66 // {sfb} not applicable in C++ ?
67 /*logln("*** CHECK TIMEZONE AGAINST HOST OS SETTING ***");
68 logln("user.timezone:" + System.getProperty("user.timezone", "<not set>"));
69 logln(new Date().toString());
70 logln("*** THE RESULTS OF THIS TEST MUST BE VERIFIED MANUALLY ***");*/
76 void TimeZoneRegressionTest:: Test4073209() {
77 TimeZone
*z1
= TimeZone::createTimeZone("PST");
78 TimeZone
*z2
= TimeZone::createTimeZone("PST");
80 errln("Fail: TimeZone should return clones");
85 UDate
TimeZoneRegressionTest::findTransitionBinary(const SimpleTimeZone
& tz
, UDate min
, UDate max
) {
86 UErrorCode status
= U_ZERO_ERROR
;
87 UBool startsInDST
= tz
.inDaylightTime(min
, status
);
88 if (failure(status
, "SimpleTimeZone::inDaylightTime")) return 0;
89 if (tz
.inDaylightTime(max
, status
) == startsInDST
) {
90 logln((UnicodeString
)"Error: inDaylightTime() != " + ((!startsInDST
)?"TRUE":"FALSE"));
93 if (failure(status
, "SimpleTimeZone::inDaylightTime")) return 0;
94 while ((max
- min
) > 100) { // Min accuracy in ms
95 UDate mid
= (min
+ max
) / 2;
96 if (tz
.inDaylightTime(mid
, status
) == startsInDST
) {
101 if (failure(status
, "SimpleTimeZone::inDaylightTime")) return 0;
103 return (min
+ max
) / 2;
106 UDate
TimeZoneRegressionTest::findTransitionStepwise(const SimpleTimeZone
& tz
, UDate min
, UDate max
) {
107 UErrorCode status
= U_ZERO_ERROR
;
108 UBool startsInDST
= tz
.inDaylightTime(min
, status
);
109 if (failure(status
, "SimpleTimeZone::inDaylightTime")) return 0;
111 if (tz
.inDaylightTime(min
, status
) != startsInDST
) {
114 if (failure(status
, "SimpleTimeZone::inDaylightTime")) return 0;
115 min
+= (UDate
)24*60*60*1000; // one day
123 // {sfb} will this work using a Calendar?
124 void TimeZoneRegressionTest:: Test4073215()
126 UErrorCode status
= U_ZERO_ERROR
;
127 UnicodeString str
, str2
;
128 SimpleTimeZone
*z
= new SimpleTimeZone(0, "GMT");
129 if (z
->useDaylightTime())
130 errln("Fail: Fix test to start with non-DST zone");
131 z
->setStartRule(UCAL_FEBRUARY
, 1, UCAL_SUNDAY
, 0, status
);
132 failure(status
, "z->setStartRule()");
133 z
->setEndRule(UCAL_MARCH
, -1, UCAL_SUNDAY
, 0, status
);
134 failure(status
, "z->setStartRule()");
135 if (!z
->useDaylightTime())
136 errln("Fail: DST not active");
138 GregorianCalendar
cal(1997, UCAL_JANUARY
, 31, status
);
139 if(U_FAILURE(status
)) {
140 dataerrln("Error creating calendar %s", u_errorName(status
));
143 failure(status
, "new GregorianCalendar");
144 cal
.adoptTimeZone(z
);
146 SimpleDateFormat
sdf((UnicodeString
)"E d MMM yyyy G HH:mm", status
);
147 if(U_FAILURE(status
)) {
148 dataerrln("Error creating date format %s", u_errorName(status
));
151 sdf
.setCalendar(cal
);
152 failure(status
, "new SimpleDateFormat");
154 UDate jan31
, mar1
, mar31
;
156 UBool indt
= z
->inDaylightTime(jan31
=cal
.getTime(status
), status
);
157 failure(status
, "inDaylightTime or getTime call on Jan 31");
159 errln("Fail: Jan 31 inDaylightTime=TRUE, exp FALSE");
161 cal
.set(1997, UCAL_MARCH
, 1);
162 indt
= z
->inDaylightTime(mar1
=cal
.getTime(status
), status
);
163 failure(status
, "inDaylightTime or getTime call on Mar 1");
166 sdf
.format(cal
.getTime(status
), str
);
167 failure(status
, "getTime");
168 errln((UnicodeString
)"Fail: " + str
+ " inDaylightTime=FALSE, exp TRUE");
170 cal
.set(1997, UCAL_MARCH
, 31);
171 indt
= z
->inDaylightTime(mar31
=cal
.getTime(status
), status
);
172 failure(status
, "inDaylightTime or getTime call on Mar 31");
174 errln("Fail: Mar 31 inDaylightTime=TRUE, exp FALSE");
178 cal.set(1997, Calendar::DECEMBER, 31);
179 UDate dec31 = cal.getTime(status);
180 failure(status, "getTime");
181 UDate trans = findTransitionStepwise(*z, jan31, dec31);
182 logln((UnicodeString)"Stepwise from " +
183 sdf.format(jan31, str.remove()) + "; transition at " +
184 (trans?sdf.format(trans, str2.remove()):(UnicodeString)"NONE"));
185 trans = findTransitionStepwise(*z, mar1, dec31);
186 logln((UnicodeString)"Stepwise from " +
187 sdf.format(mar1, str.remove()) + "; transition at " +
188 (trans?sdf.format(trans, str2.remove()):(UnicodeString)"NONE"));
189 trans = findTransitionStepwise(*z, mar31, dec31);
190 logln((UnicodeString)"Stepwise from " +
191 sdf.format(mar31, str.remove()) + "; transition at " +
192 (trans?sdf.format(trans, str2.remove()):(UnicodeString)"NONE"));
198 * The expected behavior of TimeZone around the boundaries is:
199 * (Assume transition time of 2:00 AM)
200 * day of onset 1:59 AM STD = display name 1:59 AM ST
201 * 2:00 AM STD = display name 3:00 AM DT
202 * day of end 0:59 AM STD = display name 1:59 AM DT
203 * 1:00 AM STD = display name 1:00 AM ST
205 void TimeZoneRegressionTest:: Test4084933() {
206 UErrorCode status
= U_ZERO_ERROR
;
207 TimeZone
*tz
= TimeZone::createTimeZone("PST");
209 int32_t offset1
= tz
->getOffset(1,
210 1997, UCAL_OCTOBER
, 26, UCAL_SUNDAY
, (2*60*60*1000), status
);
211 int32_t offset2
= tz
->getOffset(1,
212 1997, UCAL_OCTOBER
, 26, UCAL_SUNDAY
, (2*60*60*1000)-1, status
);
214 int32_t offset3
= tz
->getOffset(1,
215 1997, UCAL_OCTOBER
, 26, UCAL_SUNDAY
, (1*60*60*1000), status
);
216 int32_t offset4
= tz
->getOffset(1,
217 1997, UCAL_OCTOBER
, 26, UCAL_SUNDAY
, (1*60*60*1000)-1, status
);
220 * The following was added just for consistency. It shows that going *to* Daylight
221 * Savings Time (PDT) does work at 2am.
223 int32_t offset5
= tz
->getOffset(1,
224 1997, UCAL_APRIL
, 6, UCAL_SUNDAY
, (2*60*60*1000), status
);
225 int32_t offset6
= tz
->getOffset(1,
226 1997, UCAL_APRIL
, 6, UCAL_SUNDAY
, (2*60*60*1000)-1, status
);
227 int32_t offset5a
= tz
->getOffset(1,
228 1997, UCAL_APRIL
, 6, UCAL_SUNDAY
, (3*60*60*1000), status
);
229 int32_t offset6a
= tz
->getOffset(1,
230 1997, UCAL_APRIL
, 6, UCAL_SUNDAY
, (3*60*60*1000)-1, status
);
231 int32_t offset7
= tz
->getOffset(1,
232 1997, UCAL_APRIL
, 6, UCAL_SUNDAY
, (1*60*60*1000), status
);
233 int32_t offset8
= tz
->getOffset(1,
234 1997, UCAL_APRIL
, 6, UCAL_SUNDAY
, (1*60*60*1000)-1, status
);
235 int32_t SToffset
= (int32_t)(-8 * 60*60*1000L);
236 int32_t DToffset
= (int32_t)(-7 * 60*60*1000L);
238 #define ERR_IF_FAIL(x) if(x) { dataerrln("FAIL: TimeZone misbehaving - %s", #x); }
240 ERR_IF_FAIL(U_FAILURE(status
))
241 ERR_IF_FAIL(offset1
!= SToffset
)
242 ERR_IF_FAIL(offset2
!= SToffset
)
243 ERR_IF_FAIL(offset3
!= SToffset
)
244 ERR_IF_FAIL(offset4
!= DToffset
)
245 ERR_IF_FAIL(offset5
!= DToffset
)
246 ERR_IF_FAIL(offset6
!= SToffset
)
247 ERR_IF_FAIL(offset5a
!= DToffset
)
248 ERR_IF_FAIL(offset6a
!= DToffset
)
249 ERR_IF_FAIL(offset7
!= SToffset
)
250 ERR_IF_FAIL(offset8
!= SToffset
)
260 void TimeZoneRegressionTest:: Test4096952() {
261 // {sfb} serialization not applicable
263 UnicodeString ZONES [] = { UnicodeString("GMT"), UnicodeString("MET"), UnicodeString("IST") };
266 for (int32_t i=0; i < ZONES.length; ++i) {
267 TimeZone *zone = TimeZone::createTimeZone(ZONES[i]);
269 if (zone->getID(id) != ZONES[i])
270 errln("Fail: Test broken; zones not instantiating");
272 ByteArrayOutputStream baos;
273 ObjectOutputStream ostream =
274 new ObjectOutputStream(baos = new
275 ByteArrayOutputStream());
276 ostream.writeObject(zone);
279 ObjectInputStream istream =
280 new ObjectInputStream(new
281 ByteArrayInputStream(baos.toByteArray()));
282 TimeZone frankenZone = (TimeZone) istream.readObject();
283 //logln("Zone: " + zone);
284 //logln("FrankenZone: " + frankenZone);
285 if (!zone.equals(frankenZone)) {
286 logln("TimeZone " + zone.getID() +
287 " not equal to serialized/deserialized one");
291 if (!pass) errln("Fail: TimeZone serialization/equality bug");
293 catch (IOException e) {
295 e.print32_tStackTrace();
297 catch (ClassNotFoundException e) {
299 e.print32_tStackTrace();
307 void TimeZoneRegressionTest:: Test4109314() {
308 UErrorCode status
= U_ZERO_ERROR
;
309 GregorianCalendar
*testCal
= (GregorianCalendar
*)Calendar::createInstance(status
);
310 if(U_FAILURE(status
)) {
311 dataerrln("Error creating calendar %s", u_errorName(status
));
315 failure(status
, "Calendar::createInstance");
316 TimeZone
*PST
= TimeZone::createTimeZone("PST");
317 /*Object[] testData = {
318 PST, new Date(98,Calendar.APRIL,4,22,0), new Date(98, Calendar.APRIL, 5,6,0),
319 PST, new Date(98,Calendar.OCTOBER,24,22,0), new Date(98,Calendar.OCTOBER,25,6,0),
321 UDate testData
[] = {
322 CalendarRegressionTest::makeDate(98,UCAL_APRIL
,4,22,0),
323 CalendarRegressionTest::makeDate(98, UCAL_APRIL
,5,6,0),
324 CalendarRegressionTest::makeDate(98,UCAL_OCTOBER
,24,22,0),
325 CalendarRegressionTest::makeDate(98,UCAL_OCTOBER
,25,6,0)
328 for (int32_t i
= 0; i
< 4; i
+=2) {
329 //testCal->setTimeZone((TimeZone) testData[i]);
330 testCal
->setTimeZone(*PST
);
331 UDate t
= testData
[i
];
332 UDate end
= testData
[i
+1];
333 while(testCal
->getTime(status
) < end
) {
334 testCal
->setTime(t
, status
);
335 if ( ! checkCalendar314(testCal
, PST
))
341 errln("Fail: TZ API inconsistent");
348 TimeZoneRegressionTest::checkCalendar314(GregorianCalendar
*testCal
, TimeZone
*testTZ
)
350 UErrorCode status
= U_ZERO_ERROR
;
351 // GregorianCalendar testCal = (GregorianCalendar)aCal.clone();
353 int32_t tzOffset
, tzRawOffset
;
354 float tzOffsetFloat
,tzRawOffsetFloat
;
355 // Here is where the user made an error. They were passing in the value of
356 // the MILLSECOND field; you need to pass in the millis in the day in STANDARD
358 UDate millis
= testCal
->get(UCAL_MILLISECOND
, status
) +
359 1000.0 * (testCal
->get(UCAL_SECOND
, status
) +
360 60.0 * (testCal
->get(UCAL_MINUTE
, status
) +
361 60.0 * (testCal
->get(UCAL_HOUR_OF_DAY
, status
)))) -
362 testCal
->get(UCAL_DST_OFFSET
, status
);
364 /* Fix up millis to be in range. ASSUME THAT WE ARE NOT AT THE
365 * BEGINNING OR END OF A MONTH. We must add this code because
366 * getOffset() has been changed to be more strict about the parameters
367 * it receives -- it turns out that this test was passing in illegal
369 int32_t date
= testCal
->get(UCAL_DATE
, status
);
370 int32_t dow
= testCal
->get(UCAL_DAY_OF_WEEK
, status
);
372 millis
+= U_MILLIS_PER_DAY
;
374 dow
= UCAL_SUNDAY
+ ((dow
- UCAL_SUNDAY
+ 6) % 7);
376 while (millis
>= U_MILLIS_PER_DAY
) {
377 millis
-= U_MILLIS_PER_DAY
;
379 dow
= UCAL_SUNDAY
+ ((dow
- UCAL_SUNDAY
+ 1) % 7);
382 tzOffset
= testTZ
->getOffset((uint8_t)testCal
->get(UCAL_ERA
, status
),
383 testCal
->get(UCAL_YEAR
, status
),
384 testCal
->get(UCAL_MONTH
, status
),
389 tzRawOffset
= testTZ
->getRawOffset();
390 tzOffsetFloat
= (float)tzOffset
/(float)3600000;
391 tzRawOffsetFloat
= (float)tzRawOffset
/(float)3600000;
393 UDate testDate
= testCal
->getTime(status
);
395 UBool inDaylightTime
= testTZ
->inDaylightTime(testDate
, status
);
396 SimpleDateFormat
*sdf
= new SimpleDateFormat((UnicodeString
)"MM/dd/yyyy HH:mm", status
);
397 sdf
->setCalendar(*testCal
);
398 UnicodeString inDaylightTimeString
;
404 inDaylightTimeString
= " DST ";
405 passed
= (tzOffset
== (tzRawOffset
+ 3600000));
409 inDaylightTimeString
= " ";
410 passed
= (tzOffset
== tzRawOffset
);
413 UnicodeString output
;
414 FieldPosition
pos(0);
415 output
= testTZ
->getID(output
) + " " + sdf
->format(testDate
, output
, pos
) +
416 " Offset(" + tzOffsetFloat
+ ")" +
417 " RawOffset(" + tzRawOffsetFloat
+ ")" +
418 " " + millis
/(float)3600000 + " " +
419 inDaylightTimeString
;
439 * Yet another _alleged_ bug in TimeZone::getOffset(), a method that never
440 * should have been made public. It's simply too hard to use correctly.
442 * The original test code failed to do the following:
443 * (1) Call Calendar::setTime() before getting the fields!
444 * (2) Use the right millis (as usual) for getOffset(); they were passing
445 * in the MILLIS field, instead of the STANDARD MILLIS IN DAY.
446 * When you fix these two problems, the test passes, as expected.
448 void TimeZoneRegressionTest:: Test4126678()
450 UErrorCode status
= U_ZERO_ERROR
;
451 Calendar
*cal
= Calendar::createInstance(status
);
452 if(U_FAILURE(status
)) {
453 dataerrln("Error creating calendar %s", u_errorName(status
));
457 failure(status
, "Calendar::createInstance");
458 TimeZone
*tz
= TimeZone::createTimeZone("PST");
459 cal
->adoptTimeZone(tz
);
461 cal
->set(1998, UCAL_APRIL
, 5, 10, 0);
463 if (! tz
->useDaylightTime() || U_FAILURE(status
))
464 dataerrln("We're not in Daylight Savings Time and we should be. - %s", u_errorName(status
));
467 int32_t era
= cal
->get(UCAL_ERA
, status
);
468 int32_t year
= cal
->get(UCAL_YEAR
, status
);
469 int32_t month
= cal
->get(UCAL_MONTH
, status
);
470 int32_t day
= cal
->get(UCAL_DATE
, status
);
471 int32_t dayOfWeek
= cal
->get(UCAL_DAY_OF_WEEK
, status
);
472 int32_t millis
= cal
->get(UCAL_MILLISECOND
, status
) +
473 (cal
->get(UCAL_SECOND
, status
) +
474 (cal
->get(UCAL_MINUTE
, status
) +
475 (cal
->get(UCAL_HOUR
, status
) * 60) * 60) * 1000) -
476 cal
->get(UCAL_DST_OFFSET
, status
);
478 failure(status
, "cal->get");
479 int32_t offset
= tz
->getOffset((uint8_t)era
, year
, month
, day
, (uint8_t)dayOfWeek
, millis
, status
);
480 int32_t raw_offset
= tz
->getRawOffset();
482 if (offset
== raw_offset
)
483 dataerrln("Offsets should match");
490 * TimeZone::getAvailableIDs(int32_t) throws exception for certain values,
491 * due to a faulty constant in TimeZone::java.
493 void TimeZoneRegressionTest:: Test4151406() {
495 for (int32_t h
=-28; h
<=30; ++h
) {
496 // h is in half-hours from GMT; rawoffset is in millis
497 int32_t rawoffset
= h
* 1800000;
498 int32_t hh
= (h
<0) ? -h
: h
;
499 UnicodeString hname
= UnicodeString((h
<0) ? "GMT-" : "GMT+") +
500 ((hh
/2 < 10) ? "0" : "") +
502 ((hh%2
==0) ? "00" : "30");
504 UErrorCode ec
= U_ZERO_ERROR
;
506 StringEnumeration
* ids
= TimeZone::createEnumeration(rawoffset
);
508 dataerrln("Fail: TimeZone::createEnumeration(rawoffset)");
511 count
= ids
->count(ec
);
515 logln(hname
+ ' ' + (UnicodeString
)count
+ (UnicodeString
)" e.g. " + *ids
->snext(ec
));
517 logln(hname
+ ' ' + count
);
519 // weiv 11/27/2002: why uprv_free? This should be a delete
523 /*} catch (Exception e) {
524 errln(hname + ' ' + "Fail: " + e);
527 logln("Maximum zones per offset = %d", max
);
533 void TimeZoneRegressionTest:: Test4151429() {
534 // {sfb} silly test in C++, since we are using an enum and not an int
536 /*TimeZone *tz = TimeZone::createTimeZone("GMT");
538 tz->getDisplayName(TRUE, TimeZone::LONG,
539 Locale.getDefault(), name);
540 errln("IllegalArgumentException not thrown by TimeZone::getDisplayName()");*/
541 //} catch(IllegalArgumentException e) {}
546 * SimpleTimeZone::hasSameRules() doesn't work for zones with no DST
547 * and different DST parameters.
549 void TimeZoneRegressionTest:: Test4154537() {
550 UErrorCode status
= U_ZERO_ERROR
;
551 // tz1 and tz2 have no DST and different rule parameters
552 SimpleTimeZone
*tz1
= new SimpleTimeZone(0, "1", 0, 0, 0, 0, 2, 0, 0, 0, status
);
553 SimpleTimeZone
*tz2
= new SimpleTimeZone(0, "2", 1, 0, 0, 0, 3, 0, 0, 0, status
);
554 // tza and tzA have the same rule params
555 SimpleTimeZone
*tza
= new SimpleTimeZone(0, "a", 0, 1, 0, 0, 3, 2, 0, 0, status
);
556 SimpleTimeZone
*tzA
= new SimpleTimeZone(0, "A", 0, 1, 0, 0, 3, 2, 0, 0, status
);
557 // tzb differs from tza
558 SimpleTimeZone
*tzb
= new SimpleTimeZone(0, "b", 0, 1, 0, 0, 3, 1, 0, 0, status
);
560 if(U_FAILURE(status
))
561 errln("Couldn't create TimeZones");
563 if (tz1
->useDaylightTime() || tz2
->useDaylightTime() ||
564 !tza
->useDaylightTime() || !tzA
->useDaylightTime() ||
565 !tzb
->useDaylightTime()) {
566 errln("Test is broken -- rewrite it");
568 if (!tza
->hasSameRules(*tzA
) || tza
->hasSameRules(*tzb
)) {
569 errln("Fail: hasSameRules() broken for zones with rules");
571 if (!tz1
->hasSameRules(*tz2
)) {
572 errln("Fail: hasSameRules() returns false for zones without rules");
573 //errln("zone 1 = " + tz1);
574 //errln("zone 2 = " + tz2);
586 * SimpleTimeZOne constructors, setStartRule(), and setEndRule() don't
587 * check for out-of-range arguments.
589 void TimeZoneRegressionTest:: Test4154542()
591 const int32_t GOOD
= 1;
592 const int32_t BAD
= 0;
594 const int32_t GOOD_MONTH
= UCAL_JANUARY
;
595 const int32_t GOOD_DAY
= 1;
596 const int32_t GOOD_DAY_OF_WEEK
= UCAL_SUNDAY
;
597 const int32_t GOOD_TIME
= 0;
600 GOOD
, INT32_MIN
, 0, INT32_MAX
, INT32_MIN
,
601 GOOD
, UCAL_JANUARY
, -5, UCAL_SUNDAY
, 0,
602 GOOD
, UCAL_DECEMBER
, 5, UCAL_SATURDAY
, 24*60*60*1000,
603 BAD
, UCAL_DECEMBER
, 5, UCAL_SATURDAY
, 24*60*60*1000+1,
604 BAD
, UCAL_DECEMBER
, 5, UCAL_SATURDAY
, -1,
605 BAD
, UCAL_JANUARY
, -6, UCAL_SUNDAY
, 0,
606 BAD
, UCAL_DECEMBER
, 6, UCAL_SATURDAY
, 24*60*60*1000,
607 GOOD
, UCAL_DECEMBER
, 1, 0, 0,
608 GOOD
, UCAL_DECEMBER
, 31, 0, 0,
609 BAD
, UCAL_APRIL
, 31, 0, 0,
610 BAD
, UCAL_DECEMBER
, 32, 0, 0,
611 BAD
, UCAL_JANUARY
-1, 1, UCAL_SUNDAY
, 0,
612 BAD
, UCAL_DECEMBER
+1, 1, UCAL_SUNDAY
, 0,
613 GOOD
, UCAL_DECEMBER
, 31, -UCAL_SUNDAY
, 0,
614 GOOD
, UCAL_DECEMBER
, 31, -UCAL_SATURDAY
, 0,
615 BAD
, UCAL_DECEMBER
, 32, -UCAL_SATURDAY
, 0,
616 BAD
, UCAL_DECEMBER
, -32, -UCAL_SATURDAY
, 0,
617 BAD
, UCAL_DECEMBER
, 31, -UCAL_SATURDAY
-1, 0,
619 SimpleTimeZone
*zone
= new SimpleTimeZone(0, "Z");
620 for (int32_t i
=0; i
< 18*5; i
+=5) {
621 UBool shouldBeGood
= (DATA
[i
] == GOOD
);
622 int32_t month
= DATA
[i
+1];
623 int32_t day
= DATA
[i
+2];
624 int32_t dayOfWeek
= DATA
[i
+3];
625 int32_t time
= DATA
[i
+4];
627 UErrorCode status
= U_ZERO_ERROR
;
629 //Exception ex = null;
631 zone
->setStartRule(month
, day
, dayOfWeek
, time
, status
);
632 //} catch (IllegalArgumentException e) {
635 if (U_SUCCESS(status
) != shouldBeGood
) {
636 errln(UnicodeString("setStartRule(month=") + month
+ ", day=" + day
+
637 ", dayOfWeek=" + dayOfWeek
+ ", time=" + time
+
638 (shouldBeGood
? (") should work")
639 : ") should fail but doesn't"));
644 status
= U_ZERO_ERROR
;
645 zone
->setEndRule(month
, day
, dayOfWeek
, time
, status
);
646 //} catch (IllegalArgumentException e) {
649 if (U_SUCCESS(status
) != shouldBeGood
) {
650 errln(UnicodeString("setEndRule(month=") + month
+ ", day=" + day
+
651 ", dayOfWeek=" + dayOfWeek
+ ", time=" + time
+
652 (shouldBeGood
? (") should work")
653 : ") should fail but doesn't"));
658 // {sfb} need to look into ctor problems! (UErrorCode vs. dst signature confusion)
659 status
= U_ZERO_ERROR
;
660 SimpleTimeZone
*temp
= new SimpleTimeZone(0, "Z",
661 (int8_t)month
, (int8_t)day
, (int8_t)dayOfWeek
, time
,
662 (int8_t)GOOD_MONTH
, (int8_t)GOOD_DAY
, (int8_t)GOOD_DAY_OF_WEEK
,
664 //} catch (IllegalArgumentException e) {
667 if (U_SUCCESS(status
) != shouldBeGood
) {
668 errln(UnicodeString("SimpleTimeZone(month=") + month
+ ", day=" + day
+
669 ", dayOfWeek=" + dayOfWeek
+ ", time=" + time
+
670 (shouldBeGood
? (", <end>) should work")// + ex)
671 : ", <end>) should fail but doesn't"));
677 status
= U_ZERO_ERROR
;
678 temp
= new SimpleTimeZone(0, "Z",
679 (int8_t)GOOD_MONTH
, (int8_t)GOOD_DAY
, (int8_t)GOOD_DAY_OF_WEEK
,
681 (int8_t)month
, (int8_t)day
, (int8_t)dayOfWeek
, time
,status
);
682 //} catch (IllegalArgumentException e) {
685 if (U_SUCCESS(status
) != shouldBeGood
) {
686 errln(UnicodeString("SimpleTimeZone(<start>, month=") + month
+ ", day=" + day
+
687 ", dayOfWeek=" + dayOfWeek
+ ", time=" + time
+
688 (shouldBeGood
? (") should work")// + ex)
689 : ") should fail but doesn't"));
699 * SimpleTimeZone accepts illegal DST savings values. These values
700 * must be non-zero. There is no upper limit at this time.
703 TimeZoneRegressionTest::Test4154525()
705 const int32_t GOOD
= 1, BAD
= 0;
713 // Integer.MAX_VALUE, ?, // no upper limit on DST savings at this time
716 UErrorCode status
= U_ZERO_ERROR
;
717 for(int32_t i
= 0; i
< 10; i
+=2) {
718 int32_t savings
= DATA
[i
];
719 UBool valid
= DATA
[i
+1] == GOOD
;
720 UnicodeString method
;
721 for(int32_t j
=0; j
< 2; ++j
) {
722 SimpleTimeZone
*z
=NULL
;
725 method
= "constructor";
726 z
= new SimpleTimeZone(0, "id",
727 UCAL_JANUARY
, 1, 0, 0,
729 savings
, status
); // <- what we're interested in
732 method
= "setDSTSavings()";
733 z
= new SimpleTimeZone(0, "GMT");
734 z
->setDSTSavings(savings
, status
);
738 if(U_FAILURE(status
)) {
740 errln(UnicodeString("Fail: DST savings of ") + savings
+ " to " + method
+ " gave " + u_errorName(status
));
743 logln(UnicodeString("Pass: DST savings of ") + savings
+ " to " + method
+ " gave " + u_errorName(status
));
748 logln(UnicodeString("Pass: DST savings of ") + savings
+ " accepted by " + method
);
751 errln(UnicodeString("Fail: DST savings of ") + savings
+ " accepted by " + method
);
754 status
= U_ZERO_ERROR
;
762 * SimpleTimeZone.getOffset accepts illegal arguments.
765 TimeZoneRegressionTest::Test4154650()
767 const int32_t GOOD
= 1, BAD
= 0;
768 const int32_t GOOD_ERA
= GregorianCalendar::AD
, GOOD_YEAR
= 1998, GOOD_MONTH
= UCAL_AUGUST
;
769 const int32_t GOOD_DAY
= 2, GOOD_DOW
= UCAL_SUNDAY
, GOOD_TIME
= 16*3600000;
772 GOOD
, GOOD_ERA
, GOOD_YEAR
, GOOD_MONTH
, GOOD_DAY
, GOOD_DOW
, GOOD_TIME
,
774 GOOD
, GregorianCalendar::BC
, GOOD_YEAR
, GOOD_MONTH
, GOOD_DAY
, GOOD_DOW
, GOOD_TIME
,
775 GOOD
, GregorianCalendar::AD
, GOOD_YEAR
, GOOD_MONTH
, GOOD_DAY
, GOOD_DOW
, GOOD_TIME
,
776 BAD
, GregorianCalendar::BC
-1, GOOD_YEAR
, GOOD_MONTH
, GOOD_DAY
, GOOD_DOW
, GOOD_TIME
,
777 BAD
, GregorianCalendar::AD
+1, GOOD_YEAR
, GOOD_MONTH
, GOOD_DAY
, GOOD_DOW
, GOOD_TIME
,
779 GOOD
, GOOD_ERA
, GOOD_YEAR
, UCAL_JANUARY
, GOOD_DAY
, GOOD_DOW
, GOOD_TIME
,
780 GOOD
, GOOD_ERA
, GOOD_YEAR
, UCAL_DECEMBER
, GOOD_DAY
, GOOD_DOW
, GOOD_TIME
,
781 BAD
, GOOD_ERA
, GOOD_YEAR
, UCAL_JANUARY
-1, GOOD_DAY
, GOOD_DOW
, GOOD_TIME
,
782 BAD
, GOOD_ERA
, GOOD_YEAR
, UCAL_DECEMBER
+1, GOOD_DAY
, GOOD_DOW
, GOOD_TIME
,
784 GOOD
, GOOD_ERA
, GOOD_YEAR
, UCAL_JANUARY
, 1, GOOD_DOW
, GOOD_TIME
,
785 GOOD
, GOOD_ERA
, GOOD_YEAR
, UCAL_JANUARY
, 31, GOOD_DOW
, GOOD_TIME
,
786 BAD
, GOOD_ERA
, GOOD_YEAR
, UCAL_JANUARY
, 0, GOOD_DOW
, GOOD_TIME
,
787 BAD
, GOOD_ERA
, GOOD_YEAR
, UCAL_JANUARY
, 32, GOOD_DOW
, GOOD_TIME
,
789 GOOD
, GOOD_ERA
, GOOD_YEAR
, GOOD_MONTH
, GOOD_DAY
, UCAL_SUNDAY
, GOOD_TIME
,
790 GOOD
, GOOD_ERA
, GOOD_YEAR
, GOOD_MONTH
, GOOD_DAY
, UCAL_SATURDAY
, GOOD_TIME
,
791 BAD
, GOOD_ERA
, GOOD_YEAR
, GOOD_MONTH
, GOOD_DAY
, UCAL_SUNDAY
-1, GOOD_TIME
,
792 BAD
, GOOD_ERA
, GOOD_YEAR
, GOOD_MONTH
, GOOD_DAY
, UCAL_SATURDAY
+1, GOOD_TIME
,
794 GOOD
, GOOD_ERA
, GOOD_YEAR
, GOOD_MONTH
, GOOD_DAY
, GOOD_DOW
, 0,
795 GOOD
, GOOD_ERA
, GOOD_YEAR
, GOOD_MONTH
, GOOD_DAY
, GOOD_DOW
, 24*3600000-1,
796 BAD
, GOOD_ERA
, GOOD_YEAR
, GOOD_MONTH
, GOOD_DAY
, GOOD_DOW
, -1,
797 BAD
, GOOD_ERA
, GOOD_YEAR
, GOOD_MONTH
, GOOD_DAY
, GOOD_DOW
, 24*3600000,
800 int32_t dataLen
= UPRV_LENGTHOF(DATA
);
802 UErrorCode status
= U_ZERO_ERROR
;
803 TimeZone
*tz
= TimeZone::createDefault();
804 for(int32_t i
= 0; i
< dataLen
; i
+= 7) {
805 UBool good
= DATA
[i
] == GOOD
;
806 //IllegalArgumentException e = null;
808 /*int32_t offset = */
809 tz
->getOffset((uint8_t)DATA
[i
+1], DATA
[i
+2], DATA
[i
+3],
810 DATA
[i
+4], (uint8_t)DATA
[i
+5], DATA
[i
+6], status
);
811 //} catch (IllegalArgumentException ex) {
814 if(good
!= U_SUCCESS(status
)) {
815 UnicodeString errMsg
;
817 errMsg
= (UnicodeString(") threw ") + u_errorName(status
));
820 errMsg
= UnicodeString(") accepts invalid args", "");
822 errln(UnicodeString("Fail: getOffset(") +
823 DATA
[i
+1] + ", " + DATA
[i
+2] + ", " + DATA
[i
+3] + ", " +
824 DATA
[i
+4] + ", " + DATA
[i
+5] + ", " + DATA
[i
+6] +
827 status
= U_ZERO_ERROR
; // reset
834 * TimeZone broken at midnight. The TimeZone code fails to handle
835 * transitions at midnight correctly.
838 TimeZoneRegressionTest::Test4162593()
840 UErrorCode status
= U_ZERO_ERROR
;
841 SimpleDateFormat
*fmt
= new SimpleDateFormat("z", Locale::getUS(), status
);
842 if(U_FAILURE(status
)) {
843 dataerrln("Error creating calendar %s", u_errorName(status
));
847 const int32_t ONE_HOUR
= 60*60*1000;
849 SimpleTimeZone
*asuncion
= new SimpleTimeZone(-4*ONE_HOUR
, "America/Asuncion" /*PY%sT*/,
850 UCAL_OCTOBER
, 1, 0 /*DOM*/, 0*ONE_HOUR
,
851 UCAL_MARCH
, 1, 0 /*DOM*/, 0*ONE_HOUR
, 1*ONE_HOUR
, status
);
855 * Transition expected between start+1H and start+2H
857 TimeZone
*DATA_TZ
[] = {
860 int32_t DATA_INT
[] [5] = {
861 // These years must be AFTER the Gregorian cutover
862 {1998, UCAL_SEPTEMBER
, 30, 22, 0},
863 {2000, UCAL_FEBRUARY
, 28, 22, 0},
864 {2000, UCAL_FEBRUARY
, 29, 22, 0},
867 UBool DATA_BOOL
[] = {
873 UnicodeString zone
[4];// = new String[4];
875 new SimpleTimeZone(2*ONE_HOUR
, "Asia/Damascus" /*EE%sT*/,
876 UCAL_APRIL
, 1, 0 /*DOM*/, 0*ONE_HOUR
,
877 UCAL_OCTOBER
, 1, 0 /*DOM*/, 0*ONE_HOUR
, 1*ONE_HOUR
, status
);
878 DATA_TZ
[1] = asuncion
; DATA_TZ
[2] = asuncion
;
880 for(int32_t j
= 0; j
< 3; j
++) {
881 TimeZone
*tz
= (TimeZone
*)DATA_TZ
[j
];
882 TimeZone::setDefault(*tz
);
883 fmt
->setTimeZone(*tz
);
885 // Must construct the Date object AFTER setting the default zone
886 int32_t *p
= (int32_t*)DATA_INT
[j
];
887 UDate d
= CalendarRegressionTest::makeDate(p
[0], p
[1], p
[2], p
[3], p
[4]);
888 UBool transitionExpected
= DATA_BOOL
[j
];
891 logln(tz
->getID(temp
) + ":");
892 for (int32_t i
= 0; i
< 4; ++i
) {
893 FieldPosition
pos(0);
895 zone
[i
] = fmt
->format(d
+ i
*ONE_HOUR
, zone
[i
], pos
);
896 logln(UnicodeString("") + i
+ ": " + d
+ " / " + zone
[i
]);
897 //d += (double) ONE_HOUR;
899 if(zone
[0] == zone
[1] &&
900 (zone
[1] == zone
[2]) != transitionExpected
&&
901 zone
[2] == zone
[3]) {
902 logln(UnicodeString("Ok: transition ") + transitionExpected
);
905 errln("Fail: boundary transition incorrect");
914 * getDisplayName doesn't work with unusual savings/offsets.
916 void TimeZoneRegressionTest::Test4176686() {
917 // Construct a zone that does not observe DST but
918 // that does have a DST savings (which should be ignored).
919 UErrorCode status
= U_ZERO_ERROR
;
920 int32_t offset
= 90 * 60000; // 1:30
921 SimpleTimeZone
* z1
= new SimpleTimeZone(offset
, "_std_zone_");
922 z1
->setDSTSavings(45 * 60000, status
); // 0:45
924 // Construct a zone that observes DST for the first 6 months.
925 SimpleTimeZone
* z2
= new SimpleTimeZone(offset
, "_dst_zone_");
926 z2
->setDSTSavings(45 * 60000, status
); // 0:45
927 z2
->setStartRule(UCAL_JANUARY
, 1, 0, status
);
928 z2
->setEndRule(UCAL_JULY
, 1, 0, status
);
930 // Also check DateFormat
931 DateFormat
* fmt1
= new SimpleDateFormat(UnicodeString("z"), status
);
932 if (U_FAILURE(status
)) {
933 dataerrln("Failure trying to construct: %s", u_errorName(status
));
936 fmt1
->setTimeZone(*z1
); // Format uses standard zone
937 DateFormat
* fmt2
= new SimpleDateFormat(UnicodeString("z"), status
);
938 if(!assertSuccess("trying to construct", status
))return;
939 fmt2
->setTimeZone(*z2
); // Format uses DST zone
940 Calendar
* tempcal
= Calendar::createInstance(status
);
942 tempcal
->set(1970, UCAL_FEBRUARY
, 1);
943 UDate dst
= tempcal
->getTime(status
); // Time in DST
944 tempcal
->set(1970, UCAL_AUGUST
, 1);
945 UDate std
= tempcal
->getTime(status
); // Time in standard
947 // Description, Result, Expected Result
948 UnicodeString a
,b
,c
,d
,e
,f
,g
,h
,i
,j
,k
,l
;
949 UnicodeString DATA
[] = {
950 "z1->getDisplayName(false, SHORT)/std zone",
951 z1
->getDisplayName(FALSE
, TimeZone::SHORT
, a
), "GMT+1:30",
952 "z1->getDisplayName(false, LONG)/std zone",
953 z1
->getDisplayName(FALSE
, TimeZone::LONG
, b
), "GMT+01:30",
954 "z1->getDisplayName(true, SHORT)/std zone",
955 z1
->getDisplayName(TRUE
, TimeZone::SHORT
, c
), "GMT+1:30",
956 "z1->getDisplayName(true, LONG)/std zone",
957 z1
->getDisplayName(TRUE
, TimeZone::LONG
, d
), "GMT+01:30",
958 "z2->getDisplayName(false, SHORT)/dst zone",
959 z2
->getDisplayName(FALSE
, TimeZone::SHORT
, e
), "GMT+1:30",
960 "z2->getDisplayName(false, LONG)/dst zone",
961 z2
->getDisplayName(FALSE
, TimeZone::LONG
, f
), "GMT+01:30",
962 "z2->getDisplayName(true, SHORT)/dst zone",
963 z2
->getDisplayName(TRUE
, TimeZone::SHORT
, g
), "GMT+2:15",
964 "z2->getDisplayName(true, LONG)/dst zone",
965 z2
->getDisplayName(TRUE
, TimeZone::LONG
, h
), "GMT+02:15",
966 "DateFormat.format(std)/std zone", fmt1
->format(std
, i
), "GMT+1:30",
967 "DateFormat.format(dst)/std zone", fmt1
->format(dst
, j
), "GMT+1:30",
968 "DateFormat.format(std)/dst zone", fmt2
->format(std
, k
), "GMT+1:30",
969 "DateFormat.format(dst)/dst zone", fmt2
->format(dst
, l
), "GMT+2:15",
972 for (int32_t idx
=0; idx
<UPRV_LENGTHOF(DATA
); idx
+=3) {
973 if (DATA
[idx
+1]!=(DATA
[idx
+2])) {
974 errln("FAIL: " + DATA
[idx
] + " -> " + DATA
[idx
+1] + ", exp " + DATA
[idx
+2]);
985 * Make sure setStartRule and setEndRule set the DST savings to nonzero
988 void TimeZoneRegressionTest::TestJ186() {
989 UErrorCode status
= U_ZERO_ERROR
;
990 // NOTE: Setting the DST savings to zero is illegal, so we
991 // are limited in the testing we can do here. This is why
992 // lines marked //~ are commented out.
993 SimpleTimeZone
z(0, "ID");
994 //~z.setDSTSavings(0, status); // Must do this!
995 z
.setStartRule(UCAL_FEBRUARY
, 1, UCAL_SUNDAY
, 0, status
);
996 failure(status
, "setStartRule()");
997 if (z
.useDaylightTime()) {
998 errln("Fail: useDaylightTime true with start rule only");
1000 //~if (z.getDSTSavings() != 0) {
1001 //~ errln("Fail: dst savings != 0 with start rule only");
1003 z
.setEndRule(UCAL_MARCH
, -1, UCAL_SUNDAY
, 0, status
);
1004 failure(status
, "setStartRule()");
1005 if (!z
.useDaylightTime()) {
1006 errln("Fail: useDaylightTime false with rules set");
1008 if (z
.getDSTSavings() == 0) {
1009 errln("Fail: dst savings == 0 with rules set");
1014 * Test to see if DateFormat understands zone equivalency groups. It
1015 * might seem that this should be a DateFormat test, but it's really a
1016 * TimeZone test -- the changes to DateFormat are minor.
1018 * We use two known, stable zones that shouldn't change much over time
1019 * -- America/Vancouver and America/Los_Angeles. However, they MAY
1020 * change at some point -- if that happens, replace them with any two
1021 * zones in an equivalency group where one zone has localized name
1022 * data, and the other doesn't, in some locale.
1024 void TimeZoneRegressionTest::TestJ449() {
1025 UErrorCode status
= U_ZERO_ERROR
;
1028 // Modify the following three as necessary. The two IDs must
1029 // specify two zones in the same equivalency group. One must have
1030 // locale data in 'loc'; the other must not.
1031 const char* idWithLocaleData
= "America/Los_Angeles";
1032 const char* idWithoutLocaleData
= "US/Pacific";
1033 const Locale
loc("en", "", "");
1035 TimeZone
*zoneWith
= TimeZone::createTimeZone(idWithLocaleData
);
1036 TimeZone
*zoneWithout
= TimeZone::createTimeZone(idWithoutLocaleData
);
1037 // Make sure we got valid zones
1038 if (zoneWith
->getID(str
) != UnicodeString(idWithLocaleData
) ||
1039 zoneWithout
->getID(str
) != UnicodeString(idWithoutLocaleData
)) {
1040 dataerrln(UnicodeString("Fail: Unable to create zones - wanted ") + idWithLocaleData
+ ", got " + zoneWith
->getID(str
) + ", and wanted " + idWithoutLocaleData
+ " but got " + zoneWithout
->getID(str
));
1042 GregorianCalendar
calWith(*zoneWith
, status
);
1043 GregorianCalendar
calWithout(*zoneWithout
, status
);
1044 SimpleDateFormat
fmt("MMM d yyyy hh:mm a zzz", loc
, status
);
1045 if (U_FAILURE(status
)) {
1046 errln("Fail: Unable to create GregorianCalendar/SimpleDateFormat");
1049 UnicodeString strWith
, strWithout
;
1050 fmt
.setCalendar(calWith
);
1051 fmt
.format(date
, strWith
);
1052 fmt
.setCalendar(calWithout
);
1053 fmt
.format(date
, strWithout
);
1054 if (strWith
== strWithout
) {
1055 logln((UnicodeString
)"Ok: " + idWithLocaleData
+ " -> " +
1056 strWith
+ "; " + idWithoutLocaleData
+ " -> " +
1059 errln((UnicodeString
)"FAIL: " + idWithLocaleData
+ " -> " +
1060 strWith
+ "; " + idWithoutLocaleData
+ " -> " +
1070 // test new API for JDK 1.2 8/31 putback
1072 TimeZoneRegressionTest::TestJDK12API()
1074 // TimeZone *pst = TimeZone::createTimeZone("PST");
1075 // TimeZone *cst1 = TimeZone::createTimeZone("CST");
1076 UErrorCode ec
= U_ZERO_ERROR
;
1077 //d,-28800,3,1,-1,120,w,9,-1,1,120,w,60
1078 TimeZone
*pst
= new SimpleTimeZone(-28800*U_MILLIS_PER_SECOND
,
1080 3,1,-1,120*U_MILLIS_PER_MINUTE
,
1081 SimpleTimeZone::WALL_TIME
,
1082 9,-1,1,120*U_MILLIS_PER_MINUTE
,
1083 SimpleTimeZone::WALL_TIME
,
1084 60*U_MILLIS_PER_MINUTE
,ec
);
1085 //d,-21600,3,1,-1,120,w,9,-1,1,120,w,60
1086 TimeZone
*cst1
= new SimpleTimeZone(-21600*U_MILLIS_PER_SECOND
,
1088 3,1,-1,120*U_MILLIS_PER_MINUTE
,
1089 SimpleTimeZone::WALL_TIME
,
1090 9,-1,1,120*U_MILLIS_PER_MINUTE
,
1091 SimpleTimeZone::WALL_TIME
,
1092 60*U_MILLIS_PER_MINUTE
,ec
);
1093 if (U_FAILURE(ec
)) {
1094 errln("FAIL: SimpleTimeZone constructor");
1098 SimpleTimeZone
*cst
= dynamic_cast<SimpleTimeZone
*>(cst1
);
1100 if(pst
->hasSameRules(*cst
)) {
1101 errln("FAILURE: PST and CST have same rules");
1104 UErrorCode status
= U_ZERO_ERROR
;
1105 int32_t offset1
= pst
->getOffset(1,
1106 1997, UCAL_OCTOBER
, 26, UCAL_SUNDAY
, (2*60*60*1000), status
);
1107 failure(status
, "getOffset() failed");
1110 int32_t offset2
= cst
->getOffset(1,
1111 1997, UCAL_OCTOBER
, 26, UCAL_SUNDAY
, (2*60*60*1000), 31, status
);
1112 failure(status
, "getOffset() failed");
1114 if(offset1
== offset2
)
1115 errln("FAILURE: Sunday Oct. 26 1997 2:00 has same offset for PST and CST");
1117 // verify error checking
1119 1997, UCAL_FIELD_COUNT
+1, 26, UCAL_SUNDAY
, (2*60*60*1000), status
);
1120 if(U_SUCCESS(status
))
1121 errln("FAILURE: getOffset() succeeded with -1 for month");
1123 status
= U_ZERO_ERROR
;
1124 cst
->setDSTSavings(60*60*1000, status
);
1125 failure(status
, "setDSTSavings() failed");
1127 int32_t savings
= cst
->getDSTSavings();
1128 if(savings
!= 60*60*1000) {
1129 errln("setDSTSavings() failed");
1136 * SimpleTimeZone allows invalid DOM values.
1138 void TimeZoneRegressionTest::Test4184229() {
1139 SimpleTimeZone
* zone
= NULL
;
1140 UErrorCode status
= U_ZERO_ERROR
;
1141 zone
= new SimpleTimeZone(0, "A", 0, -1, 0, 0, 0, 0, 0, 0, status
);
1142 if(U_SUCCESS(status
)){
1143 errln("Failed. No exception has been thrown for DOM -1 startDay");
1145 logln("(a) " + UnicodeString( u_errorName(status
)));
1147 status
= U_ZERO_ERROR
;
1150 zone
= new SimpleTimeZone(0, "A", 0, 0, 0, 0, 0, -1, 0, 0, status
);
1151 if(U_SUCCESS(status
)){
1152 errln("Failed. No exception has been thrown for DOM -1 endDay");
1154 logln("(b) " + UnicodeString(u_errorName(status
)));
1156 status
= U_ZERO_ERROR
;
1159 zone
= new SimpleTimeZone(0, "A", 0, -1, 0, 0, 0, 0, 0, 1000, status
);
1160 if(U_SUCCESS(status
)){
1161 errln("Failed. No exception has been thrown for DOM -1 startDay+savings");
1163 logln("(c) " + UnicodeString(u_errorName(status
)));
1165 status
= U_ZERO_ERROR
;
1167 zone
= new SimpleTimeZone(0, "A", 0, 0, 0, 0, 0, -1, 0, 0, 1000, status
);
1168 if(U_SUCCESS(status
)){
1169 errln("Failed. No exception has been thrown for DOM -1 endDay+ savings");
1171 logln("(d) " + UnicodeString(u_errorName(status
)));
1173 status
= U_ZERO_ERROR
;
1175 // Make a valid constructor call for subsequent tests.
1176 zone
= new SimpleTimeZone(0, "A", 0, 1, 0, 0, 0, 1, 0, 0, status
);
1178 zone
->setStartRule(0, -1, 0, 0, status
);
1179 if(U_SUCCESS(status
)){
1180 errln("Failed. No exception has been thrown for DOM -1 setStartRule +savings");
1182 logln("(e) " + UnicodeString(u_errorName(status
)));
1184 zone
->setStartRule(0, -1, 0, status
);
1185 if(U_SUCCESS(status
)){
1186 errln("Failed. No exception has been thrown for DOM -1 setStartRule");
1188 logln("(f) " + UnicodeString(u_errorName(status
)));
1191 zone
->setEndRule(0, -1, 0, 0, status
);
1192 if(U_SUCCESS(status
)){
1193 errln("Failed. No exception has been thrown for DOM -1 setEndRule+savings");
1195 logln("(g) " + UnicodeString(u_errorName(status
)));
1198 zone
->setEndRule(0, -1, 0, status
);
1199 if(U_SUCCESS(status
)){
1200 errln("Failed. No exception has been thrown for DOM -1 setEndRule");
1202 logln("(h) " + UnicodeString(u_errorName(status
)));
1207 #endif /* #if !UCONFIG_NO_FORMATTING */