]> git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/listformattertest.h
ICU-64232.0.1.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
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 FieldPositionIterator& iter,
70 int32_t *values,
71 int32_t tupleCount);
72 void RunTestFieldPositionIteratorWithNItems(
73 UnicodeString *data,
74 int32_t n,
75 int32_t *values,
76 int32_t tupleCount,
77 UnicodeString& appendTo,
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 UnicodeString& appendTo,
86 const char16_t *expectedFormatted,
87 const char* testName);
88 void RunTestFieldPositionIteratorWithFormatter(
89 ListFormatter* formatter,
90 UnicodeString *data,
91 int32_t n,
92 int32_t *values,
93 int32_t tupleCount,
94 UnicodeString& appendTo,
95 const char16_t *expectedFormatted,
96 const char* testName);
97 void CheckFourCases(
98 const char* locale_string,
99 UnicodeString one,
100 UnicodeString two,
101 UnicodeString three,
102 UnicodeString four,
103 UnicodeString results[4],
104 const char* testName);
105 UBool RecordFourCases(
106 const Locale& locale,
107 UnicodeString one,
108 UnicodeString two,
109 UnicodeString three,
110 UnicodeString four,
111 UnicodeString results[4],
112 const char* testName);
113 void DoTheRealListStyleTesting(
114 Locale locale,
115 UnicodeString items[],
116 int32_t itemCount,
117 const char* style,
118 const char* expected,
119 IcuTestErrorCode status);
120
121 private:
122 // Reused test data.
123 const UnicodeString prefix;
124 const UnicodeString one;
125 const UnicodeString two;
126 const UnicodeString three;
127 const UnicodeString four;
128 };
129
130 #endif /* #if !UCONFIG_NO_FORMATTING */
131
132 #endif