2016-06-15 18:58:17 +00:00
|
|
|
// Copyright (C) 2016 and later: Unicode, Inc. and others.
|
|
|
|
// License & terms of use: http://www.unicode.org/copyright.html
|
2000-01-15 02:00:06 +00:00
|
|
|
/********************************************************************
|
|
|
|
* COPYRIGHT:
|
2016-05-31 21:45:07 +00:00
|
|
|
* Copyright (c) 1997-2005, International Business Machines Corporation and
|
|
|
|
* others. All Rights Reserved.
|
2000-01-15 02:00:06 +00:00
|
|
|
********************************************************************/
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
#ifndef __TimeZoneBoundaryTest__
|
|
|
|
#define __TimeZoneBoundaryTest__
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
#include "unicode/utypes.h"
|
2002-09-21 00:43:14 +00:00
|
|
|
|
|
|
|
#if !UCONFIG_NO_FORMATTING
|
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
#include "unicode/timezone.h"
|
|
|
|
#include "unicode/simpletz.h"
|
1999-08-16 21:50:52 +00:00
|
|
|
#include "caltztst.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A test which discovers the boundaries of DST programmatically and verifies
|
|
|
|
* that they are correct.
|
|
|
|
*/
|
|
|
|
class TimeZoneBoundaryTest: public CalendarTimeZoneTest {
|
|
|
|
// IntlTest override
|
2000-08-14 21:42:36 +00:00
|
|
|
void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par );
|
1999-08-16 21:50:52 +00:00
|
|
|
public: // package
|
2001-08-06 20:11:43 +00:00
|
|
|
|
|
|
|
TimeZoneBoundaryTest();
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
/**
|
|
|
|
* Date.toString().substring() Boundary Test
|
|
|
|
* Look for a DST changeover to occur within 6 months of the given Date.
|
|
|
|
* The initial Date.toString() should yield a string containing the
|
|
|
|
* startMode as a SUBSTRING. The boundary will be tested to be
|
|
|
|
* at the expectedBoundary value.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* internal routines used by major test routines to perform subtests
|
|
|
|
**/
|
|
|
|
virtual void findDaylightBoundaryUsingDate(UDate d, const char* startMode, UDate expectedBoundary);
|
2000-05-18 22:08:39 +00:00
|
|
|
virtual void findDaylightBoundaryUsingTimeZone(UDate d, UBool startsInDST, UDate expectedBoundary);
|
|
|
|
virtual void findDaylightBoundaryUsingTimeZone(UDate d, UBool startsInDST, UDate expectedBoundary, TimeZone* tz);
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
//static UnicodeString* showDate(long l);
|
|
|
|
UnicodeString showDate(UDate d);
|
|
|
|
static UnicodeString showNN(int32_t n);
|
|
|
|
|
|
|
|
public: // package
|
|
|
|
/**
|
|
|
|
* Given a date, a TimeZone, and expected values for inDaylightTime,
|
|
|
|
* useDaylightTime, zone and DST offset, verify that this is the case.
|
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
virtual void verifyDST(UDate d, TimeZone* time_zone, UBool expUseDaylightTime, UBool expInDaylightTime, UDate expZoneOffset, UDate expDSTOffset);
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test the behavior of SimpleTimeZone at the transition into and out of DST.
|
|
|
|
* Use a binary search to find boundaries.
|
|
|
|
*/
|
|
|
|
virtual void TestBoundaries(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* internal subroutine used by TestNewRules
|
|
|
|
**/
|
|
|
|
virtual void testUsingBinarySearch(SimpleTimeZone* tz, UDate d, UDate expectedBoundary);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test the handling of the "new" rules; that is, rules other than nth Day of week.
|
|
|
|
*/
|
|
|
|
virtual void TestNewRules(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Find boundaries by stepping.
|
|
|
|
*/
|
|
|
|
virtual void findBoundariesStepwise(int32_t year, UDate interval, TimeZone* z, int32_t expectedChanges);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test the behavior of SimpleTimeZone at the transition into and out of DST.
|
|
|
|
* Use a stepwise march to find boundaries.
|
|
|
|
*/
|
|
|
|
virtual void TestStepwise(void);
|
2005-11-04 21:57:24 +00:00
|
|
|
void verifyMapping(Calendar& cal, int year, int month, int dom, int hour,
|
|
|
|
double epochHours) ;
|
2001-08-06 20:11:43 +00:00
|
|
|
private:
|
|
|
|
const UDate ONE_SECOND;
|
|
|
|
const UDate ONE_MINUTE;
|
|
|
|
const UDate ONE_HOUR;
|
|
|
|
const UDate ONE_DAY;
|
|
|
|
const UDate ONE_YEAR;
|
|
|
|
const UDate SIX_MONTHS;
|
|
|
|
static const int32_t MONTH_LENGTH[];
|
|
|
|
static const UDate PST_1997_BEG;
|
|
|
|
static const UDate PST_1997_END;
|
|
|
|
static const UDate INTERVAL;
|
1999-08-16 21:50:52 +00:00
|
|
|
};
|
2002-09-21 00:43:14 +00:00
|
|
|
|
|
|
|
#endif /* #if !UCONFIG_NO_FORMATTING */
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
#endif // __TimeZoneBoundaryTest__
|