use of android.icu.text.MeasureFormat.FormatWidth in project j2objc by google.
the class MeasureUnitTest method testDisplayNames.
@Test
public void testDisplayNames() {
Object[][] data = new Object[][] { // Unit, locale, width, expected result
{ MeasureUnit.YEAR, "en", FormatWidth.WIDE, "years" }, { MeasureUnit.YEAR, "ja", FormatWidth.WIDE, "年" }, { MeasureUnit.YEAR, "es", FormatWidth.WIDE, "años" }, { MeasureUnit.YEAR, "pt", FormatWidth.WIDE, "anos" }, { MeasureUnit.YEAR, "pt-PT", FormatWidth.WIDE, "anos" }, { MeasureUnit.AMPERE, "en", FormatWidth.WIDE, "amperes" }, { MeasureUnit.AMPERE, "ja", FormatWidth.WIDE, "アンペア" }, { MeasureUnit.AMPERE, "es", FormatWidth.WIDE, "amperios" }, { MeasureUnit.AMPERE, "pt", FormatWidth.WIDE, "amperes" }, { MeasureUnit.AMPERE, "pt-PT", FormatWidth.WIDE, "amperes" }, { MeasureUnit.METER_PER_SECOND_SQUARED, "pt", FormatWidth.WIDE, "metros por segundo ao quadrado" }, { MeasureUnit.METER_PER_SECOND_SQUARED, "pt-PT", FormatWidth.WIDE, "metros por segundo quadrado" }, { MeasureUnit.SQUARE_KILOMETER, "pt", FormatWidth.NARROW, "km²" }, { MeasureUnit.SQUARE_KILOMETER, "pt", FormatWidth.SHORT, "km²" }, { MeasureUnit.SQUARE_KILOMETER, "pt", FormatWidth.WIDE, "quilômetros quadrados" }, { MeasureUnit.SECOND, "pt-PT", FormatWidth.NARROW, "s" }, { MeasureUnit.SECOND, "pt-PT", FormatWidth.SHORT, "s" }, { MeasureUnit.SECOND, "pt-PT", FormatWidth.WIDE, "segundos" }, { MeasureUnit.SECOND, "pt", FormatWidth.NARROW, "seg" }, { MeasureUnit.SECOND, "pt", FormatWidth.SHORT, "segs" }, { MeasureUnit.SECOND, "pt", FormatWidth.WIDE, "segundos" } };
for (Object[] test : data) {
MeasureUnit unit = (MeasureUnit) test[0];
ULocale locale = ULocale.forLanguageTag((String) test[1]);
FormatWidth formatWidth = (FormatWidth) test[2];
String expected = (String) test[3];
MeasureFormat mf = MeasureFormat.getInstance(locale, formatWidth);
String actual = mf.getUnitDisplayName(unit);
assertEquals(String.format("Unit Display Name for %s, %s, %s", unit, locale, formatWidth), expected, actual);
}
}
Aggregations