]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/numfmtst.h
1 /********************************************************************
3 * Copyright (c) 1997-2004, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
7 #ifndef _NUMBERFORMATTEST_
8 #define _NUMBERFORMATTEST_
10 #include "unicode/utypes.h"
12 #if !UCONFIG_NO_FORMATTING
14 #include "unicode/numfmt.h"
15 #include "unicode/decimfmt.h"
19 * Performs various in-depth test on NumberFormat
21 class NumberFormatTest
: public CalendarTimeZoneTest
{
24 void runIndexedTest( int32_t index
, UBool exec
, const char* &name
, char* par
);
28 * Test APIs (to increase code coverage)
32 * Test the handling of quotes
34 void TestQuotes(void);
36 * Test patterns with exponential representation
38 void TestExponential(void);
40 * Test handling of patterns with currency symbols
42 void TestCurrencySign(void);
44 * Test different format patterns
46 void TestPatterns(void);
48 * API coverage for DigitList
50 void TestDigitList(void);
53 * Test localized currency patterns.
55 void TestCurrency(void);
58 * Test the Currency object handling, new as of ICU 2.2.
60 void TestCurrencyObject(void);
62 void TestCurrencyPatterns(void);
65 * Do rudimentary testing of parsing.
69 * Test proper rounding by the format method.
71 void TestRounding487(void);
73 // New tests for alphaWorks upgrade
74 void TestExponent(void);
76 void TestScientific(void);
78 void TestScientific2(void);
80 void TestScientificGrouping(void);
84 void TestSurrogateSupport(void);
87 * Test the functioning of the secondary grouping value.
89 void TestSecondaryGrouping(void);
91 void TestWhiteSpaceParsing(void);
93 void TestComplexCurrency(void);
96 void TestPatterns2(void);
99 * Test currency registration.
101 void TestRegCurrency(void);
103 void TestCurrencyNames(void);
105 void TestSymbolsWithBadLocale(void);
107 void TestAdoptDecimalFormatSymbols(void);
109 void TestPerMill(void);
111 void TestIllegalPatterns(void);
113 void TestCases(void);
117 static UBool
equalValue(const Formattable
& a
, const Formattable
& b
);
119 void expect2(NumberFormat
& fmt
, const Formattable
& n
, const UnicodeString
& str
);
121 void expect2(NumberFormat
& fmt
, const Formattable
& n
, const char* str
) {
122 expect2(fmt
, n
, UnicodeString(str
, ""));
125 void expect2(NumberFormat
* fmt
, const Formattable
& n
, const UnicodeString
& str
, UErrorCode ec
);
127 void expect2(NumberFormat
* fmt
, const Formattable
& n
, const char* str
, UErrorCode ec
) {
128 expect2(fmt
, n
, UnicodeString(str
, ""), ec
);
131 void expect(NumberFormat
& fmt
, const UnicodeString
& str
, const Formattable
& n
);
133 void expect(NumberFormat
& fmt
, const char *str
, const Formattable
& n
) {
134 expect(fmt
, UnicodeString(str
, ""), n
);
137 void expect(NumberFormat
& fmt
, const Formattable
& n
,
138 const UnicodeString
& exp
, UBool rt
=TRUE
);
140 void expect(NumberFormat
& fmt
, const Formattable
& n
,
141 const char *exp
, UBool rt
=TRUE
) {
142 expect(fmt
, n
, UnicodeString(exp
, ""), rt
);
145 void expect(NumberFormat
* fmt
, const Formattable
& n
,
146 const UnicodeString
& exp
, UErrorCode
);
148 void expect(NumberFormat
* fmt
, const Formattable
& n
,
149 const char *exp
, UErrorCode errorCode
) {
150 expect(fmt
, n
, UnicodeString(exp
, ""), errorCode
);
153 void expectCurrency(NumberFormat
& nf
, const Locale
& locale
,
154 double value
, const UnicodeString
& string
);
156 void expectPat(DecimalFormat
& fmt
, const UnicodeString
& exp
);
158 void expectPat(DecimalFormat
& fmt
, const char *exp
) {
159 expectPat(fmt
, UnicodeString(exp
, ""));
162 void expectPad(DecimalFormat
& fmt
, const UnicodeString
& pat
,
165 void expectPad(DecimalFormat
& fmt
, const char *pat
,
167 expectPad(fmt
, pat
, pos
, 0, (UChar
)0);
170 void expectPad(DecimalFormat
& fmt
, const UnicodeString
& pat
,
171 int32_t pos
, int32_t width
, UChar pad
);
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
);
178 void expectPad(DecimalFormat
& fmt
, const UnicodeString
& pat
,
179 int32_t pos
, int32_t width
, const UnicodeString
& pad
);
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
);
186 // internal utility routine
187 static UnicodeString
& escape(UnicodeString
& s
);
189 enum { ILLEGAL
= -1 };
191 // internal subtest used by TestRounding487
192 void roundingTest(NumberFormat
& nf
, double x
, int32_t maxFractionDigits
, const char* expected
);
195 #endif /* #if !UCONFIG_NO_FORMATTING */
197 #endif // _NUMBERFORMATTEST_