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