• 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 TestBadStylesFail();
56     void TestCreateStyled();
57     void TestContextual();
58 
59   private:
60     void CheckFormatting(
61         const ListFormatter* formatter,
62         UnicodeString data[],
63         int32_t data_size,
64         const UnicodeString& expected_result,
65         const char* testName);
66     void ExpectPositions(
67         const FormattedList& iter,
68         int32_t *values,
69         int32_t tupleCount,
70         UErrorCode& status);
71     void RunTestFieldPositionIteratorWithNItems(
72         UnicodeString *data,
73         int32_t n,
74         int32_t *values,
75         int32_t tupleCount,
76         const char16_t *expectedFormatted,
77         const char* testName);
78     void RunTestFieldPositionIteratorWithNItemsPatternShift(
79         UnicodeString *data,
80         int32_t n,
81         int32_t *values,
82         int32_t tupleCount,
83         const char16_t *expectedFormatted,
84         const char* testName);
85     void RunTestFieldPositionIteratorWithFormatter(
86         ListFormatter* formatter,
87         UnicodeString *data,
88         int32_t n,
89         int32_t *values,
90         int32_t tupleCount,
91         const char16_t *expectedFormatted,
92         const char* testName);
93     void CheckFourCases(
94         const char* locale_string,
95         UnicodeString one,
96         UnicodeString two,
97         UnicodeString three,
98         UnicodeString four,
99         UnicodeString results[4],
100         const char* testName);
101     UBool RecordFourCases(
102         const Locale& locale,
103         UnicodeString one,
104         UnicodeString two,
105         UnicodeString three,
106         UnicodeString four,
107         UnicodeString results[4],
108         const char* testName);
109     void DoTheRealListStyleTesting(
110         Locale locale,
111         UnicodeString items[],
112         int32_t itemCount,
113         const char* style,
114         const char* expected,
115         IcuTestErrorCode status);
116 
117   private:
118     // Reused test data.
119     const UnicodeString prefix;
120     const UnicodeString one;
121     const UnicodeString two;
122     const UnicodeString three;
123     const UnicodeString four;
124 };
125 
126 #endif /* #if !UCONFIG_NO_FORMATTING */
127 
128 #endif
129