ICU-2892 reinstate exhaustive mode; make sure to test currency prefix, suffix, and choice even in quick mode; clean up
X-SVN-Rev: 12009
This commit is contained in:
parent
913cae8031
commit
6471e31f95
@ -4,8 +4,8 @@
|
|||||||
* others. All Rights Reserved. *
|
* others. All Rights Reserved. *
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/test/format/IntlTestNumberFormat.java,v $
|
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/test/format/IntlTestNumberFormat.java,v $
|
||||||
* $Date: 2003/05/14 19:03:16 $
|
* $Date: 2003/05/19 21:08:58 $
|
||||||
* $Revision: 1.4 $
|
* $Revision: 1.5 $
|
||||||
*
|
*
|
||||||
*****************************************************************************************
|
*****************************************************************************************
|
||||||
*/
|
*/
|
||||||
@ -16,7 +16,7 @@
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
package com.ibm.icu.dev.test.format;
|
package com.ibm.icu.dev.test.format;
|
||||||
|
import java.util.Locale;
|
||||||
import com.ibm.icu.text.*;
|
import com.ibm.icu.text.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -25,67 +25,55 @@ import com.ibm.icu.text.*;
|
|||||||
*/
|
*/
|
||||||
public class IntlTestNumberFormat extends com.ibm.icu.dev.test.TestFmwk {
|
public class IntlTestNumberFormat extends com.ibm.icu.dev.test.TestFmwk {
|
||||||
|
|
||||||
public NumberFormat fNumberFormat = NumberFormat.getInstance();
|
public NumberFormat fNumberFormat;
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
new IntlTestNumberFormat().run(args);
|
new IntlTestNumberFormat().run(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Internal use
|
* Internal use
|
||||||
**/
|
*/
|
||||||
public void _testLocale(java.util.Locale locale, String localeName) {
|
public void _testLocale(Locale locale) {
|
||||||
String name;
|
String localeName = locale + " (" + locale.getDisplayName() + ")";
|
||||||
// locale = java.util.Locale.getDefault();
|
|
||||||
// localeName = locale.getDisplayName();
|
|
||||||
|
|
||||||
name = "Number test";
|
logln("Number test " + localeName);
|
||||||
logln(name + " ( " + localeName + " ) ");
|
|
||||||
fNumberFormat = NumberFormat.getInstance(locale);
|
fNumberFormat = NumberFormat.getInstance(locale);
|
||||||
TestFormat();
|
_testFormat();
|
||||||
|
|
||||||
name = "Currency test";
|
logln("Currency test " + localeName);
|
||||||
logln(name + " (" + localeName + ")");
|
|
||||||
fNumberFormat = NumberFormat.getCurrencyInstance(locale);
|
fNumberFormat = NumberFormat.getCurrencyInstance(locale);
|
||||||
TestFormat(/* par */);
|
_testFormat();
|
||||||
|
|
||||||
name = "Percent test";
|
logln("Percent test " + localeName);
|
||||||
logln(name + " (" + localeName + ")");
|
|
||||||
fNumberFormat = NumberFormat.getPercentInstance(locale);
|
fNumberFormat = NumberFormat.getPercentInstance(locale);
|
||||||
TestFormat(/* par */);
|
_testFormat();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* call TestFormat for currency, percent and plain number instances
|
* call _testFormat for currency, percent and plain number instances
|
||||||
**/
|
*/
|
||||||
public void TestLocale() {
|
public void TestLocale() {
|
||||||
String name;
|
Locale locale = Locale.getDefault();
|
||||||
String localeName;
|
String localeName = locale + " (" + locale.getDisplayName() + ")";
|
||||||
java.util.Locale locale = java.util.Locale.getDefault();
|
|
||||||
localeName = locale.getDisplayName();
|
|
||||||
|
|
||||||
name = "Number test";
|
logln("Number test " + localeName);
|
||||||
logln(name + " ( " + localeName + " ) ");
|
fNumberFormat = NumberFormat.getInstance(locale);
|
||||||
fNumberFormat = NumberFormat.getInstance();
|
_testFormat();
|
||||||
TestFormat();
|
|
||||||
|
|
||||||
name = "Currency test";
|
logln("Currency test " + localeName);
|
||||||
logln(name + " (" + localeName + ")");
|
fNumberFormat = NumberFormat.getCurrencyInstance(locale);
|
||||||
fNumberFormat = NumberFormat.getCurrencyInstance();
|
_testFormat();
|
||||||
TestFormat(/* par */);
|
|
||||||
|
|
||||||
name = "Percent test";
|
|
||||||
logln(name + " (" + localeName + ")");
|
|
||||||
fNumberFormat = NumberFormat.getPercentInstance();
|
|
||||||
TestFormat(/* par */);
|
|
||||||
|
|
||||||
|
logln("Percent test " + localeName);
|
||||||
|
fNumberFormat = NumberFormat.getPercentInstance(locale);
|
||||||
|
_testFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* call tryIt with many variations, called by testLocale
|
* call tryIt with many variations, called by testLocale
|
||||||
**/
|
*/
|
||||||
public void TestFormat() {
|
public void _testFormat() {
|
||||||
|
|
||||||
if (fNumberFormat == null){
|
if (fNumberFormat == null){
|
||||||
errln("**** FAIL: Null format returned by createXxxInstance.");
|
errln("**** FAIL: Null format returned by createXxxInstance.");
|
||||||
@ -156,8 +144,8 @@ public class IntlTestNumberFormat extends com.ibm.icu.dev.test.TestFmwk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* perform tests using aNumber and fNumberFormat, called in many variations
|
* Perform tests using aNumber and fNumberFormat, called in many variations
|
||||||
**/
|
*/
|
||||||
public void tryIt(double aNumber) {
|
public void tryIt(double aNumber) {
|
||||||
final int DEPTH = 10;
|
final int DEPTH = 10;
|
||||||
double[] number = new double[DEPTH];
|
double[] number = new double[DEPTH];
|
||||||
@ -248,7 +236,7 @@ public class IntlTestNumberFormat extends com.ibm.icu.dev.test.TestFmwk {
|
|||||||
* test NumberFormat::getAvailableLocales
|
* test NumberFormat::getAvailableLocales
|
||||||
**/
|
**/
|
||||||
public void TestAvailableLocales() {
|
public void TestAvailableLocales() {
|
||||||
final java.util.Locale[] locales = NumberFormat.getAvailableLocales();
|
final Locale[] locales = NumberFormat.getAvailableLocales();
|
||||||
int count = locales.length;
|
int count = locales.length;
|
||||||
logln(count + " available locales");
|
logln(count + " available locales");
|
||||||
if (count != 0)
|
if (count != 0)
|
||||||
@ -272,16 +260,29 @@ public class IntlTestNumberFormat extends com.ibm.icu.dev.test.TestFmwk {
|
|||||||
public void TestMonster() {
|
public void TestMonster() {
|
||||||
final String SEP = "============================================================\n";
|
final String SEP = "============================================================\n";
|
||||||
int count;
|
int count;
|
||||||
final java.util.Locale[] locales = NumberFormat.getAvailableLocales();
|
final Locale[] allLocales = NumberFormat.getAvailableLocales();
|
||||||
|
Locale[] locales = allLocales;
|
||||||
count = locales.length;
|
count = locales.length;
|
||||||
if (count != 0)
|
if (count != 0)
|
||||||
{
|
{
|
||||||
count = 3; // just test 3 locales
|
if (getInclusion() < 10 && count > 6) {
|
||||||
|
count = 6;
|
||||||
|
locales = new Locale[6];
|
||||||
|
locales[0] = allLocales[0];
|
||||||
|
locales[1] = allLocales[1];
|
||||||
|
locales[2] = allLocales[2];
|
||||||
|
// In a quick test, make sure we test locales that use
|
||||||
|
// currency prefix, currency suffix, and choice currency
|
||||||
|
// logic. Otherwise bugs in these areas can slip through.
|
||||||
|
locales[3] = new Locale("ar", "AE", "");
|
||||||
|
locales[4] = new Locale("cs", "CZ", "");
|
||||||
|
locales[5] = new Locale("en", "IN", "");
|
||||||
|
}
|
||||||
for (int i=0; i<count; ++i)
|
for (int i=0; i<count; ++i)
|
||||||
{
|
{
|
||||||
String name = locales[i].getDisplayName();
|
String name = locales[i].getDisplayName();
|
||||||
logln(SEP);
|
logln(SEP);
|
||||||
_testLocale(/* par, */locales[i], name);
|
_testLocale(locales[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user