scuffed-code/icu4c/source/test/intltest/numfmtst.h

184 lines
5.0 KiB
C
Raw Normal View History

/********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2001, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
1999-08-16 21:50:52 +00:00
#ifndef _NUMBERFORMATTEST_
#define _NUMBERFORMATTEST_
#include "unicode/utypes.h"
#if !UCONFIG_NO_FORMATTING
#include "unicode/numfmt.h"
#include "unicode/decimfmt.h"
1999-08-16 21:50:52 +00:00
#include "caltztst.h"
/**
* Performs various in-depth test on NumberFormat
**/
class NumberFormatTest: public CalendarTimeZoneTest {
1999-08-16 21:50:52 +00:00
// IntlTest override
void runIndexedTest( int32_t index, UBool exec, const char* &name, char* par );
public:
/**
* Test APIs (to increase code coverage)
*/
void TestAPI(void);
/**
1999-08-16 21:50:52 +00:00
* Test the handling of quotes
**/
void TestQuotes(void);
1999-08-16 21:50:52 +00:00
/**
* Test patterns with exponential representation
**/
void TestExponential(void);
1999-08-16 21:50:52 +00:00
/**
* Test handling of patterns with currency symbols
**/
void TestCurrencySign(void);
1999-08-16 21:50:52 +00:00
/**
* Test different format patterns
**/
void TestPatterns(void);
/**
* API coverage for DigitList
**/
void TestDigitList(void);
1999-08-16 21:50:52 +00:00
/**
* Test localized currency patterns.
*/
void TestCurrency(void);
/**
* Test the Currency object handling, new as of ICU 2.2.
*/
void TestCurrencyObject(void);
void TestCurrencyPatterns(void);
1999-08-16 21:50:52 +00:00
/**
* Do rudimentary testing of parsing.
*/
void TestParse(void);
1999-08-16 21:50:52 +00:00
/**
* Test proper rounding by the format method.
*/
void TestRounding487(void);
1999-08-16 21:50:52 +00:00
// New tests for alphaWorks upgrade
void TestExponent(void);
void TestScientific(void);
void TestSurrogateSupport(void);
/**
* Test the functioning of the secondary grouping value.
*/
void TestSecondaryGrouping(void);
void TestWhiteSpaceParsing(void);
void TestComplexCurrency(void);
void TestPad(void);
void TestPatterns2(void);
/**
* Test currency registration.
*/
void TestRegCurrency(void);
void TestSymbolsWithBadLocale(void);
void TestAdoptDecimalFormatSymbols(void);
private:
static UBool equalValue(const Formattable& a, const Formattable& b);
void expect2(NumberFormat& fmt, const Formattable& n, const UnicodeString& str);
void expect2(NumberFormat& fmt, const Formattable& n, const char* str) {
expect2(fmt, n, UnicodeString(str, ""));
}
void expect2(NumberFormat* fmt, const Formattable& n, const UnicodeString& str, UErrorCode ec);
void expect2(NumberFormat* fmt, const Formattable& n, const char* str, UErrorCode ec) {
expect2(fmt, n, UnicodeString(str, ""), ec);
}
void expect(NumberFormat& fmt, const UnicodeString& str, const Formattable& n);
void expect(NumberFormat& fmt, const char *str, const Formattable& n) {
expect(fmt, UnicodeString(str, ""), n);
}
1999-08-16 21:50:52 +00:00
void expect(NumberFormat& fmt, const Formattable& n,
const UnicodeString& exp, UBool rt=TRUE);
void expect(NumberFormat& fmt, const Formattable& n,
const char *exp, UBool rt=TRUE) {
expect(fmt, n, UnicodeString(exp, ""), rt);
}
1999-08-16 21:50:52 +00:00
void expect(NumberFormat* fmt, const Formattable& n,
const UnicodeString& exp, UErrorCode);
void expect(NumberFormat* fmt, const Formattable& n,
const char *exp, UErrorCode errorCode) {
expect(fmt, n, UnicodeString(exp, ""), errorCode);
}
void expectCurrency(NumberFormat& nf, const Locale& locale,
double value, const UnicodeString& string);
void expectPat(DecimalFormat& fmt, const UnicodeString& exp);
void expectPat(DecimalFormat& fmt, const char *exp) {
expectPat(fmt, UnicodeString(exp, ""));
}
1999-08-16 21:50:52 +00:00
void expectPad(DecimalFormat& fmt, const UnicodeString& pat,
int32_t pos);
void expectPad(DecimalFormat& fmt, const char *pat,
int32_t pos) {
expectPad(fmt, pat, pos, 0, (UChar)0);
}
1999-08-16 21:50:52 +00:00
void expectPad(DecimalFormat& fmt, const UnicodeString& pat,
int32_t pos, int32_t width, UChar pad);
void expectPad(DecimalFormat& fmt, const char *pat,
int32_t pos, int32_t width, UChar pad) {
expectPad(fmt, UnicodeString(pat, ""), pos, width, pad);
}
void expectPad(DecimalFormat& fmt, const UnicodeString& pat,
int32_t pos, int32_t width, const UnicodeString& pad);
void expectPad(DecimalFormat& fmt, const char *pat,
int32_t pos, int32_t width, const UnicodeString& pad) {
expectPad(fmt, UnicodeString(pat, ""), pos, width, pad);
}
// internal utility routine
static UnicodeString& escape(UnicodeString& s);
1999-08-16 21:50:52 +00:00
enum { ILLEGAL = -1 };
// internal subtest used by TestRounding487
void roundingTest(NumberFormat& nf, double x, int32_t maxFractionDigits, const char* expected);
1999-08-16 21:50:52 +00:00
};
#endif /* #if !UCONFIG_NO_FORMATTING */
1999-08-16 21:50:52 +00:00
#endif // _NUMBERFORMATTEST_