]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | /******************************************************************** |
2 | * COPYRIGHT: | |
3 | * Copyright (c) 1997-2001, International Business Machines Corporation and | |
4 | * others. All Rights Reserved. | |
5 | ********************************************************************/ | |
6 | ||
7 | #ifndef __TimeZoneBoundaryTest__ | |
8 | #define __TimeZoneBoundaryTest__ | |
9 | ||
10 | #include "unicode/utypes.h" | |
11 | ||
12 | #if !UCONFIG_NO_FORMATTING | |
13 | ||
14 | #include "unicode/timezone.h" | |
15 | #include "unicode/simpletz.h" | |
16 | #include "caltztst.h" | |
17 | ||
18 | /** | |
19 | * A test which discovers the boundaries of DST programmatically and verifies | |
20 | * that they are correct. | |
21 | */ | |
22 | class TimeZoneBoundaryTest: public CalendarTimeZoneTest { | |
23 | // IntlTest override | |
24 | void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par ); | |
25 | public: // package | |
26 | ||
27 | TimeZoneBoundaryTest(); | |
28 | ||
29 | /** | |
30 | * Date.toString().substring() Boundary Test | |
31 | * Look for a DST changeover to occur within 6 months of the given Date. | |
32 | * The initial Date.toString() should yield a string containing the | |
33 | * startMode as a SUBSTRING. The boundary will be tested to be | |
34 | * at the expectedBoundary value. | |
35 | */ | |
36 | ||
37 | /** | |
38 | * internal routines used by major test routines to perform subtests | |
39 | **/ | |
40 | virtual void findDaylightBoundaryUsingDate(UDate d, const char* startMode, UDate expectedBoundary); | |
41 | virtual void findDaylightBoundaryUsingTimeZone(UDate d, UBool startsInDST, UDate expectedBoundary); | |
42 | virtual void findDaylightBoundaryUsingTimeZone(UDate d, UBool startsInDST, UDate expectedBoundary, TimeZone* tz); | |
43 | ||
44 | private: | |
45 | //static UnicodeString* showDate(long l); | |
46 | UnicodeString showDate(UDate d); | |
47 | static UnicodeString showNN(int32_t n); | |
48 | ||
49 | public: // package | |
50 | /** | |
51 | * Given a date, a TimeZone, and expected values for inDaylightTime, | |
52 | * useDaylightTime, zone and DST offset, verify that this is the case. | |
53 | */ | |
54 | virtual void verifyDST(UDate d, TimeZone* time_zone, UBool expUseDaylightTime, UBool expInDaylightTime, UDate expZoneOffset, UDate expDSTOffset); | |
55 | ||
56 | /** | |
57 | * Test the behavior of SimpleTimeZone at the transition into and out of DST. | |
58 | * Use a binary search to find boundaries. | |
59 | */ | |
60 | virtual void TestBoundaries(void); | |
61 | ||
62 | /** | |
63 | * internal subroutine used by TestNewRules | |
64 | **/ | |
65 | virtual void testUsingBinarySearch(SimpleTimeZone* tz, UDate d, UDate expectedBoundary); | |
66 | ||
67 | /** | |
68 | * Test the handling of the "new" rules; that is, rules other than nth Day of week. | |
69 | */ | |
70 | virtual void TestNewRules(void); | |
71 | ||
72 | /** | |
73 | * Find boundaries by stepping. | |
74 | */ | |
75 | virtual void findBoundariesStepwise(int32_t year, UDate interval, TimeZone* z, int32_t expectedChanges); | |
76 | ||
77 | /** | |
78 | * Test the behavior of SimpleTimeZone at the transition into and out of DST. | |
79 | * Use a stepwise march to find boundaries. | |
80 | */ | |
81 | virtual void TestStepwise(void); | |
82 | ||
83 | private: | |
84 | const UDate ONE_SECOND; | |
85 | const UDate ONE_MINUTE; | |
86 | const UDate ONE_HOUR; | |
87 | const UDate ONE_DAY; | |
88 | const UDate ONE_YEAR; | |
89 | const UDate SIX_MONTHS; | |
90 | static const int32_t MONTH_LENGTH[]; | |
91 | static const UDate PST_1997_BEG; | |
92 | static const UDate PST_1997_END; | |
93 | static const UDate INTERVAL; | |
94 | }; | |
95 | ||
96 | #endif /* #if !UCONFIG_NO_FORMATTING */ | |
97 | ||
98 | #endif // __TimeZoneBoundaryTest__ |