• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 TestCreateStyled();
56     void TestContextual();
57     void TestNextPosition();
58     void TestInt32Overflow();
59 
60   private:
61     void CheckFormatting(
62         const ListFormatter* formatter,
63         UnicodeString data[],
64         int32_t data_size,
65         const UnicodeString& expected_result,
66         const char* testName);
67     void ExpectPositions(
68         const FormattedList& iter,
69         int32_t *values,
70         int32_t tupleCount,
71         UErrorCode& status);
72     void RunTestFieldPositionIteratorWithNItems(
73         UnicodeString *data,
74         int32_t n,
75         int32_t *values,
76         int32_t tupleCount,
77         const char16_t *expectedFormatted,
78         const char* testName);
79     void RunTestFieldPositionIteratorWithNItemsPatternShift(
80         UnicodeString *data,
81         int32_t n,
82         int32_t *values,
83         int32_t tupleCount,
84         const char16_t *expectedFormatted,
85         const char* testName);
86     void RunTestFieldPositionIteratorWithFormatter(
87         ListFormatter* formatter,
88         UnicodeString *data,
89         int32_t n,
90         int32_t *values,
91         int32_t tupleCount,
92         const char16_t *expectedFormatted,
93         const char* testName);
94     void CheckFourCases(
95         const char* locale_string,
96         UnicodeString one,
97         UnicodeString two,
98         UnicodeString three,
99         UnicodeString four,
100         UnicodeString results[4],
101         const char* testName);
102     UBool RecordFourCases(
103         const Locale& locale,
104         UnicodeString one,
105         UnicodeString two,
106         UnicodeString three,
107         UnicodeString four,
108         UnicodeString results[4],
109         const char* testName);
110     void DoTheRealListStyleTesting(
111         Locale locale,
112         UnicodeString items[],
113         int itemCount,
114         UListFormatterType type,
115         UListFormatterWidth width,
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