]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/callimts.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /********************************************************************
5 * Copyright (c) 1997-2015, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 ********************************************************************/
9 #ifndef __CalendarLimitTest__
10 #define __CalendarLimitTest__
12 #include "unicode/utypes.h"
14 #if !UCONFIG_NO_FORMATTING
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.
24 class CalendarLimitTest
: public CalendarTimeZoneTest
{
26 void runIndexedTest( int32_t index
, UBool exec
, const char* &name
, char* par
);
28 //test routine used by TestCalendarLimit
29 virtual void test(UDate millis
, Calendar
*cal
, DateFormat
*fmt
);
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
);
37 // test behaviour and error reporting at boundaries of defined range
38 virtual void TestCalendarExtremeLimit(void);
40 void TestLimits(void);
41 void TestLimitsThread(int32_t threadNumber
);
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
50 void doTheoreticalLimitsTest(Calendar
& cal
, UBool leapMonth
);
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
61 * 1. minimum <= actualMinimum <= greatestMinimum <=
62 * leastMaximum <= actualMaximum <= maximum
64 * 2. actualMinimum <= value <= actualMaximum
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
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.
79 void doLimitsTest(Calendar
& cal
, const int32_t* fieldsToTest
, UDate startDate
, int32_t testDuration
);
82 * doLimitsTest with default test duration and fields
84 void doLimitsTest(Calendar
& cal
, UDate startDate
, int32_t endTime
);
86 UnicodeString
& ymdToString(const Calendar
& cal
, UnicodeString
& str
);
89 #endif /* #if !UCONFIG_NO_FORMATTING */
91 #endif // __CalendarLimitTest__