use of javax.measure.format.UnitFormat in project indriya by unitsofmeasurement.
the class LocalFormatTest method testFormatKm.
@Test
public void testFormatKm() {
final UnitFormat format = LocalUnitFormat.getInstance();
String s = format.format(KILO(METRE));
assertEquals("km", s);
}
use of javax.measure.format.UnitFormat in project indriya by unitsofmeasurement.
the class UnitFormatTest method testParseLocal.
@Test
public void testParseLocal() {
final UnitFormat format = LocalUnitFormat.getInstance();
assertThrows(UnsupportedOperationException.class, () -> {
try {
Unit<?> u = format.parse("min");
assertEquals("min", u.getSymbol());
} catch (ParserException e) {
fail(e.getMessage());
}
});
}
use of javax.measure.format.UnitFormat in project sis by apache.
the class UnitServicesTest method testGetUnitFormat.
/**
* Tests {@link UnitServices#getUnitFormat(String)}.
*/
@Test
public void testGetUnitFormat() {
final ServiceProvider provider = ServiceProvider.current();
final UnitFormat f = provider.getUnitFormatService().getUnitFormat("name");
((org.apache.sis.measure.UnitFormat) f).setLocale(Locale.US);
assertEquals("CUBIC_METRE", "cubic meter", f.format(Units.CUBIC_METRE));
}
use of javax.measure.format.UnitFormat in project unit-api by unitsofmeasurement.
the class UnitFormatTest method testMoreLocalSensitive.
@Test
public void testMoreLocalSensitive() {
final UnitFormat simple = SimpleTestUnitFormat.getInstance();
assertFalse(simple.isLocaleSensitive());
}
use of javax.measure.format.UnitFormat in project indriya by unitsofmeasurement.
the class LocalFormatTest method testFormatMm.
@Test
public void testFormatMm() {
final UnitFormat format = LocalUnitFormat.getInstance();
String s = format.format(MILLI(METRE));
assertEquals("mm", s);
}
Aggregations