]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/numfmtst.h
1 /********************************************************************
3 * Copyright (c) 1997-2003, 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 TestSurrogateSupport(void);
81 * Test the functioning of the secondary grouping value.
83 void TestSecondaryGrouping(void);
85 void TestWhiteSpaceParsing(void);
87 void TestComplexCurrency(void);
90 void TestPatterns2(void);
93 * Test currency registration.
95 void TestRegCurrency(void);
97 void TestSymbolsWithBadLocale(void);
99 void TestAdoptDecimalFormatSymbols(void);
103 static UBool
equalValue(const Formattable
& a
, const Formattable
& b
);
105 void expect2(NumberFormat
& fmt
, const Formattable
& n
, const UnicodeString
& str
);
107 void expect2(NumberFormat
& fmt
, const Formattable
& n
, const char* str
) {
108 expect2(fmt
, n
, UnicodeString(str
, ""));
111 void expect2(NumberFormat
* fmt
, const Formattable
& n
, const UnicodeString
& str
, UErrorCode ec
);
113 void expect2(NumberFormat
* fmt
, const Formattable
& n
, const char* str
, UErrorCode ec
) {
114 expect2(fmt
, n
, UnicodeString(str
, ""), ec
);
117 void expect(NumberFormat
& fmt
, const UnicodeString
& str
, const Formattable
& n
);
119 void expect(NumberFormat
& fmt
, const char *str
, const Formattable
& n
) {
120 expect(fmt
, UnicodeString(str
, ""), n
);
123 void expect(NumberFormat
& fmt
, const Formattable
& n
,
124 const UnicodeString
& exp
, UBool rt
=TRUE
);
126 void expect(NumberFormat
& fmt
, const Formattable
& n
,
127 const char *exp
, UBool rt
=TRUE
) {
128 expect(fmt
, n
, UnicodeString(exp
, ""), rt
);
131 void expect(NumberFormat
* fmt
, const Formattable
& n
,
132 const UnicodeString
& exp
, UErrorCode
);
134 void expect(NumberFormat
* fmt
, const Formattable
& n
,
135 const char *exp
, UErrorCode errorCode
) {
136 expect(fmt
, n
, UnicodeString(exp
, ""), errorCode
);
139 void expectCurrency(NumberFormat
& nf
, const Locale
& locale
,
140 double value
, const UnicodeString
& string
);
142 void expectPat(DecimalFormat
& fmt
, const UnicodeString
& exp
);
144 void expectPat(DecimalFormat
& fmt
, const char *exp
) {
145 expectPat(fmt
, UnicodeString(exp
, ""));
148 void expectPad(DecimalFormat
& fmt
, const UnicodeString
& pat
,
151 void expectPad(DecimalFormat
& fmt
, const char *pat
,
153 expectPad(fmt
, pat
, pos
, 0, (UChar
)0);
156 void expectPad(DecimalFormat
& fmt
, const UnicodeString
& pat
,
157 int32_t pos
, int32_t width
, UChar pad
);
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
);
164 void expectPad(DecimalFormat
& fmt
, const UnicodeString
& pat
,
165 int32_t pos
, int32_t width
, const UnicodeString
& pad
);
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
);
172 // internal utility routine
173 static UnicodeString
& escape(UnicodeString
& s
);
175 enum { ILLEGAL
= -1 };
177 // internal subtest used by TestRounding487
178 void roundingTest(NumberFormat
& nf
, double x
, int32_t maxFractionDigits
, const char* expected
);
181 #endif /* #if !UCONFIG_NO_FORMATTING */
183 #endif // _NUMBERFORMATTEST_