use of javax.measure.UnitConverter in project indriya by unitsofmeasurement.
the class PrefixTest method testKibi.
@Test
public void testKibi() {
final UnitConverter expected = new RationalConverter(128, 125);
final UnitConverter actual = KIBI(METRE).getConverterTo(KILO(METRE));
assertEquals("Ki", KIBI.getSymbol());
assertEquals(expected, actual);
}
use of javax.measure.UnitConverter in project indriya by unitsofmeasurement.
the class PrefixTest method testZebi.
@Test
public void testZebi() {
final UnitConverter expected = new RationalConverter(1, 6835937500000000000L);
final UnitConverter actual = ZEBI(GRAM).getConverterTo(ZETTA(GRAM));
assertEquals(expected, actual);
}
use of javax.measure.UnitConverter in project indriya by unitsofmeasurement.
the class PrefixTest method testYobi.
@Test
public void testYobi() {
final UnitConverter expected = new RationalConverter(BigInteger.ONE, BigDecimal.valueOf(7812500000000000000000D).toBigInteger());
final UnitConverter actual = YOBI(GRAM).getConverterTo(YOTTA(GRAM));
assertEquals(expected, actual);
}
use of javax.measure.UnitConverter in project indriya by unitsofmeasurement.
the class PrefixTest method testNestedOperationsShouldBeSame.
@Test
@Disabled("This is research for https://github.com/unitsofmeasurement/uom-se/issues/164")
public void testNestedOperationsShouldBeSame() {
Unit<Mass> m1 = MICRO(GRAM);
Unit<Mass> m2 = GRAM.divide(1000).divide(1000);
UnitConverter c1 = m1.getConverterTo(m2);
List steps1 = c1.getConversionSteps();
UnitConverter c2 = m2.getConverterTo(m1);
List steps2 = c2.getConversionSteps();
assertEquals(c1, c2);
assertEquals(m1, m2);
}
use of javax.measure.UnitConverter in project indriya by unitsofmeasurement.
the class UnitsTest method testConverterToSI.
/**
* Test method for {@link javax.measure.Unit#toMetric()}.
*/
// @Test
// public void testToMetric() {
// AbstractUnit<? extends QuantityAmount> su = (AbstractUnit<? extends
// QuantityAmount>) one.toMetric();
// assertTrue(su.isUnscaledMetric());
// }
/**
* Test method for {@link javax.measure.Unit#getConverterTo}.
*/
@Test
public void testConverterToSI() {
Double factor = 10.0;
UnitConverter converter = one.getConverterTo(one);
Double result = converter.convert(factor.doubleValue());
assertEquals(result, factor);
logger.log(Level.FINER, result.toString());
}
Aggregations