1 // © 2016 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html 3 /******************************************************************** 4 * COPYRIGHT: 5 * Copyright (c) 1997-2003, International Business Machines Corporation and 6 * others. All Rights Reserved. 7 ********************************************************************/ 8 9 #ifndef _INTLTESTDATEFORMAT 10 #define _INTLTESTDATEFORMAT 11 12 #include "unicode/utypes.h" 13 14 #if !UCONFIG_NO_FORMATTING 15 16 #include "unicode/unistr.h" 17 #include "unicode/datefmt.h" 18 #include "intltest.h" 19 20 /** 21 * Performs some tests in many variations on DateFormat 22 **/ 23 class IntlTestDateFormat: public IntlTest { 24 void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par = NULL ) override; 25 26 private: 27 28 /** 29 * test DateFormat::getAvailableLocales 30 **/ 31 void testAvailableLocales(/* char* par */); 32 /** 33 * call testLocale for all locales 34 **/ 35 void monsterTest(/* char *par */); 36 37 /** 38 * call tryDate with variations, called by testLocale 39 **/ 40 void testFormat(/* char* par */); 41 /** 42 * perform tests using date and fFormat, called in many variations 43 **/ 44 void tryDate(UDate date); 45 /** 46 * call testFormat for different DateFormat::EStyle's, etc 47 **/ 48 void testLocale(/*char *par, */const Locale&, const UnicodeString&); 49 /** 50 * return a random number 51 **/ 52 double randDouble(void); 53 /** 54 * generate description for verbose test output 55 **/ 56 void describeTest(void); 57 58 DateFormat *fFormat; 59 UnicodeString fTestName; 60 int32_t fLimit; // How many iterations it should take to reach convergence 61 62 // Values in milliseconds (== Date) 63 static constexpr int32_t ONESECOND = 1000; 64 static constexpr int32_t ONEMINUTE = 60 * ONESECOND; 65 static constexpr int32_t ONEHOUR = 60 * ONEMINUTE; 66 static constexpr int32_t ONEDAY = 24 * ONEHOUR; 67 68 static constexpr double ONEYEAR = 365.25 * ONEDAY; // Approximate 69 enum EMode 70 { 71 GENERIC, 72 TIME, 73 DATE, 74 DATE_TIME 75 }; 76 public: 77 virtual ~IntlTestDateFormat(); 78 }; 79 80 #endif /* #if !UCONFIG_NO_FORMATTING */ 81 82 #endif 83