]> git.saurik.com Git - apple/icu.git/blame - icuSources/test/intltest/numfmtst.h
ICU-6.2.4.tar.gz
[apple/icu.git] / icuSources / test / intltest / numfmtst.h
CommitLineData
b75a7d8f
A
1/********************************************************************
2 * COPYRIGHT:
374ca955 3 * Copyright (c) 1997-2004, International Business Machines Corporation and
b75a7d8f
A
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 **/
21class 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
374ca955
A
78 void TestScientific2(void);
79
80 void TestScientificGrouping(void);
81
82 void TestInt64(void);
83
b75a7d8f
A
84 void TestSurrogateSupport(void);
85
86 /**
87 * Test the functioning of the secondary grouping value.
88 */
89 void TestSecondaryGrouping(void);
90
91 void TestWhiteSpaceParsing(void);
92
93 void TestComplexCurrency(void);
94
95 void TestPad(void);
96 void TestPatterns2(void);
97
98 /**
99 * Test currency registration.
100 */
101 void TestRegCurrency(void);
102
374ca955
A
103 void TestCurrencyNames(void);
104
b75a7d8f
A
105 void TestSymbolsWithBadLocale(void);
106
107 void TestAdoptDecimalFormatSymbols(void);
108
374ca955
A
109 void TestPerMill(void);
110
111 void TestIllegalPatterns(void);
112
113 void TestCases(void);
114
b75a7d8f
A
115 private:
116
117 static UBool equalValue(const Formattable& a, const Formattable& b);
118
119 void expect2(NumberFormat& fmt, const Formattable& n, const UnicodeString& str);
120
121 void expect2(NumberFormat& fmt, const Formattable& n, const char* str) {
122 expect2(fmt, n, UnicodeString(str, ""));
123 }
124
125 void expect2(NumberFormat* fmt, const Formattable& n, const UnicodeString& str, UErrorCode ec);
126
127 void expect2(NumberFormat* fmt, const Formattable& n, const char* str, UErrorCode ec) {
128 expect2(fmt, n, UnicodeString(str, ""), ec);
129 }
130
131 void expect(NumberFormat& fmt, const UnicodeString& str, const Formattable& n);
132
133 void expect(NumberFormat& fmt, const char *str, const Formattable& n) {
134 expect(fmt, UnicodeString(str, ""), n);
135 }
136
137 void expect(NumberFormat& fmt, const Formattable& n,
138 const UnicodeString& exp, UBool rt=TRUE);
139
140 void expect(NumberFormat& fmt, const Formattable& n,
141 const char *exp, UBool rt=TRUE) {
142 expect(fmt, n, UnicodeString(exp, ""), rt);
143 }
144
145 void expect(NumberFormat* fmt, const Formattable& n,
146 const UnicodeString& exp, UErrorCode);
147
148 void expect(NumberFormat* fmt, const Formattable& n,
149 const char *exp, UErrorCode errorCode) {
150 expect(fmt, n, UnicodeString(exp, ""), errorCode);
151 }
152
153 void expectCurrency(NumberFormat& nf, const Locale& locale,
154 double value, const UnicodeString& string);
155
156 void expectPat(DecimalFormat& fmt, const UnicodeString& exp);
157
158 void expectPat(DecimalFormat& fmt, const char *exp) {
159 expectPat(fmt, UnicodeString(exp, ""));
160 }
161
162 void expectPad(DecimalFormat& fmt, const UnicodeString& pat,
163 int32_t pos);
164
165 void expectPad(DecimalFormat& fmt, const char *pat,
166 int32_t pos) {
167 expectPad(fmt, pat, pos, 0, (UChar)0);
168 }
169
170 void expectPad(DecimalFormat& fmt, const UnicodeString& pat,
171 int32_t pos, int32_t width, UChar pad);
172
173 void expectPad(DecimalFormat& fmt, const char *pat,
174 int32_t pos, int32_t width, UChar pad) {
175 expectPad(fmt, UnicodeString(pat, ""), pos, width, pad);
176 }
177
178 void expectPad(DecimalFormat& fmt, const UnicodeString& pat,
179 int32_t pos, int32_t width, const UnicodeString& pad);
180
181 void expectPad(DecimalFormat& fmt, const char *pat,
182 int32_t pos, int32_t width, const UnicodeString& pad) {
183 expectPad(fmt, UnicodeString(pat, ""), pos, width, pad);
184 }
185
186 // internal utility routine
187 static UnicodeString& escape(UnicodeString& s);
188
189 enum { ILLEGAL = -1 };
190
191 // internal subtest used by TestRounding487
192 void roundingTest(NumberFormat& nf, double x, int32_t maxFractionDigits, const char* expected);
193};
194
195#endif /* #if !UCONFIG_NO_FORMATTING */
196
197#endif // _NUMBERFORMATTEST_