1 // © 2016 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html 3 /* 4 ******************************************************************************* 5 * 6 * Copyright (C) 2012-2013, International Business Machines 7 * Corporation and others. All Rights Reserved. 8 * 9 ******************************************************************************* 10 * file name: listformattertest.cpp 11 * encoding: UTF-8 12 * tab size: 8 (not used) 13 * indentation:4 14 * 15 * created on: 2012aug27 16 * created by: Umesh P. Nair 17 */ 18 19 #ifndef __LISTFORMATTERTEST_H__ 20 #define __LISTFORMATTERTEST_H__ 21 22 #include "unicode/fpositer.h" 23 #include "unicode/listformatter.h" 24 #include "intltest.h" 25 #include "itformat.h" 26 27 #if !UCONFIG_NO_FORMATTING 28 29 class ListFormatterTest : public IntlTestWithFieldPosition { 30 public: 31 ListFormatterTest(); ~ListFormatterTest()32 virtual ~ListFormatterTest() {} 33 34 void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par=0); 35 36 void TestRoot(); 37 void TestBogus(); 38 void TestEnglish(); 39 void TestEnglishUS(); 40 void TestEnglishGB(); 41 void TestNynorsk(); 42 void TestChineseTradHK(); 43 void TestRussian(); 44 void TestMalayalam(); 45 void TestZulu(); 46 void TestOutOfOrderPatterns(); 47 void Test9946(); 48 void TestFieldPositionIteratorWith1Item(); 49 void TestFieldPositionIteratorWith2Items(); 50 void TestFieldPositionIteratorWith3Items(); 51 void TestFieldPositionIteratorWith2ItemsPatternShift(); 52 void TestFieldPositionIteratorWith3ItemsPatternShift(); 53 void TestFormattedValue(); 54 void TestDifferentStyles(); 55 void TestBadStylesFail(); 56 void TestCreateStyled(); 57 void TestContextual(); 58 void TestNextPosition(); 59 void TestInt32Overflow(); 60 61 private: 62 void CheckFormatting( 63 const ListFormatter* formatter, 64 UnicodeString data[], 65 int32_t data_size, 66 const UnicodeString& expected_result, 67 const char* testName); 68 void ExpectPositions( 69 const FormattedList& iter, 70 int32_t *values, 71 int32_t tupleCount, 72 UErrorCode& status); 73 void RunTestFieldPositionIteratorWithNItems( 74 UnicodeString *data, 75 int32_t n, 76 int32_t *values, 77 int32_t tupleCount, 78 const char16_t *expectedFormatted, 79 const char* testName); 80 void RunTestFieldPositionIteratorWithNItemsPatternShift( 81 UnicodeString *data, 82 int32_t n, 83 int32_t *values, 84 int32_t tupleCount, 85 const char16_t *expectedFormatted, 86 const char* testName); 87 void RunTestFieldPositionIteratorWithFormatter( 88 ListFormatter* formatter, 89 UnicodeString *data, 90 int32_t n, 91 int32_t *values, 92 int32_t tupleCount, 93 const char16_t *expectedFormatted, 94 const char* testName); 95 void CheckFourCases( 96 const char* locale_string, 97 UnicodeString one, 98 UnicodeString two, 99 UnicodeString three, 100 UnicodeString four, 101 UnicodeString results[4], 102 const char* testName); 103 UBool RecordFourCases( 104 const Locale& locale, 105 UnicodeString one, 106 UnicodeString two, 107 UnicodeString three, 108 UnicodeString four, 109 UnicodeString results[4], 110 const char* testName); 111 void DoTheRealListStyleTesting( 112 Locale locale, 113 UnicodeString items[], 114 int32_t itemCount, 115 const char* style, 116 const char* expected, 117 IcuTestErrorCode status); 118 119 private: 120 // Reused test data. 121 const UnicodeString prefix; 122 const UnicodeString one; 123 const UnicodeString two; 124 const UnicodeString three; 125 const UnicodeString four; 126 }; 127 128 #endif /* #if !UCONFIG_NO_FORMATTING */ 129 130 #endif 131