]> git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/numfmtst.h
ICU-8.11.4.tar.gz
[apple/icu.git] / icuSources / test / intltest / numfmtst.h
1 /********************************************************************
2 * COPYRIGHT:
3 * Copyright (c) 1997-2006, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
6
7 #ifndef _NUMBERFORMATTEST_
8 #define _NUMBERFORMATTEST_
9
10 #include "unicode/utypes.h"
11
12 #if !UCONFIG_NO_FORMATTING
13
14 #include "unicode/numfmt.h"
15 #include "unicode/decimfmt.h"
16 #include "caltztst.h"
17
18 /**
19 * Performs various in-depth test on NumberFormat
20 **/
21 class NumberFormatTest: public CalendarTimeZoneTest {
22
23 // IntlTest override
24 void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par );
25 public:
26
27 /**
28 * Test APIs (to increase code coverage)
29 */
30 void TestAPI(void);
31
32 void TestCoverage(void);
33
34 /**
35 * Test the handling of quotes
36 **/
37 void TestQuotes(void);
38 /**
39 * Test patterns with exponential representation
40 **/
41 void TestExponential(void);
42 /**
43 * Test handling of patterns with currency symbols
44 **/
45 void TestCurrencySign(void);
46 /**
47 * Test different format patterns
48 **/
49 void TestPatterns(void);
50 /**
51 * API coverage for DigitList
52 **/
53 void TestDigitList(void);
54
55 /**
56 * Test localized currency patterns.
57 */
58 void TestCurrency(void);
59
60 /**
61 * Test the Currency object handling, new as of ICU 2.2.
62 */
63 void TestCurrencyObject(void);
64
65 void TestCurrencyPatterns(void);
66
67 /**
68 * Do rudimentary testing of parsing.
69 */
70 void TestParse(void);
71 /**
72 * Test proper rounding by the format method.
73 */
74 void TestRounding487(void);
75
76 // New tests for alphaWorks upgrade
77 void TestExponent(void);
78
79 void TestScientific(void);
80
81 void TestScientific2(void);
82
83 void TestScientificGrouping(void);
84
85 void TestInt64(void);
86
87 void TestSurrogateSupport(void);
88
89 /**
90 * Test the functioning of the secondary grouping value.
91 */
92 void TestSecondaryGrouping(void);
93
94 void TestWhiteSpaceParsing(void);
95
96 void TestComplexCurrency(void);
97
98 void TestPad(void);
99 void TestPatterns2(void);
100
101 /**
102 * Test currency registration.
103 */
104 void TestRegCurrency(void);
105
106 void TestCurrencyNames(void);
107
108 void TestCurrencyAmount(void);
109
110 void TestCurrencyUnit(void);
111
112 void TestSymbolsWithBadLocale(void);
113
114 void TestAdoptDecimalFormatSymbols(void);
115
116 void TestPerMill(void);
117
118 void TestIllegalPatterns(void);
119
120 void TestCases(void);
121
122 void TestJB3832(void);
123
124 void TestHost(void);
125
126 void TestCurrencyFormat(void);
127 private:
128
129 static UBool equalValue(const Formattable& a, const Formattable& b);
130
131 void expect2(NumberFormat& fmt, const Formattable& n, const UnicodeString& str);
132
133 void expect2(NumberFormat& fmt, const Formattable& n, const char* str) {
134 expect2(fmt, n, UnicodeString(str, ""));
135 }
136
137 void expect2(NumberFormat* fmt, const Formattable& n, const UnicodeString& str, UErrorCode ec);
138
139 void expect2(NumberFormat* fmt, const Formattable& n, const char* str, UErrorCode ec) {
140 expect2(fmt, n, UnicodeString(str, ""), ec);
141 }
142
143 void expect(NumberFormat& fmt, const UnicodeString& str, const Formattable& n);
144
145 void expect(NumberFormat& fmt, const char *str, const Formattable& n) {
146 expect(fmt, UnicodeString(str, ""), n);
147 }
148
149 void expect(NumberFormat& fmt, const Formattable& n,
150 const UnicodeString& exp, UBool rt=TRUE);
151
152 void expect(NumberFormat& fmt, const Formattable& n,
153 const char *exp, UBool rt=TRUE) {
154 expect(fmt, n, UnicodeString(exp, ""), rt);
155 }
156
157 void expect(NumberFormat* fmt, const Formattable& n,
158 const UnicodeString& exp, UErrorCode);
159
160 void expect(NumberFormat* fmt, const Formattable& n,
161 const char *exp, UErrorCode errorCode) {
162 expect(fmt, n, UnicodeString(exp, ""), errorCode);
163 }
164
165 void expectCurrency(NumberFormat& nf, const Locale& locale,
166 double value, const UnicodeString& string);
167
168 void expectPad(DecimalFormat& fmt, const UnicodeString& pat,
169 int32_t pos, int32_t width, UChar pad);
170
171 void expectPad(DecimalFormat& fmt, const char *pat,
172 int32_t pos, int32_t width, UChar pad) {
173 expectPad(fmt, UnicodeString(pat, ""), pos, width, pad);
174 }
175
176 void expectPad(DecimalFormat& fmt, const UnicodeString& pat,
177 int32_t pos, int32_t width, const UnicodeString& pad);
178
179 void expectPad(DecimalFormat& fmt, const char *pat,
180 int32_t pos, int32_t width, const UnicodeString& pad) {
181 expectPad(fmt, UnicodeString(pat, ""), pos, width, pad);
182 }
183
184 void expectPat(DecimalFormat& fmt, const UnicodeString& exp);
185
186 void expectPat(DecimalFormat& fmt, const char *exp) {
187 expectPat(fmt, UnicodeString(exp, ""));
188 }
189
190 void expectPad(DecimalFormat& fmt, const UnicodeString& pat,
191 int32_t pos);
192
193 void expectPad(DecimalFormat& fmt, const char *pat,
194 int32_t pos) {
195 expectPad(fmt, pat, pos, 0, (UChar)0);
196 }
197
198 // internal utility routine
199 static UnicodeString& escape(UnicodeString& s);
200
201 enum { ILLEGAL = -1 };
202
203 // internal subtest used by TestRounding487
204 void roundingTest(NumberFormat& nf, double x, int32_t maxFractionDigits, const char* expected);
205 };
206
207 #endif /* #if !UCONFIG_NO_FORMATTING */
208
209 #endif // _NUMBERFORMATTEST_