use of android.icu.text.TimeUnitFormat in project j2objc by google.
the class TimeUnitTest method TestStandInForMeasureFormat.
@Test
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());
}
use of android.icu.text.TimeUnitFormat in project j2objc by google.
the class TimeUnitTest method TestEqHashCode.
@Test
public void TestEqHashCode() {
TimeUnitFormat tf = new TimeUnitFormat(ULocale.ENGLISH, TimeUnitFormat.FULL_NAME);
MeasureFormat tfeq = new TimeUnitFormat(ULocale.ENGLISH, TimeUnitFormat.FULL_NAME);
MeasureFormat tfne = new TimeUnitFormat(ULocale.ENGLISH, TimeUnitFormat.ABBREVIATED_NAME);
MeasureFormat tfne2 = new TimeUnitFormat(ULocale.GERMAN, TimeUnitFormat.FULL_NAME);
verifyEqualsHashCode(tf, tfeq, tfne);
verifyEqualsHashCode(tf, tfeq, tfne2);
}
use of android.icu.text.TimeUnitFormat in project j2objc by google.
the class TimeUnitTest method TestGetLocale.
@Test
public void TestGetLocale() {
TimeUnitFormat tf = new TimeUnitFormat(ULocale.GERMAN);
assertEquals("", ULocale.GERMAN, tf.getLocale(ULocale.VALID_LOCALE));
}
use of android.icu.text.TimeUnitFormat in project j2objc by google.
the class TimeUnitTest method TestSetNumberFormat.
/*
* Tests the method public TimeUnitFormat setNumberFormat(NumberFormat format)
*/
@Test
public void TestSetNumberFormat() {
TimeUnitFormat tuf = new TimeUnitFormat();
// Tests when "if (format == this.format)" is false
// Tests when "if ( format == null )" is false
tuf.setNumberFormat(NumberFormat.getInstance());
// Tests when "if (format == this.format)" is true
if (!tuf.setNumberFormat(NumberFormat.getInstance()).equals(tuf)) {
errln("TimeUnitFormat.setNumberFormat(NumberFormat) was suppose to " + "return the same object when the same NumberFormat is passed.");
}
// Tests when "if ( locale == null )" is true
if (!tuf.setNumberFormat(null).equals(tuf)) {
errln("TimeUnitFormat.setNumberFormat(NumberFormat) was suppose to " + "return the same object when null is passed.");
}
TimeUnitFormat tuf1 = new TimeUnitFormat(new ULocale("en_US"));
// Tests when "if ( locale == null )" is false
tuf1.setNumberFormat(NumberFormat.getInstance());
tuf1.setNumberFormat(null);
}
use of android.icu.text.TimeUnitFormat in project j2objc by google.
the class TimeUnitTest method TestGreekWithSanitization.
/**
* @bug9042
* Performs tests for Greek.
* This tests that if the plural count listed in time unit format does not
* match those in the plural rules for the locale, those plural count in
* time unit format will be ingored and subsequently, fall back will kick in
* which is tested above.
* Without data sanitization, setNumberFormat() would crash.
* As of CLDR shiped in ICU4.8, Greek is one such language.
*/
@Test
public void TestGreekWithSanitization() {
ULocale loc = new ULocale("el");
NumberFormat numfmt = NumberFormat.getInstance(loc);
TimeUnitFormat tuf = new TimeUnitFormat(loc);
tuf.parseObject("", new ParsePosition(0));
tuf.setNumberFormat(numfmt);
}
Aggregations