]> git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/listformattertest.h
ICU-66108.tar.gz
[apple/icu.git] / icuSources / test / intltest / listformattertest.h
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();
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 TestFieldPositionIteratorWontCrash();
49 void TestFieldPositionIteratorWith1Item();
50 void TestFieldPositionIteratorWith2Items();
51 void TestFieldPositionIteratorWith3Items();
52 void TestFieldPositionIteratorWith1ItemAndDataBefore();
53 void TestFieldPositionIteratorWith2ItemsAndDataBefore();
54 void TestFieldPositionIteratorWith3ItemsAndDataBefore();
55 void TestFieldPositionIteratorWith2ItemsPatternShift();
56 void TestFieldPositionIteratorWith3ItemsPatternShift();
57 void TestFormattedValue();
58 void TestDifferentStyles();
59 void TestBadStylesFail();
60 void TestCreateStyled();
61 void TestContextual();
62
63 private:
64 void CheckFormatting(
65 const ListFormatter* formatter,
66 UnicodeString data[],
67 int32_t data_size,
68 const UnicodeString& expected_result,
69 const char* testName);
70 void ExpectPositions(
71 FieldPositionIterator& iter,
72 int32_t *values,
73 int32_t tupleCount);
74 void RunTestFieldPositionIteratorWithNItems(
75 UnicodeString *data,
76 int32_t n,
77 int32_t *values,
78 int32_t tupleCount,
79 UnicodeString& appendTo,
80 const char16_t *expectedFormatted,
81 const char* testName);
82 void RunTestFieldPositionIteratorWithNItemsPatternShift(
83 UnicodeString *data,
84 int32_t n,
85 int32_t *values,
86 int32_t tupleCount,
87 UnicodeString& appendTo,
88 const char16_t *expectedFormatted,
89 const char* testName);
90 void RunTestFieldPositionIteratorWithFormatter(
91 ListFormatter* formatter,
92 UnicodeString *data,
93 int32_t n,
94 int32_t *values,
95 int32_t tupleCount,
96 UnicodeString& appendTo,
97 const char16_t *expectedFormatted,
98 const char* testName);
99 void CheckFourCases(
100 const char* locale_string,
101 UnicodeString one,
102 UnicodeString two,
103 UnicodeString three,
104 UnicodeString four,
105 UnicodeString results[4],
106 const char* testName);
107 UBool RecordFourCases(
108 const Locale& locale,
109 UnicodeString one,
110 UnicodeString two,
111 UnicodeString three,
112 UnicodeString four,
113 UnicodeString results[4],
114 const char* testName);
115 void DoTheRealListStyleTesting(
116 Locale locale,
117 UnicodeString items[],
118 int32_t itemCount,
119 const char* style,
120 const char* expected,
121 IcuTestErrorCode status);
122
123 private:
124 // Reused test data.
125 const UnicodeString prefix;
126 const UnicodeString one;
127 const UnicodeString two;
128 const UnicodeString three;
129 const UnicodeString four;
130 };
131
132 #endif /* #if !UCONFIG_NO_FORMATTING */
133
134 #endif