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