]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | /******************************************************************** |
2 | * COPYRIGHT: | |
2ca993e8 | 3 | * Copyright (c) 1997-2015, International Business Machines Corporation and |
b75a7d8f A |
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 | |
46f4442e A |
36 | virtual void TestCalendarExtremeLimit(void); |
37 | ||
38 | void TestLimits(void); | |
2ca993e8 | 39 | void TestLimitsThread(int threadNumber); |
46f4442e A |
40 | |
41 | private: | |
42 | /* | |
43 | * Test the functions getMaximum/getGeratestMinimum logically correct. | |
44 | * This method assumes day of week cycle is consistent. | |
45 | * @param cal The calendar instance to be tested. | |
46 | * @param leapMonth true if the calendar system has leap months | |
47 | */ | |
48 | void doTheoreticalLimitsTest(Calendar& cal, UBool leapMonth); | |
49 | ||
50 | /* | |
51 | * Test the functions getXxxMinimum() and getXxxMaximum() by marching a | |
52 | * test calendar 'cal' through 'numberOfDays' sequential days starting | |
53 | * with 'startDate'. For each date, read a field value along with its | |
54 | * reported actual minimum and actual maximum. These values are | |
55 | * checked against one another as well as against getMinimum(), | |
56 | * getGreatestMinimum(), getLeastMaximum(), and getMaximum(). We | |
57 | * expect to see: | |
58 | * | |
59 | * 1. minimum <= actualMinimum <= greatestMinimum <= | |
60 | * leastMaximum <= actualMaximum <= maximum | |
61 | * | |
62 | * 2. actualMinimum <= value <= actualMaximum | |
63 | * | |
64 | * Note: In addition to outright failures, this test reports some | |
65 | * results as warnings. These are not generally of concern, but they | |
66 | * should be evaluated by a human. To see these, run this test in | |
67 | * verbose mode. | |
68 | * @param cal the calendar to be tested | |
69 | * @param fieldsToTest an array of field values to be tested, e.g., new | |
70 | * int[] { UCAL_MONTH, UCAL_DAY_OF_MONTH }. It only makes | |
71 | * sense to test the day fields; the time fields are not tested by this | |
72 | * method. If null, then test all standard fields. | |
73 | * @param startDate the first date to test | |
74 | * @param testDuration if positive, the number of days to be tested. | |
75 | * If negative, the number of seconds to run the test. | |
76 | */ | |
77 | void doLimitsTest(Calendar& cal, const int32_t* fieldsToTest, UDate startDate, int32_t testDuration); | |
78 | ||
79 | /** | |
80 | * doLimitsTest with default test duration and fields | |
81 | */ | |
729e4ab9 | 82 | void doLimitsTest(Calendar& cal, UDate startDate, int32_t endTime); |
46f4442e A |
83 | |
84 | UnicodeString& ymdToString(const Calendar& cal, UnicodeString& str); | |
b75a7d8f A |
85 | }; |
86 | ||
87 | #endif /* #if !UCONFIG_NO_FORMATTING */ | |
88 | ||
89 | #endif // __CalendarLimitTest__ |