ICU-3090 add regression test to prove 3090 is user error

X-SVN-Rev: 14489
This commit is contained in:
Alan Liu 2004-02-12 01:10:19 +00:00
parent 6d5aaf8514
commit 967064db9c
3 changed files with 37 additions and 2 deletions

View file

@ -65,6 +65,8 @@ void NumberFormatTest::runIndexedTest( int32_t index, UBool exec, const char* &n
CASE(23,TestScientificGrouping);
CASE(24,TestInt64);
CASE(25,TestPerMill);
default: name = ""; break;
}
}
@ -1470,6 +1472,24 @@ void NumberFormatTest::TestAdoptDecimalFormatSymbols(void) {
}
}
void NumberFormatTest::TestPerMill() {
UErrorCode ec = U_ZERO_ERROR;
UnicodeString str;
DecimalFormat fmt(ctou("###.###\\u2030"), ec);
if (!assertSuccess("DecimalFormat ct", ec)) return;
assertEquals("0.4857 x ###.###\\u2030",
ctou("485.7\\u2030"), fmt.format(0.4857, str));
DecimalFormatSymbols sym(Locale::getUS(), ec);
sym.setSymbol(DecimalFormatSymbols::kPerMillSymbol, ctou("m"));
DecimalFormat fmt2("", sym, ec);
fmt2.applyLocalizedPattern("###.###m", ec);
if (!assertSuccess("setup", ec)) return;
str.truncate(0);
assertEquals("0.4857 x ###.###m",
"485.7m", fmt2.format(0.4857, str));
}
//----------------------------------------------------------------------
// Support methods
//----------------------------------------------------------------------

View file

@ -104,6 +104,8 @@ class NumberFormatTest: public CalendarTimeZoneTest {
void TestAdoptDecimalFormatSymbols(void);
void TestPerMill(void);
private:
static UBool equalValue(const Formattable& a, const Formattable& b);

View file

@ -4,8 +4,8 @@
* others. All Rights Reserved. *
*******************************************************************************
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/test/format/NumberFormatTest.java,v $
* $Date: 2003/11/19 19:51:56 $
* $Revision: 1.21 $
* $Date: 2004/02/12 01:10:19 $
* $Revision: 1.22 $
*
*****************************************************************************************
*/
@ -928,6 +928,19 @@ public class NumberFormatTest extends com.ibm.icu.dev.test.TestFmwk {
}
}
public void TestPerMill() {
DecimalFormat fmt = new DecimalFormat("###.###\u2030");
assertEquals("0.4857 x ###.###\u2030",
"485.7\u2030", fmt.format(0.4857));
DecimalFormatSymbols sym = new DecimalFormatSymbols(Locale.ENGLISH);
sym.setPerMill('m');
DecimalFormat fmt2 = new DecimalFormat("", sym);
fmt2.applyLocalizedPattern("###.###m");
assertEquals("0.4857 x ###.###m",
"485.7m", fmt2.format(0.4857));
}
//------------------------------------------------------------------
// Support methods
//------------------------------------------------------------------