]>
Commit | Line | Data |
---|---|---|
1 | /******************************************************************** | |
2 | * COPYRIGHT: | |
3 | * Copyright (c) 1997-2008, International Business Machines Corporation and | |
4 | * others. All Rights Reserved. | |
5 | ********************************************************************/ | |
6 | ||
7 | #ifndef __CalendarLimitTest__ | |
8 | #define __CalendarLimitTest__ | |
9 | ||
10 | #include "unicode/utypes.h" | |
11 | ||
12 | #if !UCONFIG_NO_FORMATTING | |
13 | ||
14 | #include "caltztst.h" | |
15 | ||
16 | /** | |
17 | * This test verifies the behavior of Calendar around the very earliest limits | |
18 | * which it can handle. It also verifies the behavior for large values of millis. | |
19 | * | |
20 | * Bug ID 4033662. | |
21 | */ | |
22 | class CalendarLimitTest: public CalendarTimeZoneTest { | |
23 | // IntlTest override | |
24 | void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par ); | |
25 | public: // package | |
26 | //test routine used by TestCalendarLimit | |
27 | virtual void test(UDate millis, Calendar *cal, DateFormat *fmt); | |
28 | ||
29 | // bug 986c: deprecate nextDouble/previousDouble | |
30 | //static double nextDouble(double a); | |
31 | //static double previousDouble(double a); | |
32 | static UBool withinErr(double a, double b, double err); | |
33 | ||
34 | public: | |
35 | // test behaviour and error reporting at boundaries of defined range | |
36 | virtual void TestCalendarExtremeLimit(void); | |
37 | ||
38 | void TestLimits(void); | |
39 | ||
40 | private: | |
41 | /* | |
42 | * Test the functions getMaximum/getGeratestMinimum logically correct. | |
43 | * This method assumes day of week cycle is consistent. | |
44 | * @param cal The calendar instance to be tested. | |
45 | * @param leapMonth true if the calendar system has leap months | |
46 | */ | |
47 | void doTheoreticalLimitsTest(Calendar& cal, UBool leapMonth); | |
48 | ||
49 | /* | |
50 | * Test the functions getXxxMinimum() and getXxxMaximum() by marching a | |
51 | * test calendar 'cal' through 'numberOfDays' sequential days starting | |
52 | * with 'startDate'. For each date, read a field value along with its | |
53 | * reported actual minimum and actual maximum. These values are | |
54 | * checked against one another as well as against getMinimum(), | |
55 | * getGreatestMinimum(), getLeastMaximum(), and getMaximum(). We | |
56 | * expect to see: | |
57 | * | |
58 | * 1. minimum <= actualMinimum <= greatestMinimum <= | |
59 | * leastMaximum <= actualMaximum <= maximum | |
60 | * | |
61 | * 2. actualMinimum <= value <= actualMaximum | |
62 | * | |
63 | * Note: In addition to outright failures, this test reports some | |
64 | * results as warnings. These are not generally of concern, but they | |
65 | * should be evaluated by a human. To see these, run this test in | |
66 | * verbose mode. | |
67 | * @param cal the calendar to be tested | |
68 | * @param fieldsToTest an array of field values to be tested, e.g., new | |
69 | * int[] { UCAL_MONTH, UCAL_DAY_OF_MONTH }. It only makes | |
70 | * sense to test the day fields; the time fields are not tested by this | |
71 | * method. If null, then test all standard fields. | |
72 | * @param startDate the first date to test | |
73 | * @param testDuration if positive, the number of days to be tested. | |
74 | * If negative, the number of seconds to run the test. | |
75 | */ | |
76 | void doLimitsTest(Calendar& cal, const int32_t* fieldsToTest, UDate startDate, int32_t testDuration); | |
77 | ||
78 | /** | |
79 | * doLimitsTest with default test duration and fields | |
80 | */ | |
81 | void doLimitsTest(Calendar& cal, UDate startDate); | |
82 | ||
83 | UnicodeString& ymdToString(const Calendar& cal, UnicodeString& str); | |
84 | }; | |
85 | ||
86 | #endif /* #if !UCONFIG_NO_FORMATTING */ | |
87 | ||
88 | #endif // __CalendarLimitTest__ |