]> git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/numfmtst.h
ICU-3.13.tar.gz
[apple/icu.git] / icuSources / test / intltest / numfmtst.h
1 /********************************************************************
2 * COPYRIGHT:
3 * Copyright (c) 1997-2003, 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 * Test the handling of quotes
33 **/
34 void TestQuotes(void);
35 /**
36 * Test patterns with exponential representation
37 **/
38 void TestExponential(void);
39 /**
40 * Test handling of patterns with currency symbols
41 **/
42 void TestCurrencySign(void);
43 /**
44 * Test different format patterns
45 **/
46 void TestPatterns(void);
47 /**
48 * API coverage for DigitList
49 **/
50 void TestDigitList(void);
51
52 /**
53 * Test localized currency patterns.
54 */
55 void TestCurrency(void);
56
57 /**
58 * Test the Currency object handling, new as of ICU 2.2.
59 */
60 void TestCurrencyObject(void);
61
62 void TestCurrencyPatterns(void);
63
64 /**
65 * Do rudimentary testing of parsing.
66 */
67 void TestParse(void);
68 /**
69 * Test proper rounding by the format method.
70 */
71 void TestRounding487(void);
72
73 // New tests for alphaWorks upgrade
74 void TestExponent(void);
75
76 void TestScientific(void);
77
78 void TestSurrogateSupport(void);
79
80 /**
81 * Test the functioning of the secondary grouping value.
82 */
83 void TestSecondaryGrouping(void);
84
85 void TestWhiteSpaceParsing(void);
86
87 void TestComplexCurrency(void);
88
89 void TestPad(void);
90 void TestPatterns2(void);
91
92 /**
93 * Test currency registration.
94 */
95 void TestRegCurrency(void);
96
97 void TestSymbolsWithBadLocale(void);
98
99 void TestAdoptDecimalFormatSymbols(void);
100
101 private:
102
103 static UBool equalValue(const Formattable& a, const Formattable& b);
104
105 void expect2(NumberFormat& fmt, const Formattable& n, const UnicodeString& str);
106
107 void expect2(NumberFormat& fmt, const Formattable& n, const char* str) {
108 expect2(fmt, n, UnicodeString(str, ""));
109 }
110
111 void expect2(NumberFormat* fmt, const Formattable& n, const UnicodeString& str, UErrorCode ec);
112
113 void expect2(NumberFormat* fmt, const Formattable& n, const char* str, UErrorCode ec) {
114 expect2(fmt, n, UnicodeString(str, ""), ec);
115 }
116
117 void expect(NumberFormat& fmt, const UnicodeString& str, const Formattable& n);
118
119 void expect(NumberFormat& fmt, const char *str, const Formattable& n) {
120 expect(fmt, UnicodeString(str, ""), n);
121 }
122
123 void expect(NumberFormat& fmt, const Formattable& n,
124 const UnicodeString& exp, UBool rt=TRUE);
125
126 void expect(NumberFormat& fmt, const Formattable& n,
127 const char *exp, UBool rt=TRUE) {
128 expect(fmt, n, UnicodeString(exp, ""), rt);
129 }
130
131 void expect(NumberFormat* fmt, const Formattable& n,
132 const UnicodeString& exp, UErrorCode);
133
134 void expect(NumberFormat* fmt, const Formattable& n,
135 const char *exp, UErrorCode errorCode) {
136 expect(fmt, n, UnicodeString(exp, ""), errorCode);
137 }
138
139 void expectCurrency(NumberFormat& nf, const Locale& locale,
140 double value, const UnicodeString& string);
141
142 void expectPat(DecimalFormat& fmt, const UnicodeString& exp);
143
144 void expectPat(DecimalFormat& fmt, const char *exp) {
145 expectPat(fmt, UnicodeString(exp, ""));
146 }
147
148 void expectPad(DecimalFormat& fmt, const UnicodeString& pat,
149 int32_t pos);
150
151 void expectPad(DecimalFormat& fmt, const char *pat,
152 int32_t pos) {
153 expectPad(fmt, pat, pos, 0, (UChar)0);
154 }
155
156 void expectPad(DecimalFormat& fmt, const UnicodeString& pat,
157 int32_t pos, int32_t width, UChar pad);
158
159 void expectPad(DecimalFormat& fmt, const char *pat,
160 int32_t pos, int32_t width, UChar pad) {
161 expectPad(fmt, UnicodeString(pat, ""), pos, width, pad);
162 }
163
164 void expectPad(DecimalFormat& fmt, const UnicodeString& pat,
165 int32_t pos, int32_t width, const UnicodeString& pad);
166
167 void expectPad(DecimalFormat& fmt, const char *pat,
168 int32_t pos, int32_t width, const UnicodeString& pad) {
169 expectPad(fmt, UnicodeString(pat, ""), pos, width, pad);
170 }
171
172 // internal utility routine
173 static UnicodeString& escape(UnicodeString& s);
174
175 enum { ILLEGAL = -1 };
176
177 // internal subtest used by TestRounding487
178 void roundingTest(NumberFormat& nf, double x, int32_t maxFractionDigits, const char* expected);
179 };
180
181 #endif /* #if !UCONFIG_NO_FORMATTING */
182
183 #endif // _NUMBERFORMATTEST_