Search in sources :

Example 6 with RationalConverter

use of tech.units.indriya.function.RationalConverter in project indriya by unitsofmeasurement.

the class SimpleFormatTest method testTransformed.

@Test
public void testTransformed() {
    final String ANGSTROEM_SYM = "\u212B";
    final Unit<Length> ANGSTROEM = new TransformedUnit<Length>(ANGSTROEM_SYM, METRE, METRE, new RationalConverter(BigInteger.ONE, BigInteger.TEN.pow(10)));
    final String s = format.format(ANGSTROEM);
    assertEquals(ANGSTROEM_SYM, s);
}
Also used : Length(javax.measure.quantity.Length) RationalConverter(tech.units.indriya.function.RationalConverter) TransformedUnit(tech.units.indriya.unit.TransformedUnit) Test(org.junit.jupiter.api.Test)

Example 7 with RationalConverter

use of tech.units.indriya.function.RationalConverter 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 8 with RationalConverter

use of tech.units.indriya.function.RationalConverter 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 9 with RationalConverter

use of tech.units.indriya.function.RationalConverter 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 10 with RationalConverter

use of tech.units.indriya.function.RationalConverter 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)

Aggregations

RationalConverter (tech.units.indriya.function.RationalConverter)10 Test (org.junit.jupiter.api.Test)9 UnitConverter (javax.measure.UnitConverter)7 Length (javax.measure.quantity.Length)2 TransformedUnit (tech.units.indriya.unit.TransformedUnit)2 AddConverter (tech.units.indriya.function.AddConverter)1 MultiplyConverter (tech.units.indriya.function.MultiplyConverter)1 MetricPrefix (tech.units.indriya.unit.MetricPrefix)1