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) 2008-2016 International Business Machines Corporation and 6 * others. All Rights Reserved. 7 ********************************************************************/ 8 9 #ifndef _INTLTESTDATEINTERVALFORMAT 10 #define _INTLTESTDATEINTERVALFORMAT 11 12 #include "unicode/utypes.h" 13 #include "unicode/locid.h" 14 15 #if !UCONFIG_NO_FORMATTING 16 17 #include "intltest.h" 18 #include "itformat.h" 19 20 U_NAMESPACE_BEGIN 21 class FormattedDateInterval; 22 U_NAMESPACE_END 23 24 /** 25 * Test basic functionality of various API functions 26 **/ 27 class DateIntervalFormatTest: public IntlTestWithFieldPosition { 28 void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par = NULL ); 29 30 public: 31 /** 32 * Performs tests on many API functions, see detailed comments in source code 33 **/ 34 void testAPI(); 35 36 /** 37 * Test formatting 38 */ 39 void testFormat(); 40 41 42 /** 43 * Test handling of hour and day period metacharacters 44 */ 45 void testHourMetacharacters(); 46 47 void testFormatMillisecond(); 48 49 /** 50 * Test formatting using user defined DateIntervalInfo 51 */ 52 void testFormatUserDII(); 53 54 /* 55 * Test format using UDisplayContext 56 */ 57 void testContext(); 58 59 /** 60 * Test for no unwanted side effects when setting 61 * interval patterns. 62 */ 63 void testSetIntervalPatternNoSideEffect(); 64 65 /** 66 * Tests different year formats. 67 */ 68 void testYearFormats(); 69 70 /** 71 * Stress test -- stress test formatting on 40 locales 72 */ 73 void testStress(); 74 75 void testTicket11583_2(); 76 77 void testTicket11985(); 78 79 void testTicket11669(); 80 void threadFunc11669(int32_t threadNum); 81 82 void testTicket12065(); 83 84 void testFormattedDateInterval(); 85 void testCreateInstanceForAllLocales(); 86 87 void testTicket20707(); 88 void testTicket21222GregorianEraDiff(); 89 void testTicket21222ROCEraDiff(); 90 void testTicket21222JapaneseEraDiff(); 91 92 private: 93 /** 94 * Test formatting against expected result 95 */ 96 void expect(const char** data, int32_t data_length); 97 98 /** 99 * Test formatting against expected result using user defined 100 * DateIntervalInfo 101 */ 102 void expectUserDII(const char** data, int32_t data_length); 103 104 /** 105 * Stress test formatting 106 */ 107 void stress(const char** data, int32_t data_length, const Locale& loc, 108 const char* locName); 109 110 void getCategoryAndField( 111 const FormattedDateInterval& formatted, 112 std::vector<int32_t>& categories, 113 std::vector<int32_t>& fields, 114 IcuTestErrorCode& status); 115 116 void verifyCategoryAndField( 117 const FormattedDateInterval& formatted, 118 const std::vector<int32_t>& categories, 119 const std::vector<int32_t>& fields, 120 IcuTestErrorCode& status); 121 122 }; 123 124 #endif /* #if !UCONFIG_NO_FORMATTING */ 125 126 #endif 127