use of tech.units.indriya.quantity.time.TemporalQuantity in project indriya by unitsofmeasurement.
the class TimeQuantitiesTest method convertTest.
@Test
public void convertTest() {
TemporalQuantity day = TemporalQuantity.of(1, DAYS);
TemporalQuantity hours = day.to(HOURS);
assertEquals(HOURS, hours.getTemporalUnit());
assertEquals(Integer.valueOf(24), hours.getValue());
TemporalQuantity oneDay = hours.to(DAYS);
assertEquals(DAYS, oneDay.getTemporalUnit());
assertEquals(Integer.valueOf(1), oneDay.getValue());
}
use of tech.units.indriya.quantity.time.TemporalQuantity in project indriya by unitsofmeasurement.
the class TimeQuantitiesTest method toUnitTest.
@Test
public void toUnitTest() {
TemporalQuantity day = TemporalQuantity.of(1, DAYS);
TemporalQuantity hour = TemporalQuantity.of(1, HOURS);
TemporalQuantity minute = TemporalQuantity.of(1, MINUTES);
TemporalQuantity second = TemporalQuantity.of(1, SECONDS);
TemporalQuantity microSecond = TemporalQuantity.of(1, MICROS);
TemporalQuantity milliSecond = TemporalQuantity.of(1, MILLIS);
TemporalQuantity nanoSecond = TemporalQuantity.of(1, NANOS);
assertEquals(DAY, day.toUnit());
assertEquals(HOUR, hour.toUnit());
assertEquals(MINUTE, minute.toUnit());
assertEquals(SECOND, second.toUnit());
assertEquals(TimeQuantities.MICROSECOND, microSecond.toUnit());
assertEquals(TimeQuantities.MILLISECOND, milliSecond.toUnit());
assertEquals(TimeQuantities.NANOSECOND, nanoSecond.toUnit());
}
use of tech.units.indriya.quantity.time.TemporalQuantity in project indriya by unitsofmeasurement.
the class TimeQuantitiesTest method toQuantityTest.
@Test
public void toQuantityTest() {
TemporalQuantity day = TemporalQuantity.of(1, DAYS);
TemporalQuantity hour = TemporalQuantity.of(1, HOURS);
TemporalQuantity minute = TemporalQuantity.of(1, MINUTES);
TemporalQuantity second = TemporalQuantity.of(1, SECONDS);
TemporalQuantity microSecond = TemporalQuantity.of(1, MICROS);
TemporalQuantity milliSecond = TemporalQuantity.of(1, MILLIS);
TemporalQuantity nanoSecond = TemporalQuantity.of(1, NANOS);
verifyQuantity(day.toQuantity(), DAY, 1);
verifyQuantity(hour.toQuantity(), HOUR, 1);
verifyQuantity(minute.toQuantity(), MINUTE, 1);
verifyQuantity(second.toQuantity(), SECOND, 1);
verifyQuantity(microSecond.toQuantity(), TimeQuantities.MICROSECOND, 1);
verifyQuantity(milliSecond.toQuantity(), TimeQuantities.MILLISECOND, 1);
verifyQuantity(nanoSecond.toQuantity(), TimeQuantities.NANOSECOND, 1);
}
use of tech.units.indriya.quantity.time.TemporalQuantity in project indriya by unitsofmeasurement.
the class TimeQuantitiesTest method inverseTemporalTest.
@Test
public void inverseTemporalTest() {
TemporalQuantity tenSeconds = TemporalQuantity.of(10, SECONDS);
Quantity<Frequency> perTenSeconds = tenSeconds.inverse();
assertEquals(0.1d, perTenSeconds.getValue());
assertEquals(HERTZ.getConverterTo(perTenSeconds.getUnit()), perTenSeconds.getUnit().getConverterTo(HERTZ));
}
use of tech.units.indriya.quantity.time.TemporalQuantity in project indriya by unitsofmeasurement.
the class TimeQuantitiesTest method ofTest.
@Test
public void ofTest() {
TemporalQuantity day = TemporalQuantity.of(1, DAYS);
TemporalQuantity hour = TemporalQuantity.of(1, HOURS);
TemporalQuantity minute = TemporalQuantity.of(1, MINUTES);
TemporalQuantity second = TemporalQuantity.of(1, SECONDS);
TemporalQuantity microSecond = TemporalQuantity.of(1, MICROS);
TemporalQuantity milliSecond = TemporalQuantity.of(1, MILLIS);
TemporalQuantity nanoSecond = TemporalQuantity.of(1, NANOS);
assertEquals(DAYS, day.getTemporalUnit());
assertEquals(Integer.valueOf(1), day.getValue());
assertEquals(HOURS, hour.getTemporalUnit());
assertEquals(Integer.valueOf(1), hour.getValue());
assertEquals(MINUTES, minute.getTemporalUnit());
assertEquals(Integer.valueOf(1), minute.getValue());
assertEquals(SECONDS, second.getTemporalUnit());
assertEquals(Integer.valueOf(1), second.getValue());
assertEquals(MICROS, microSecond.getTemporalUnit());
assertEquals(Integer.valueOf(1), microSecond.getValue());
assertEquals(MILLIS, milliSecond.getTemporalUnit());
assertEquals(Integer.valueOf(1), milliSecond.getValue());
assertEquals(NANOS, nanoSecond.getTemporalUnit());
assertEquals(Integer.valueOf(1), nanoSecond.getValue());
}
Aggregations