ICU-10640 Add tests to be sure that TimeUnitFormat and CurrencyFormat are stand-ins for MeasureFormat.
X-SVN-Rev: 35037
This commit is contained in:
parent
995b68f085
commit
53e36c62b6
@ -28,6 +28,7 @@ import com.ibm.icu.dev.test.serializable.SerializableTest;
|
||||
import com.ibm.icu.impl.Utility;
|
||||
import com.ibm.icu.math.BigDecimal;
|
||||
import com.ibm.icu.text.MeasureFormat;
|
||||
import com.ibm.icu.text.TimeUnitFormat;
|
||||
import com.ibm.icu.text.MeasureFormat.FormatWidth;
|
||||
import com.ibm.icu.text.NumberFormat;
|
||||
import com.ibm.icu.util.Currency;
|
||||
@ -562,6 +563,19 @@ public class MeasureUnitTest extends TestFmwk {
|
||||
assertEquals("FormatWidth.NUMERIC", 3, FormatWidth.NUMERIC.ordinal());
|
||||
}
|
||||
|
||||
public void testCurrencyFormatStandInForMeasureFormat() {
|
||||
MeasureFormat mf = MeasureFormat.getCurrencyFormat(ULocale.ENGLISH);
|
||||
assertEquals(
|
||||
"70 feet, 5.3 inches",
|
||||
"70 feet, 5.3 inches",
|
||||
mf.formatMeasures(
|
||||
new Measure(70, MeasureUnit.FOOT),
|
||||
new Measure(5.3, MeasureUnit.INCH)));
|
||||
assertEquals("getLocale", ULocale.ENGLISH, mf.getLocale());
|
||||
assertEquals("getNumberFormat", ULocale.ENGLISH, mf.getNumberFormat().getLocale(ULocale.VALID_LOCALE));
|
||||
assertEquals("getWidth", MeasureFormat.FormatWidth.WIDE, mf.getWidth());
|
||||
}
|
||||
|
||||
static void generateCXXHConstants() {
|
||||
Map<String, MeasureUnit> seen = new HashMap<String, MeasureUnit>();
|
||||
TreeMap<String, List<MeasureUnit>> allUnits = new TreeMap<String, List<MeasureUnit>>();
|
||||
|
@ -15,6 +15,8 @@ import com.ibm.icu.math.BigDecimal;
|
||||
import com.ibm.icu.text.MeasureFormat;
|
||||
import com.ibm.icu.text.NumberFormat;
|
||||
import com.ibm.icu.text.TimeUnitFormat;
|
||||
import com.ibm.icu.util.Measure;
|
||||
import com.ibm.icu.util.MeasureUnit;
|
||||
import com.ibm.icu.util.TimeUnit;
|
||||
import com.ibm.icu.util.TimeUnitAmount;
|
||||
import com.ibm.icu.util.ULocale;
|
||||
@ -379,6 +381,22 @@ public class TimeUnitTest extends TestFmwk {
|
||||
tuf1.parseObject("", new ParsePosition(0));
|
||||
}
|
||||
|
||||
public void TestStandInForMeasureFormat() {
|
||||
TimeUnitFormat tuf = new TimeUnitFormat(ULocale.FRENCH, TimeUnitFormat.ABBREVIATED_NAME);
|
||||
Measure measure = new Measure(23, MeasureUnit.CELSIUS);
|
||||
assertEquals("23 °C", "23 °C", tuf.format(measure));
|
||||
tuf = new TimeUnitFormat(ULocale.FRENCH, TimeUnitFormat.FULL_NAME);
|
||||
assertEquals(
|
||||
"70 pied et 5,3 pouces",
|
||||
"70 pieds et 5,3 pouces",
|
||||
tuf.formatMeasures(
|
||||
new Measure(70, MeasureUnit.FOOT),
|
||||
new Measure(5.3, MeasureUnit.INCH)));
|
||||
assertEquals("getLocale", ULocale.FRENCH, tuf.getLocale());
|
||||
assertEquals("getNumberFormat", ULocale.FRENCH, tuf.getNumberFormat().getLocale(ULocale.VALID_LOCALE));
|
||||
assertEquals("getWidth", MeasureFormat.FormatWidth.WIDE, tuf.getWidth());
|
||||
}
|
||||
|
||||
private void verifyEqualsHashCode(Object o, Object eq, Object ne) {
|
||||
assertEquals("verifyEqualsHashCodeSame", o, o);
|
||||
assertEquals("verifyEqualsHashCodeEq", o, eq);
|
||||
|
Loading…
Reference in New Issue
Block a user