use of android.icu.text.PluralFormat in project j2objc by google.
the class PluralFormatUnitTest method TestDecimals.
@Test
public void TestDecimals() {
// Simple number replacement.
PluralFormat pf = new PluralFormat(ULocale.ENGLISH, "one{one meter}other{# meters}");
assertEquals("simple format(1)", "one meter", pf.format(1));
assertEquals("simple format(1.5)", "1.5 meters", pf.format(1.5));
PluralFormat pf2 = new PluralFormat(ULocale.ENGLISH, "offset:1 one{another meter}other{another # meters}");
pf2.setNumberFormat(new DecimalFormat("0.0", new DecimalFormatSymbols(ULocale.ENGLISH)));
assertEquals("offset-decimals format(1)", "another 0.0 meters", pf2.format(1));
assertEquals("offset-decimals format(2)", "another 1.0 meters", pf2.format(2));
assertEquals("offset-decimals format(2.5)", "another 1.5 meters", pf2.format(2.5));
}
Aggregations