Search in sources :

Example 46 with UnitConverter

use of javax.measure.UnitConverter in project indriya by unitsofmeasurement.

the class PrefixTest method testMebi.

@Test
public void testMebi() {
    final UnitConverter expected = new RationalConverter(8, 15625);
    final UnitConverter actual = MEBI(METRE).getConverterTo(MEGA(METRE));
    assertEquals(expected, actual);
}
Also used : RationalConverter(tech.units.indriya.function.RationalConverter) UnitConverter(javax.measure.UnitConverter) Test(org.junit.jupiter.api.Test)

Example 47 with UnitConverter

use of javax.measure.UnitConverter in project indriya by unitsofmeasurement.

the class PrefixTest method testTebi.

@Test
public void testTebi() {
    final UnitConverter expected = new RationalConverter(1, 3906250000l);
    final UnitConverter actual = TEBI(LITRE).getConverterTo(TERA(LITRE));
    assertEquals(expected, actual);
}
Also used : RationalConverter(tech.units.indriya.function.RationalConverter) UnitConverter(javax.measure.UnitConverter) Test(org.junit.jupiter.api.Test)

Example 48 with UnitConverter

use of javax.measure.UnitConverter in project indriya by unitsofmeasurement.

the class PrefixTest method testGibi.

@Test
public void testGibi() {
    final UnitConverter expected = new RationalConverter(2, 5859375);
    final UnitConverter actual = GIBI(METRE).getConverterTo(GIGA(METRE));
    assertEquals(expected, actual);
}
Also used : RationalConverter(tech.units.indriya.function.RationalConverter) UnitConverter(javax.measure.UnitConverter) Test(org.junit.jupiter.api.Test)

Example 49 with UnitConverter

use of javax.measure.UnitConverter in project indriya by unitsofmeasurement.

the class PrefixTest method testPebi.

@Test
public void testPebi() {
    final UnitConverter expected = new RationalConverter(1, 4882812500000L);
    final UnitConverter actual = PEBI(LITRE).getConverterTo(PETA(LITRE));
    assertEquals(expected, actual);
}
Also used : RationalConverter(tech.units.indriya.function.RationalConverter) UnitConverter(javax.measure.UnitConverter) Test(org.junit.jupiter.api.Test)

Example 50 with UnitConverter

use of javax.measure.UnitConverter in project uom-se by unitsofmeasurement.

the class PrefixTest method testNestedOperationsShouldBeSame.

@Test
@Ignore("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);
}
Also used : Mass(javax.measure.quantity.Mass) UnitConverter(javax.measure.UnitConverter) List(java.util.List) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

UnitConverter (javax.measure.UnitConverter)54 IncommensurableException (javax.measure.IncommensurableException)18 UnconvertibleException (javax.measure.UnconvertibleException)13 Test (org.junit.jupiter.api.Test)11 Test (org.junit.Test)9 RationalConverter (tech.units.indriya.function.RationalConverter)7 Unit (javax.measure.Unit)5 List (java.util.List)4 Mass (javax.measure.quantity.Mass)4 Date (java.util.Date)3 DateFormat (java.text.DateFormat)2 DecimalFormat (java.text.DecimalFormat)2 Format (java.text.Format)2 NumberFormat (java.text.NumberFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 HashMap (java.util.HashMap)2 Dimension (javax.measure.Dimension)2 CompoundFormat (org.apache.sis.io.CompoundFormat)2 Angle (org.apache.sis.measure.Angle)2 AngleFormat (org.apache.sis.measure.AngleFormat)2