use of android.icu.text.MeasureFormat in project j2objc by google.
the class MeasureUnitTest method testFormatSingleArg.
@Test
public void testFormatSingleArg() {
MeasureFormat mf = MeasureFormat.getInstance(ULocale.ENGLISH, FormatWidth.WIDE);
assertEquals("", "5 meters", mf.format(new Measure(5, MeasureUnit.METER)));
}
use of android.icu.text.MeasureFormat in project j2objc by google.
the class MeasureUnitTest method testFormatMeasuresOneArg.
@Test
public void testFormatMeasuresOneArg() {
MeasureFormat mf = MeasureFormat.getInstance(ULocale.ENGLISH, FormatWidth.WIDE);
assertEquals("", "5 meters", mf.formatMeasures(new Measure(5, MeasureUnit.METER)));
}
use of android.icu.text.MeasureFormat in project j2objc by google.
the class MeasureUnitTest method testManyLocaleDurations.
@Test
public void testManyLocaleDurations() {
Measure hours = new Measure(5, MeasureUnit.HOUR);
Measure minutes = new Measure(37, MeasureUnit.MINUTE);
ULocale ulocDanish = new ULocale("da");
ULocale ulocSpanish = new ULocale("es");
ULocale ulocFinnish = new ULocale("fi");
ULocale ulocIcelandic = new ULocale("is");
ULocale ulocNorwegianBok = new ULocale("nb");
ULocale ulocNorwegianNyn = new ULocale("nn");
ULocale ulocDutch = new ULocale("nl");
ULocale ulocSwedish = new ULocale("sv");
Object[][] data = new Object[][] { { ulocDanish, FormatWidth.NARROW, "5 t og 37 min" }, { ulocDanish, FormatWidth.NUMERIC, "5.37" }, { ULocale.GERMAN, FormatWidth.NARROW, "5 Std., 37 Min." }, { ULocale.GERMAN, FormatWidth.NUMERIC, "5:37" }, { ULocale.ENGLISH, FormatWidth.NARROW, "5h 37m" }, { ULocale.ENGLISH, FormatWidth.NUMERIC, "5:37" }, { ulocSpanish, FormatWidth.NARROW, "5h 37min" }, { ulocSpanish, FormatWidth.NUMERIC, "5:37" }, { ulocFinnish, FormatWidth.NARROW, "5t 37min" }, { ulocFinnish, FormatWidth.NUMERIC, "5.37" }, { ULocale.FRENCH, FormatWidth.NARROW, "5h 37m" }, { ULocale.FRENCH, FormatWidth.NUMERIC, "05:37" }, { ulocIcelandic, FormatWidth.NARROW, "5 klst. og 37 m\u00EDn." }, { ulocIcelandic, FormatWidth.NUMERIC, "5:37" }, { ULocale.JAPANESE, FormatWidth.NARROW, "5h37m" }, { ULocale.JAPANESE, FormatWidth.NUMERIC, "5:37" }, { ulocNorwegianBok, FormatWidth.NARROW, "5t, 37m" }, { ulocNorwegianBok, FormatWidth.NUMERIC, "5:37" }, { ulocDutch, FormatWidth.NARROW, "5 u, 37 m" }, { ulocDutch, FormatWidth.NUMERIC, "5:37" }, { ulocNorwegianNyn, FormatWidth.NARROW, "5 h og 37 min" }, { ulocNorwegianNyn, FormatWidth.NUMERIC, "5:37" }, { ulocSwedish, FormatWidth.NARROW, "5h 37m" }, { ulocSwedish, FormatWidth.NUMERIC, "5:37" }, { ULocale.CHINESE, FormatWidth.NARROW, "5\u5C0F\u65F637\u5206\u949F" }, { ULocale.CHINESE, FormatWidth.NUMERIC, "5:37" } };
for (Object[] row : data) {
MeasureFormat mf = null;
try {
mf = MeasureFormat.getInstance((ULocale) row[0], (FormatWidth) row[1]);
} catch (Exception e) {
errln("Exception creating MeasureFormat for locale " + row[0] + ", width " + row[1] + ": " + e);
continue;
}
String result = mf.formatMeasures(hours, minutes);
if (!result.equals(row[2])) {
errln("MeasureFormat.formatMeasures for locale " + row[0] + ", width " + row[1] + ", expected \"" + (String) row[2] + "\", got \"" + result + "\"");
}
}
}
use of android.icu.text.MeasureFormat in project j2objc by google.
the class MeasureUnitTest method testFormatMeasuresZeroArg.
@Test
public void testFormatMeasuresZeroArg() {
MeasureFormat mf = MeasureFormat.getInstance(ULocale.ENGLISH, FormatWidth.WIDE);
assertEquals("", "", mf.formatMeasures());
}
use of android.icu.text.MeasureFormat in project j2objc by google.
the class MeasureUnitTest method testGetLocale.
@Test
public void testGetLocale() {
MeasureFormat mf = MeasureFormat.getInstance(ULocale.GERMAN, FormatWidth.SHORT);
assertEquals("", ULocale.GERMAN, mf.getLocale(ULocale.VALID_LOCALE));
}
Aggregations