1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
********************************************************************
|
|
|
|
* COPYRIGHT:
|
|
|
|
* (C) Copyright Taligent, Inc., 1997
|
|
|
|
* (C) Copyright International Business Machines Corporation, 1997 - 1998
|
|
|
|
* Licensed Material - Program-Property of IBM - All Rights Reserved.
|
|
|
|
* US Government Users Restricted Rights - Use, duplication, or disclosure
|
|
|
|
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
|
|
*
|
|
|
|
********************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NUMBERFORMATTEST_
|
|
|
|
#define _NUMBERFORMATTEST_
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
#include "unicode/utypes.h"
|
1999-08-16 21:50:52 +00:00
|
|
|
#include "caltztst.h"
|
|
|
|
class NumberFormat;
|
|
|
|
class DecimalFormat;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Performs various in-depth test on NumberFormat
|
|
|
|
**/
|
|
|
|
class NumberFormatTest: public CalendarTimeZoneTest {
|
|
|
|
// IntlTest override
|
|
|
|
void runIndexedTest( int32_t index, bool_t exec, char* &name, char* par );
|
|
|
|
public:
|
|
|
|
/*
|
|
|
|
* Test the handling of quotes
|
|
|
|
**/
|
1999-12-22 22:57:04 +00:00
|
|
|
virtual void TestQuotes(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
/**
|
|
|
|
* Test patterns with exponential representation
|
|
|
|
**/
|
1999-12-22 22:57:04 +00:00
|
|
|
virtual void TestExponential(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
/**
|
|
|
|
* Test handling of patterns with currency symbols
|
|
|
|
**/
|
1999-12-22 22:57:04 +00:00
|
|
|
virtual void TestCurrencySign(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
/**
|
|
|
|
* Test different format patterns
|
|
|
|
**/
|
1999-12-22 22:57:04 +00:00
|
|
|
virtual void TestPatterns(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
public: // package
|
|
|
|
// internal utility routine
|
|
|
|
static UnicodeString& escape(UnicodeString& s);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Test localized currency patterns.
|
|
|
|
*/
|
1999-12-22 22:57:04 +00:00
|
|
|
virtual void TestCurrency(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
/**
|
|
|
|
* Do rudimentary testing of parsing.
|
|
|
|
*/
|
1999-12-22 22:57:04 +00:00
|
|
|
virtual void TestParse(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
/**
|
|
|
|
* Test proper rounding by the format method.
|
|
|
|
*/
|
1999-12-22 22:57:04 +00:00
|
|
|
virtual void TestRounding487(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
// New tests for alphaWorks upgrade
|
1999-12-22 22:57:04 +00:00
|
|
|
virtual void TestExponent(void);
|
|
|
|
virtual void TestScientific(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
void expect(NumberFormat& fmt, const UnicodeString& str, int32_t n);
|
|
|
|
void expect(NumberFormat& fmt, const Formattable& n,
|
|
|
|
const UnicodeString& exp);
|
|
|
|
void expect(NumberFormat* fmt, const Formattable& n,
|
|
|
|
const UnicodeString& exp, UErrorCode);
|
1999-12-22 22:57:04 +00:00
|
|
|
void TestPad(void);
|
|
|
|
void TestPatterns2(void);
|
1999-08-16 21:50:52 +00:00
|
|
|
void expectPad(DecimalFormat& fmt, const UnicodeString& pat,
|
|
|
|
int32_t pos);
|
|
|
|
void expectPad(DecimalFormat& fmt, const UnicodeString& pat,
|
|
|
|
int32_t pos, int32_t width, UChar pad);
|
|
|
|
void expectPat(DecimalFormat& fmt, const UnicodeString& exp);
|
|
|
|
enum { ILLEGAL = -1 };
|
|
|
|
|
|
|
|
public: // package
|
|
|
|
// internal subtest used by TestRounding487
|
|
|
|
virtual void roundingTest(NumberFormat& nf, double x, int32_t maxFractionDigits, const char* expected);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _NUMBERFORMATTEST_
|