ICU-10485 Fix MeasureUnit failing tests.

X-SVN-Rev: 34546
This commit is contained in:
Travis Keep 2013-10-10 20:58:53 +00:00
parent 0d26708552
commit c1fbbc062e
3 changed files with 11 additions and 8 deletions

View File

@ -153,8 +153,10 @@ public class MeasureUnit implements Comparable<MeasureUnit>, Serializable {
String type = unitsRes.getKey(); String type = unitsRes.getKey();
int unitsSize = unitsRes.getSize(); int unitsSize = unitsRes.getSize();
for ( int index2 = 0; index2 < unitsSize; ++index2) { for ( int index2 = 0; index2 < unitsSize; ++index2) {
String unitName = unitsRes.get(index2).getKey(); UResourceBundle unitNameRes = unitsRes.get(index2);
addUnit(type, unitName, UNIT_FACTORY); if (unitNameRes.containsKey("other")) {
addUnit(type, unitNameRes.getKey(), UNIT_FACTORY);
}
} }
} }
} catch ( MissingResourceException e ) { } catch ( MissingResourceException e ) {
@ -307,9 +309,9 @@ public class MeasureUnit implements Comparable<MeasureUnit>, Serializable {
/** Constant for unit of angle: degree */ /** Constant for unit of angle: degree */
DEGREE = MeasureUnit.getInstance("angle", "degree"), DEGREE = MeasureUnit.getInstance("angle", "degree"),
/** Constant for unit of angle: minute */ /** Constant for unit of angle: minute */
ARC_MINUTE = MeasureUnit.getInstance("angle", "minute"), ARC_MINUTE = MeasureUnit.getInstance("angle", "arc-minute"),
/** Constant for unit of angle: second */ /** Constant for unit of angle: second */
ARC_SECOND = MeasureUnit.getInstance("angle", "second"), ARC_SECOND = MeasureUnit.getInstance("angle", "arc-second"),
/** Constant for unit of area: acre */ /** Constant for unit of area: acre */
ACRE = MeasureUnit.getInstance("area", "acre"), ACRE = MeasureUnit.getInstance("area", "acre"),
/** Constant for unit of area: hectare */ /** Constant for unit of area: hectare */

View File

@ -145,10 +145,10 @@ public class MeasureUnitTest extends TestFmwk {
public void testExamples() { public void testExamples() {
GeneralMeasureFormat fmtFr = GeneralMeasureFormat.getInstance(ULocale.FRENCH, FormatWidth.SHORT); GeneralMeasureFormat fmtFr = GeneralMeasureFormat.getInstance(ULocale.FRENCH, FormatWidth.SHORT);
Measure measure = new Measure(23, MeasureUnit.CELSIUS); Measure measure = new Measure(23, MeasureUnit.CELSIUS);
assertEquals("", "23°C", fmtFr.format(measure)); assertEquals("", "23 °C", fmtFr.format(measure));
Measure measureF = new Measure(70, MeasureUnit.FAHRENHEIT); Measure measureF = new Measure(70, MeasureUnit.FAHRENHEIT);
assertEquals("", "70°F", fmtFr.format(measureF)); assertEquals("", "70 °F", fmtFr.format(measureF));
GeneralMeasureFormat fmtFrFull = GeneralMeasureFormat.getInstance(ULocale.FRENCH, FormatWidth.WIDE); GeneralMeasureFormat fmtFrFull = GeneralMeasureFormat.getInstance(ULocale.FRENCH, FormatWidth.WIDE);
if (!logKnownIssue("8474", "needs latest CLDR data")) { if (!logKnownIssue("8474", "needs latest CLDR data")) {
@ -159,7 +159,7 @@ public class MeasureUnitTest extends TestFmwk {
} }
// Degenerate case // Degenerate case
GeneralMeasureFormat fmtEn = GeneralMeasureFormat.getInstance(ULocale.ENGLISH, FormatWidth.WIDE); GeneralMeasureFormat fmtEn = GeneralMeasureFormat.getInstance(ULocale.ENGLISH, FormatWidth.WIDE);
assertEquals("", "1 inch, 2 feet", fmtEn.format(new Measure(1, MeasureUnit.INCH), assertEquals("", "1 inch and 2 feet", fmtEn.format(new Measure(1, MeasureUnit.INCH),
new Measure(2, MeasureUnit.FOOT))); new Measure(2, MeasureUnit.FOOT)));
logln("Show all currently available units"); logln("Show all currently available units");

View File

@ -1,6 +1,6 @@
/* /*
******************************************************************************* *******************************************************************************
* Copyright (c) 2004-2012, International Business Machines * Copyright (c) 2004-2013, International Business Machines
* Corporation and others. All Rights Reserved. * Corporation and others. All Rights Reserved.
* Copyright (C) 2010 , Yahoo! Inc. * Copyright (C) 2010 , Yahoo! Inc.
******************************************************************************* *******************************************************************************
@ -29,6 +29,7 @@ public class TestAll extends TestGroup {
"com.ibm.icu.dev.test.format.BigNumberFormatTest", "com.ibm.icu.dev.test.format.BigNumberFormatTest",
"DataDrivenFormatTest", "DataDrivenFormatTest",
"ListFormatterTest", "ListFormatterTest",
"MeasureUnitTest",
"TestAll$PluralFormat", "TestAll$PluralFormat",
"TestAll$MessageFormat", "TestAll$MessageFormat",
"TestAll$SelectFormat" "TestAll$SelectFormat"