ICU-12456 Fixed compiler warnings.
X-SVN-Rev: 38891
This commit is contained in:
parent
688cbee0ce
commit
7e54878b26
@ -287,7 +287,7 @@ public final class DayPeriodRules {
|
|||||||
|
|
||||||
private static DayPeriodRulesData loadData() {
|
private static DayPeriodRulesData loadData() {
|
||||||
DayPeriodRulesData data = new DayPeriodRulesData();
|
DayPeriodRulesData data = new DayPeriodRulesData();
|
||||||
ICUResourceBundle rb = (ICUResourceBundle)ICUResourceBundle.getBundleInstance(
|
ICUResourceBundle rb = ICUResourceBundle.getBundleInstance(
|
||||||
ICUData.ICU_BASE_NAME,
|
ICUData.ICU_BASE_NAME,
|
||||||
"dayPeriods",
|
"dayPeriods",
|
||||||
ICUResourceBundle.ICU_DATA_CLASS_LOADER,
|
ICUResourceBundle.ICU_DATA_CLASS_LOADER,
|
||||||
|
@ -33,11 +33,13 @@ import com.ibm.icu.util.ULocale;
|
|||||||
*/
|
*/
|
||||||
final class BreakIteratorFactory extends BreakIterator.BreakIteratorServiceShim {
|
final class BreakIteratorFactory extends BreakIterator.BreakIteratorServiceShim {
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object registerInstance(BreakIterator iter, ULocale locale, int kind) {
|
public Object registerInstance(BreakIterator iter, ULocale locale, int kind) {
|
||||||
iter.setText(new java.text.StringCharacterIterator(""));
|
iter.setText(new java.text.StringCharacterIterator(""));
|
||||||
return service.registerObject(iter, locale, kind);
|
return service.registerObject(iter, locale, kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean unregister(Object key) {
|
public boolean unregister(Object key) {
|
||||||
if (service.isDefault()) {
|
if (service.isDefault()) {
|
||||||
return false;
|
return false;
|
||||||
@ -45,6 +47,7 @@ final class BreakIteratorFactory extends BreakIterator.BreakIteratorServiceShim
|
|||||||
return service.unregisterFactory((Factory)key);
|
return service.unregisterFactory((Factory)key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Locale[] getAvailableLocales() {
|
public Locale[] getAvailableLocales() {
|
||||||
if (service == null) {
|
if (service == null) {
|
||||||
return ICUResourceBundle.getAvailableLocales();
|
return ICUResourceBundle.getAvailableLocales();
|
||||||
@ -53,6 +56,7 @@ final class BreakIteratorFactory extends BreakIterator.BreakIteratorServiceShim
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ULocale[] getAvailableULocales() {
|
public ULocale[] getAvailableULocales() {
|
||||||
if (service == null) {
|
if (service == null) {
|
||||||
return ICUResourceBundle.getAvailableULocales();
|
return ICUResourceBundle.getAvailableULocales();
|
||||||
@ -61,6 +65,7 @@ final class BreakIteratorFactory extends BreakIterator.BreakIteratorServiceShim
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public BreakIterator createBreakIterator(ULocale locale, int kind) {
|
public BreakIterator createBreakIterator(ULocale locale, int kind) {
|
||||||
// TODO: convert to ULocale when service switches over
|
// TODO: convert to ULocale when service switches over
|
||||||
if (service.isDefault()) {
|
if (service.isDefault()) {
|
||||||
@ -77,6 +82,7 @@ final class BreakIteratorFactory extends BreakIterator.BreakIteratorServiceShim
|
|||||||
super("BreakIterator");
|
super("BreakIterator");
|
||||||
|
|
||||||
class RBBreakIteratorFactory extends ICUResourceBundleFactory {
|
class RBBreakIteratorFactory extends ICUResourceBundleFactory {
|
||||||
|
@Override
|
||||||
protected Object handleCreate(ULocale loc, int kind, ICUService srvc) {
|
protected Object handleCreate(ULocale loc, int kind, ICUService srvc) {
|
||||||
return createBreakInstance(loc, kind);
|
return createBreakInstance(loc, kind);
|
||||||
}
|
}
|
||||||
@ -115,7 +121,7 @@ final class BreakIteratorFactory extends BreakIterator.BreakIteratorServiceShim
|
|||||||
private static BreakIterator createBreakInstance(ULocale locale, int kind) {
|
private static BreakIterator createBreakInstance(ULocale locale, int kind) {
|
||||||
|
|
||||||
RuleBasedBreakIterator iter = null;
|
RuleBasedBreakIterator iter = null;
|
||||||
ICUResourceBundle rb = (ICUResourceBundle)ICUResourceBundle.
|
ICUResourceBundle rb = ICUResourceBundle.
|
||||||
getBundleInstance(ICUData.ICU_BRKITR_BASE_NAME, locale,
|
getBundleInstance(ICUData.ICU_BRKITR_BASE_NAME, locale,
|
||||||
ICUResourceBundle.OpenType.LOCALE_ROOT);
|
ICUResourceBundle.OpenType.LOCALE_ROOT);
|
||||||
|
|
||||||
|
@ -29,14 +29,15 @@ public class ICUCurrencyDisplayInfoProvider implements CurrencyDisplayInfoProvid
|
|||||||
public ICUCurrencyDisplayInfoProvider() {
|
public ICUCurrencyDisplayInfoProvider() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public CurrencyDisplayInfo getInstance(ULocale locale, boolean withFallback) {
|
public CurrencyDisplayInfo getInstance(ULocale locale, boolean withFallback) {
|
||||||
ICUResourceBundle rb;
|
ICUResourceBundle rb;
|
||||||
if (withFallback) {
|
if (withFallback) {
|
||||||
rb = (ICUResourceBundle) ICUResourceBundle.getBundleInstance(
|
rb = ICUResourceBundle.getBundleInstance(
|
||||||
ICUData.ICU_CURR_BASE_NAME, locale, OpenType.LOCALE_DEFAULT_ROOT);
|
ICUData.ICU_CURR_BASE_NAME, locale, OpenType.LOCALE_DEFAULT_ROOT);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
rb = (ICUResourceBundle) ICUResourceBundle.getBundleInstance(
|
rb = ICUResourceBundle.getBundleInstance(
|
||||||
ICUData.ICU_CURR_BASE_NAME, locale, OpenType.LOCALE_ONLY);
|
ICUData.ICU_CURR_BASE_NAME, locale, OpenType.LOCALE_ONLY);
|
||||||
} catch (MissingResourceException e) {
|
} catch (MissingResourceException e) {
|
||||||
return null;
|
return null;
|
||||||
@ -45,6 +46,7 @@ public class ICUCurrencyDisplayInfoProvider implements CurrencyDisplayInfoProvid
|
|||||||
return new ICUCurrencyDisplayInfo(rb, withFallback);
|
return new ICUCurrencyDisplayInfo(rb, withFallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean hasData() {
|
public boolean hasData() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -333,7 +333,7 @@ public class IBMCalendarTest extends CalendarTestFmwk {
|
|||||||
errln("FAIL: Buddhist calendar is not returned for locale " + cal.toString());
|
errln("FAIL: Buddhist calendar is not returned for locale " + cal.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify that TaiwanCalendar shifts years to Minguo Era but otherwise
|
* Verify that TaiwanCalendar shifts years to Minguo Era but otherwise
|
||||||
* behaves like GregorianCalendar.
|
* behaves like GregorianCalendar.
|
||||||
@ -954,6 +954,7 @@ public class IBMCalendarTest extends CalendarTestFmwk {
|
|||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -4558903444622684759L;
|
private static final long serialVersionUID = -4558903444622684759L;
|
||||||
|
|
||||||
|
@Override
|
||||||
protected int handleGetLimit(int field, int limitType) {
|
protected int handleGetLimit(int field, int limitType) {
|
||||||
if (limitType == Calendar.LEAST_MAXIMUM) {
|
if (limitType == Calendar.LEAST_MAXIMUM) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -962,6 +963,7 @@ public class IBMCalendarTest extends CalendarTestFmwk {
|
|||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
protected int handleComputeMonthStart(int eyear, int month, boolean useMonth) {
|
protected int handleComputeMonthStart(int eyear, int month, boolean useMonth) {
|
||||||
if (useMonth) {
|
if (useMonth) {
|
||||||
return eyear * 365 + month * 31;
|
return eyear * 365 + month * 31;
|
||||||
@ -969,6 +971,7 @@ public class IBMCalendarTest extends CalendarTestFmwk {
|
|||||||
return eyear * 365;
|
return eyear * 365;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
protected int handleGetExtendedYear() {return 2017;}
|
protected int handleGetExtendedYear() {return 2017;}
|
||||||
|
|
||||||
public void run(){
|
public void run(){
|
||||||
@ -990,18 +993,18 @@ public class IBMCalendarTest extends CalendarTestFmwk {
|
|||||||
// Tests for complete coverage of Calendar functions.
|
// Tests for complete coverage of Calendar functions.
|
||||||
int julianDay = Calendar.millisToJulianDay(millis - 1);
|
int julianDay = Calendar.millisToJulianDay(millis - 1);
|
||||||
assertEquals("Julian max day -1", julianDay, Calendar.MAX_JULIAN - 1);
|
assertEquals("Julian max day -1", julianDay, Calendar.MAX_JULIAN - 1);
|
||||||
|
|
||||||
DateFormat df1 = handleGetDateFormat("GG yyyy-d:MM", "option=xyz", Locale.getDefault());
|
DateFormat df1 = handleGetDateFormat("GG yyyy-d:MM", "option=xyz", Locale.getDefault());
|
||||||
if (!df1.equals(handleGetDateFormat("GG yyyy-d:MM", "option=xyz", ULocale.getDefault()))){
|
if (!df1.equals(handleGetDateFormat("GG yyyy-d:MM", "option=xyz", ULocale.getDefault()))){
|
||||||
errln ("Calendar.handleGetDateFormat(String, Locale) should delegate to ( ,ULocale)");
|
errln ("Calendar.handleGetDateFormat(String, Locale) should delegate to ( ,ULocale)");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prove that the local overrides are used.
|
// Prove that the local overrides are used.
|
||||||
int leastMsInDay = handleGetLimit(Calendar.MILLISECONDS_IN_DAY, Calendar.LEAST_MAXIMUM);
|
int leastMsInDay = handleGetLimit(Calendar.MILLISECONDS_IN_DAY, Calendar.LEAST_MAXIMUM);
|
||||||
assertEquals("getLimit test 1", leastMsInDay, 1);
|
assertEquals("getLimit test 1", leastMsInDay, 1);
|
||||||
int maxMsInDay = handleGetLimit(Calendar.WEEK_OF_MONTH, Calendar.GREATEST_MINIMUM);
|
int maxMsInDay = handleGetLimit(Calendar.WEEK_OF_MONTH, Calendar.GREATEST_MINIMUM);
|
||||||
assertEquals("getLimit test 2", 7, maxMsInDay);
|
assertEquals("getLimit test 2", 7, maxMsInDay);
|
||||||
|
|
||||||
int febLeapLength = handleGetMonthLength(2020, Calendar.FEBRUARY);
|
int febLeapLength = handleGetMonthLength(2020, Calendar.FEBRUARY);
|
||||||
assertEquals("handleMonthLength", 31, febLeapLength);
|
assertEquals("handleMonthLength", 31, febLeapLength);
|
||||||
int exYear = handleGetExtendedYear();
|
int exYear = handleGetExtendedYear();
|
||||||
@ -1029,14 +1032,14 @@ public class IBMCalendarTest extends CalendarTestFmwk {
|
|||||||
ULocale loc = new ULocale("en_US");
|
ULocale loc = new ULocale("en_US");
|
||||||
|
|
||||||
// !!! Shouldn't we have an api like this?
|
// !!! Shouldn't we have an api like this?
|
||||||
// !!! Question: should this reflect those actually available in this copy of ICU, or
|
// !!! Question: should this reflect those actually available in this copy of ICU, or
|
||||||
// the list of types we assume is available?
|
// the list of types we assume is available?
|
||||||
// String[] calTypes = Calendar.getAvailableTypes();
|
// String[] calTypes = Calendar.getAvailableTypes();
|
||||||
final String[] calTypes = {
|
final String[] calTypes = {
|
||||||
"buddhist", "chinese", "coptic", "ethiopic", "gregorian", "hebrew",
|
"buddhist", "chinese", "coptic", "ethiopic", "gregorian", "hebrew",
|
||||||
"islamic", "islamic-civil", "japanese", "roc"
|
"islamic", "islamic-civil", "japanese", "roc"
|
||||||
};
|
};
|
||||||
|
|
||||||
// constructing a DateFormat with a locale indicating a calendar type should construct a
|
// constructing a DateFormat with a locale indicating a calendar type should construct a
|
||||||
// date format appropriate to that calendar
|
// date format appropriate to that calendar
|
||||||
final Date time = new Date();
|
final Date time = new Date();
|
||||||
@ -1059,14 +1062,14 @@ public class IBMCalendarTest extends CalendarTestFmwk {
|
|||||||
|
|
||||||
// dateFormat.setCalendar should throw exception if wrong format for calendar
|
// dateFormat.setCalendar should throw exception if wrong format for calendar
|
||||||
if (false) {
|
if (false) {
|
||||||
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL,
|
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL,
|
||||||
DateFormat.FULL,
|
DateFormat.FULL,
|
||||||
new ULocale("en_US@calendar=chinese"));
|
new ULocale("en_US@calendar=chinese"));
|
||||||
|
|
||||||
logln("dateformat type: " + df.getClass().getName());
|
logln("dateformat type: " + df.getClass().getName());
|
||||||
|
|
||||||
Calendar cal = Calendar.getInstance(new ULocale("en_US@calendar=chinese"));
|
Calendar cal = Calendar.getInstance(new ULocale("en_US@calendar=chinese"));
|
||||||
|
|
||||||
logln("calendar type: " + cal.getClass().getName());
|
logln("calendar type: " + cal.getClass().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1199,10 +1202,12 @@ public class IBMCalendarTest extends CalendarTestFmwk {
|
|||||||
cal.set(Calendar.MILLISECOND, ms);
|
cal.set(Calendar.MILLISECOND, ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("%04d-%02d-%02d %02d:%02d:%02d.%03d", year, month, day, hour, min, sec, ms);
|
return String.format("%04d-%02d-%02d %02d:%02d:%02d.%03d", year, month, day, hour, min, sec, ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
if (other instanceof CalFields) {
|
if (other instanceof CalFields) {
|
||||||
CalFields otr = (CalFields)other;
|
CalFields otr = (CalFields)other;
|
||||||
@ -1216,7 +1221,7 @@ public class IBMCalendarTest extends CalendarTestFmwk {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isEquivalentTo(Calendar cal) {
|
boolean isEquivalentTo(Calendar cal) {
|
||||||
return year == cal.get(Calendar.YEAR)
|
return year == cal.get(Calendar.YEAR)
|
||||||
&& month == cal.get(Calendar.MONTH) + 1
|
&& month == cal.get(Calendar.MONTH) + 1
|
||||||
@ -1602,7 +1607,7 @@ public class IBMCalendarTest extends CalendarTestFmwk {
|
|||||||
String calType = ucalTest.getType();
|
String calType = ucalTest.getType();
|
||||||
boolean era0YearsGoBackwards = (calType.equals("gregorian") || calType.equals("roc") || calType.equals("coptic"));
|
boolean era0YearsGoBackwards = (calType.equals("gregorian") || calType.equals("roc") || calType.equals("coptic"));
|
||||||
int yrBefore, yrAfter, yrMax, eraAfter, eraMax, eraNow;
|
int yrBefore, yrAfter, yrMax, eraAfter, eraMax, eraNow;
|
||||||
|
|
||||||
ucalTest.clear();
|
ucalTest.clear();
|
||||||
ucalTest.set(Calendar.YEAR, 2);
|
ucalTest.set(Calendar.YEAR, 2);
|
||||||
ucalTest.set(Calendar.ERA, 0);
|
ucalTest.set(Calendar.ERA, 0);
|
||||||
@ -1670,7 +1675,7 @@ public class IBMCalendarTest extends CalendarTestFmwk {
|
|||||||
if ( yrAfter<yrBefore ) {
|
if ( yrAfter<yrBefore ) {
|
||||||
errln("Fail: era 1 add 1 year does not move forward in time for " + localeID);
|
errln("Fail: era 1 add 1 year does not move forward in time for " + localeID);
|
||||||
}
|
}
|
||||||
|
|
||||||
ucalTest.clear();
|
ucalTest.clear();
|
||||||
ucalTest.set(Calendar.YEAR, 2);
|
ucalTest.set(Calendar.YEAR, 2);
|
||||||
ucalTest.set(Calendar.ERA, 1);
|
ucalTest.set(Calendar.ERA, 1);
|
||||||
@ -1707,7 +1712,7 @@ public class IBMCalendarTest extends CalendarTestFmwk {
|
|||||||
+ localeID + " (get era " + eraAfter + " year " + yrAfter + ")");
|
+ localeID + " (get era " + eraAfter + " year " + yrAfter + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if current era > 1, try the same roll tests for current era
|
// if current era > 1, try the same roll tests for current era
|
||||||
ucalTest.setTime(new Date());
|
ucalTest.setTime(new Date());
|
||||||
eraNow = ucalTest.get(Calendar.ERA);
|
eraNow = ucalTest.get(Calendar.ERA);
|
||||||
@ -1957,14 +1962,16 @@ public class IBMCalendarTest extends CalendarTestFmwk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TestSimpleDateFormatCoverage() {
|
public void TestSimpleDateFormatCoverage() {
|
||||||
|
|
||||||
class StubSimpleDateFormat extends SimpleDateFormat {
|
class StubSimpleDateFormat extends SimpleDateFormat {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public StubSimpleDateFormat(String pattern, Locale loc) {
|
public StubSimpleDateFormat(String pattern, Locale loc) {
|
||||||
new SimpleDateFormat(pattern, loc);
|
new SimpleDateFormat(pattern, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(){
|
public void run(){
|
||||||
Calendar cal = Calendar.getInstance(Locale.US);
|
Calendar cal = Calendar.getInstance(Locale.US);
|
||||||
cal.clear();
|
cal.clear();
|
||||||
@ -1973,17 +1980,17 @@ public class IBMCalendarTest extends CalendarTestFmwk {
|
|||||||
DateFormatSymbols theseSymbols = this.getSymbols();
|
DateFormatSymbols theseSymbols = this.getSymbols();
|
||||||
String shouldBeMonday = theseSymbols.getWeekdays()[Calendar.MONDAY];
|
String shouldBeMonday = theseSymbols.getWeekdays()[Calendar.MONDAY];
|
||||||
assertEquals("Should be Monday", "Monday", shouldBeMonday);
|
assertEquals("Should be Monday", "Monday", shouldBeMonday);
|
||||||
|
|
||||||
String [] matchData = {"16", "2016", "2016AD", "Monday", "lunes"};
|
String [] matchData = {"16", "2016", "2016AD", "Monday", "lunes"};
|
||||||
int matchIndex = matchString("Monday March 28, 2016", 0, Calendar.DAY_OF_WEEK, matchData, cal);
|
int matchIndex = matchString("Monday March 28, 2016", 0, Calendar.DAY_OF_WEEK, matchData, cal);
|
||||||
assertEquals("matchData for Monday", 6, matchIndex); // Position of the pointer after the matched string.
|
assertEquals("matchData for Monday", 6, matchIndex); // Position of the pointer after the matched string.
|
||||||
matchIndex = matchString("Monday March 28, 2016 AD", 17, Calendar.YEAR, matchData, cal);
|
matchIndex = matchString("Monday March 28, 2016 AD", 17, Calendar.YEAR, matchData, cal);
|
||||||
assertEquals("matchData for 2016", 21, matchIndex); // Position of the pointer after the matched string.
|
assertEquals("matchData for 2016", 21, matchIndex); // Position of the pointer after the matched string.
|
||||||
|
|
||||||
char ch = 'y';
|
char ch = 'y';
|
||||||
int count = 4;
|
int count = 4;
|
||||||
int beginOffset = 0;
|
int beginOffset = 0;
|
||||||
cal.set(Calendar.YEAR, 2000); // Reset this
|
cal.set(Calendar.YEAR, 2000); // Reset this
|
||||||
assertEquals("calendar year reset", 2000, cal.get(Calendar.YEAR));
|
assertEquals("calendar year reset", 2000, cal.get(Calendar.YEAR));
|
||||||
FieldPosition pos = new FieldPosition(java.text.DateFormat.YEAR_FIELD);
|
FieldPosition pos = new FieldPosition(java.text.DateFormat.YEAR_FIELD);
|
||||||
String subFormatResult = subFormat(ch, count, beginOffset,
|
String subFormatResult = subFormat(ch, count, beginOffset,
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Port From: ICU4C v1.8.1 : format : IntlTestDecimalFormatAPI
|
* Port From: ICU4C v1.8.1 : format : IntlTestDecimalFormatAPI
|
||||||
* Source File: $ICU4CRoot/source/test/intltest/dcfmapts.cpp
|
* Source File: $ICU4CRoot/source/test/intltest/dcfmapts.cpp
|
||||||
**/
|
**/
|
||||||
@ -35,7 +35,7 @@ import com.ibm.icu.util.ULocale;
|
|||||||
// try to test the full functionality. It just calls each function in the class and
|
// try to test the full functionality. It just calls each function in the class and
|
||||||
// verifies that it works on a basic level.
|
// verifies that it works on a basic level.
|
||||||
public class IntlTestDecimalFormatAPIC extends com.ibm.icu.dev.test.TestFmwk {
|
public class IntlTestDecimalFormatAPIC extends com.ibm.icu.dev.test.TestFmwk {
|
||||||
|
|
||||||
// This test checks various generic API methods in DecimalFormat to achieve 100% API coverage.
|
// This test checks various generic API methods in DecimalFormat to achieve 100% API coverage.
|
||||||
@Test
|
@Test
|
||||||
public void TestAPI() {
|
public void TestAPI() {
|
||||||
@ -53,7 +53,7 @@ public class IntlTestDecimalFormatAPIC extends com.ibm.icu.dev.test.TestFmwk {
|
|||||||
final String pattern = new String("#,##0.# FF");
|
final String pattern = new String("#,##0.# FF");
|
||||||
final DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.FRENCH);
|
final DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.FRENCH);
|
||||||
final CurrencyPluralInfo infoInput = new CurrencyPluralInfo(ULocale.FRENCH);
|
final CurrencyPluralInfo infoInput = new CurrencyPluralInfo(ULocale.FRENCH);
|
||||||
|
|
||||||
DecimalFormat pat = null;
|
DecimalFormat pat = null;
|
||||||
try {
|
try {
|
||||||
pat = new DecimalFormat(pattern);
|
pat = new DecimalFormat(pattern);
|
||||||
@ -67,7 +67,8 @@ public class IntlTestDecimalFormatAPIC extends com.ibm.icu.dev.test.TestFmwk {
|
|||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
errln("ERROR: Could not create DecimalFormat (pattern, symbols)");
|
errln("ERROR: Could not create DecimalFormat (pattern, symbols)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
DecimalFormat cust2 = null;
|
DecimalFormat cust2 = null;
|
||||||
try {
|
try {
|
||||||
cust2 = new DecimalFormat(pattern, symbols, infoInput, NumberFormat.PLURALCURRENCYSTYLE);
|
cust2 = new DecimalFormat(pattern, symbols, infoInput, NumberFormat.PLURALCURRENCYSTYLE);
|
||||||
@ -127,7 +128,7 @@ public class IntlTestDecimalFormatAPIC extends com.ibm.icu.dev.test.TestFmwk {
|
|||||||
double d2 = pat.parse(text, pos).doubleValue();
|
double d2 = pat.parse(text, pos).doubleValue();
|
||||||
if (d2 != d) {
|
if (d2 != d) {
|
||||||
errln(
|
errln(
|
||||||
"ERROR: Roundtrip failed (via parse(" + Double.toString(d2) + " != " + Double.toString(d) + ")) for " + text);
|
"ERROR: Roundtrip failed (via parse(" + Double.toString(d2) + " != " + Double.toString(d) + ")) for " + text);
|
||||||
}
|
}
|
||||||
logln(text + " parsed into " + (long) d2);
|
logln(text + " parsed into " + (long) d2);
|
||||||
|
|
||||||
@ -192,7 +193,7 @@ public class IntlTestDecimalFormatAPIC extends com.ibm.icu.dev.test.TestFmwk {
|
|||||||
pat.setDecimalSeparatorAlwaysShown(true);
|
pat.setDecimalSeparatorAlwaysShown(true);
|
||||||
boolean tf = pat.isDecimalSeparatorAlwaysShown();
|
boolean tf = pat.isDecimalSeparatorAlwaysShown();
|
||||||
logln(
|
logln(
|
||||||
"DecimalSeparatorIsAlwaysShown (should be true) is " + (tf ? "true" : "false"));
|
"DecimalSeparatorIsAlwaysShown (should be true) is " + (tf ? "true" : "false"));
|
||||||
if (tf != true) {
|
if (tf != true) {
|
||||||
errln("ERROR: setDecimalSeparatorAlwaysShown() failed");
|
errln("ERROR: setDecimalSeparatorAlwaysShown() failed");
|
||||||
}
|
}
|
||||||
@ -204,13 +205,13 @@ public class IntlTestDecimalFormatAPIC extends com.ibm.icu.dev.test.TestFmwk {
|
|||||||
String locPat;
|
String locPat;
|
||||||
locPat = pat.toLocalizedPattern();
|
locPat = pat.toLocalizedPattern();
|
||||||
logln("Localized pattern is " + locPat);
|
logln("Localized pattern is " + locPat);
|
||||||
|
|
||||||
pat.setCurrencyPluralInfo(infoInput);
|
pat.setCurrencyPluralInfo(infoInput);
|
||||||
if(!infoInput.equals(pat.getCurrencyPluralInfo())) {
|
if(!infoInput.equals(pat.getCurrencyPluralInfo())) {
|
||||||
errln("ERROR: set/get CurrencyPluralInfo() failed");
|
errln("ERROR: set/get CurrencyPluralInfo() failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pat.setCurrencyPluralInfo(infoInput);
|
pat.setCurrencyPluralInfo(infoInput);
|
||||||
if(!infoInput.equals(pat.getCurrencyPluralInfo())) {
|
if(!infoInput.equals(pat.getCurrencyPluralInfo())) {
|
||||||
errln("ERROR: set/get CurrencyPluralInfo() failed");
|
errln("ERROR: set/get CurrencyPluralInfo() failed");
|
||||||
@ -254,7 +255,7 @@ public class IntlTestDecimalFormatAPIC extends com.ibm.icu.dev.test.TestFmwk {
|
|||||||
// catch (Exception e) {
|
// catch (Exception e) {
|
||||||
// errln("ERROR: Couldn't create a DecimalFormat");
|
// errln("ERROR: Couldn't create a DecimalFormat");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -263,13 +264,13 @@ public class IntlTestDecimalFormatAPIC extends com.ibm.icu.dev.test.TestFmwk {
|
|||||||
double Roundingnumber1 = -2.55;
|
double Roundingnumber1 = -2.55;
|
||||||
//+2.55 results -2.55 results
|
//+2.55 results -2.55 results
|
||||||
double result[] = {
|
double result[] = {
|
||||||
3, -3,
|
3, -3,
|
||||||
2, -2,
|
2, -2,
|
||||||
3, -2,
|
3, -2,
|
||||||
2, -3,
|
2, -3,
|
||||||
3, -3,
|
3, -3,
|
||||||
3, -3,
|
3, -3,
|
||||||
3, -3
|
3, -3
|
||||||
};
|
};
|
||||||
DecimalFormat pat = new DecimalFormat();
|
DecimalFormat pat = new DecimalFormat();
|
||||||
String s = "";
|
String s = "";
|
||||||
@ -283,22 +284,22 @@ public class IntlTestDecimalFormatAPIC extends com.ibm.icu.dev.test.TestFmwk {
|
|||||||
pat.setRoundingMode(mode);
|
pat.setRoundingMode(mode);
|
||||||
if (pat.getRoundingMode() != mode) {
|
if (pat.getRoundingMode() != mode) {
|
||||||
errln(
|
errln(
|
||||||
"SetRoundingMode or GetRoundingMode failed for mode=" + mode);
|
"SetRoundingMode or GetRoundingMode failed for mode=" + mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
//for +2.55 with RoundingIncrement=1.0
|
//for +2.55 with RoundingIncrement=1.0
|
||||||
pat.setRoundingIncrement(1.0);
|
pat.setRoundingIncrement(1.0);
|
||||||
resultStr = pat.format(Roundingnumber);
|
resultStr = pat.format(Roundingnumber);
|
||||||
message = "round(" + (double) Roundingnumber
|
message = "round(" + Roundingnumber
|
||||||
+ "," + mode + ",FALSE) with RoundingIncrement=1.0==>";
|
+ "," + mode + ",FALSE) with RoundingIncrement=1.0==>";
|
||||||
verify(message, resultStr, result[i++]);
|
verify(message, resultStr, result[i++]);
|
||||||
message = "";
|
message = "";
|
||||||
resultStr = "";
|
resultStr = "";
|
||||||
|
|
||||||
//for -2.55 with RoundingIncrement=1.0
|
//for -2.55 with RoundingIncrement=1.0
|
||||||
resultStr = pat.format(Roundingnumber1);
|
resultStr = pat.format(Roundingnumber1);
|
||||||
message = "round(" + (double) Roundingnumber1
|
message = "round(" + Roundingnumber1
|
||||||
+ "," + mode + ",FALSE) with RoundingIncrement=1.0==>";
|
+ "," + mode + ",FALSE) with RoundingIncrement=1.0==>";
|
||||||
verify(message, resultStr, result[i++]);
|
verify(message, resultStr, result[i++]);
|
||||||
message = "";
|
message = "";
|
||||||
resultStr = "";
|
resultStr = "";
|
||||||
@ -359,7 +360,7 @@ public class IntlTestDecimalFormatAPIC extends com.ibm.icu.dev.test.TestFmwk {
|
|||||||
v.add(new FieldContainer(4, 6, NumberFormat.Field.FRACTION));
|
v.add(new FieldContainer(4, 6, NumberFormat.Field.FRACTION));
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
// private static Vector getPositiveCurrencyVectorTR() {
|
// private static Vector getPositiveCurrencyVectorTR() {
|
||||||
// Vector v = new Vector();
|
// Vector v = new Vector();
|
||||||
// v.add(new FieldContainer(0, 3, NumberFormat.Field.INTEGER));
|
// v.add(new FieldContainer(0, 3, NumberFormat.Field.INTEGER));
|
||||||
@ -449,8 +450,8 @@ public class IntlTestDecimalFormatAPIC extends com.ibm.icu.dev.test.TestFmwk {
|
|||||||
List<FieldContainer> v = new ArrayList<FieldContainer>(1);
|
List<FieldContainer> v = new ArrayList<FieldContainer>(1);
|
||||||
v.add(new FieldContainer(0, 1, NumberFormat.Field.INTEGER));
|
v.add(new FieldContainer(0, 1, NumberFormat.Field.INTEGER));
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void t_Format(int count, Object object, Format format,
|
private void t_Format(int count, Object object, Format format,
|
||||||
List<FieldContainer> expectedResults) {
|
List<FieldContainer> expectedResults) {
|
||||||
List<FieldContainer> results = findFields(format.formatToCharacterIterator(object));
|
List<FieldContainer> results = findFields(format.formatToCharacterIterator(object));
|
||||||
@ -465,11 +466,11 @@ public class IntlTestDecimalFormatAPIC extends com.ibm.icu.dev.test.TestFmwk {
|
|||||||
private static boolean compare(List vector1, List vector2) {
|
private static boolean compare(List vector1, List vector2) {
|
||||||
return vector1.size() == vector2.size() && vector1.containsAll(vector2);
|
return vector1.size() == vector2.size() && vector1.containsAll(vector2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* finds attributes with regards to char index in this
|
* finds attributes with regards to char index in this
|
||||||
* AttributedCharacterIterator, and puts them in a vector
|
* AttributedCharacterIterator, and puts them in a vector
|
||||||
*
|
*
|
||||||
* @param iterator
|
* @param iterator
|
||||||
* @return a vector, each entry in this vector are of type FieldContainer ,
|
* @return a vector, each entry in this vector are of type FieldContainer ,
|
||||||
* which stores start and end indexes and an attribute this range
|
* which stores start and end indexes and an attribute this range
|
||||||
@ -523,6 +524,7 @@ public class IntlTestDecimalFormatAPIC extends com.ibm.icu.dev.test.TestFmwk {
|
|||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (!(obj instanceof FieldContainer))
|
if (!(obj instanceof FieldContainer))
|
||||||
return false;
|
return false;
|
||||||
@ -531,7 +533,7 @@ public class IntlTestDecimalFormatAPIC extends com.ibm.icu.dev.test.TestFmwk {
|
|||||||
return (start == fc.start && end == fc.end
|
return (start == fc.start && end == fc.end
|
||||||
&& attribute == fc.attribute && value.equals(fc.value));
|
&& attribute == fc.attribute && value.equals(fc.value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Helper functions */
|
/*Helper functions */
|
||||||
public void verify(String message, String got, double expected) {
|
public void verify(String message, String got, double expected) {
|
||||||
|
Loading…
Reference in New Issue
Block a user