use of android.icu.text.MeasureFormat in project j2objc by google.
the class MeasureUnitTest method testOldFormatWithList.
@Test
public void testOldFormatWithList() {
List<Measure> measures = new ArrayList<Measure>(2);
measures.add(new Measure(5, MeasureUnit.ACRE));
measures.add(new Measure(3000, MeasureUnit.SQUARE_FOOT));
MeasureFormat fmt = MeasureFormat.getInstance(ULocale.ENGLISH, FormatWidth.WIDE);
assertEquals("", "5 acres, 3,000 square feet", fmt.format(measures));
assertEquals("", "5 acres", fmt.format(measures.subList(0, 1)));
List<String> badList = new ArrayList<String>();
badList.add("be");
badList.add("you");
try {
fmt.format(badList);
fail("Expected IllegalArgumentException.");
} catch (IllegalArgumentException expected) {
// Expected
}
}
use of android.icu.text.MeasureFormat in project j2objc by google.
the class MeasureUnitTest method testCurrencyFormatLocale.
@Test
public void testCurrencyFormatLocale() {
MeasureFormat mfu = MeasureFormat.getCurrencyFormat(ULocale.FRANCE);
MeasureFormat mfj = MeasureFormat.getCurrencyFormat(Locale.FRANCE);
assertEquals("getCurrencyFormat ULocale/Locale", mfu, mfj);
}
use of android.icu.text.MeasureFormat in project j2objc by google.
the class MeasureUnitTest method testOldFormatWithArray.
@Test
public void testOldFormatWithArray() {
Measure[] measures = new Measure[] { new Measure(5, MeasureUnit.ACRE), new Measure(3000, MeasureUnit.SQUARE_FOOT) };
MeasureFormat fmt = MeasureFormat.getInstance(ULocale.ENGLISH, FormatWidth.WIDE);
assertEquals("", "5 acres, 3,000 square feet", fmt.format(measures));
}
use of android.icu.text.MeasureFormat in project j2objc by google.
the class MeasureUnitTest method testNumeratorPlurals.
@Test
public void testNumeratorPlurals() {
ULocale polish = new ULocale("pl");
Object[][] data = new Object[][] { { 1, "1 stopa na sekundę" }, { 2, "2 stopy na sekundę" }, { 5, "5 stóp na sekundę" }, { 1.5, "1,5 stopy na sekundę" } };
for (Object[] row : data) {
MeasureFormat mf = MeasureFormat.getInstance(polish, FormatWidth.WIDE);
assertEquals("", row[1], mf.formatMeasurePerUnit(new Measure((Number) row[0], MeasureUnit.FOOT), MeasureUnit.SECOND, new StringBuilder(), new FieldPosition(0)).toString());
}
}
use of android.icu.text.MeasureFormat in project j2objc by google.
the class MeasureUnitTest method testOldFormatBadArg.
@Test
public void testOldFormatBadArg() {
MeasureFormat fmt = MeasureFormat.getInstance(ULocale.ENGLISH, FormatWidth.WIDE);
try {
fmt.format("be");
fail("Expected IllegalArgumentExceptino.");
} catch (IllegalArgumentException e) {
// Expected
}
}
Aggregations