use of tech.units.indriya.quantity.time.TimeUnitQuantity in project indriya by unitsofmeasurement.
the class TimeQuantitiesConcurrentTest method convertTest.
@Test
public void convertTest() {
TimeUnitQuantity day = TimeUnitQuantity.of(DAYS, 1);
TimeUnitQuantity hours = day.to(TimeUnit.HOURS);
assertEquals(TimeUnit.HOURS, hours.getTimeUnit());
assertEquals(Integer.valueOf(24), hours.getValue());
TimeUnitQuantity oneDay = hours.to(TimeUnit.DAYS);
assertEquals(TimeUnit.DAYS, oneDay.getTimeUnit());
assertEquals(Integer.valueOf(1), oneDay.getValue());
}
use of tech.units.indriya.quantity.time.TimeUnitQuantity in project indriya by unitsofmeasurement.
the class TimeQuantitiesConcurrentTest method ofTest.
@Test
public void ofTest() {
TimeUnitQuantity day = TimeUnitQuantity.of(1, DAYS);
TimeUnitQuantity hour = TimeUnitQuantity.of(HOURS, 1);
TimeUnitQuantity minute = TimeUnitQuantity.of(MINUTES, 1);
TimeUnitQuantity second = TimeUnitQuantity.of(SECONDS, 1);
TimeUnitQuantity microSecond = TimeUnitQuantity.of(MICROSECONDS, 1);
TimeUnitQuantity milliSecond = TimeUnitQuantity.of(MILLISECONDS, 1);
TimeUnitQuantity nanoSecond = TimeUnitQuantity.of(NANOSECONDS, 1);
assertEquals(DAYS, day.getTimeUnit());
assertEquals(Integer.valueOf(1), day.getValue());
assertEquals(HOURS, hour.getTimeUnit());
assertEquals(Integer.valueOf(1), hour.getValue());
assertEquals(MINUTES, minute.getTimeUnit());
assertEquals(Integer.valueOf(1), minute.getValue());
assertEquals(SECONDS, second.getTimeUnit());
assertEquals(Integer.valueOf(1), second.getValue());
assertEquals(MICROSECONDS, microSecond.getTimeUnit());
assertEquals(Integer.valueOf(1), microSecond.getValue());
assertEquals(MILLISECONDS, milliSecond.getTimeUnit());
assertEquals(Integer.valueOf(1), milliSecond.getValue());
assertEquals(NANOSECONDS, nanoSecond.getTimeUnit());
assertEquals(Integer.valueOf(1), nanoSecond.getValue());
}
use of tech.units.indriya.quantity.time.TimeUnitQuantity in project indriya by unitsofmeasurement.
the class TimeQuantitiesTest method inverseTest.
@Test
public void inverseTest() {
TimeUnitQuantity tenSeconds = TimeUnitQuantity.of(10, TimeUnit.SECONDS);
Quantity<Frequency> perTenSeconds = tenSeconds.inverse();
assertEquals(Double.valueOf(0.1d), perTenSeconds.getValue());
assertEquals(HERTZ.getConverterTo(perTenSeconds.getUnit()), perTenSeconds.getUnit().getConverterTo(HERTZ));
}
use of tech.units.indriya.quantity.time.TimeUnitQuantity in project indriya by unitsofmeasurement.
the class TimeQuantitiesConcurrentTest method toUnitTest.
@Test
public void toUnitTest() {
TimeUnitQuantity day = TimeUnitQuantity.of(DAYS, 1);
TimeUnitQuantity hour = TimeUnitQuantity.of(HOURS, 1);
TimeUnitQuantity minute = TimeUnitQuantity.of(MINUTES, 1);
TimeUnitQuantity second = TimeUnitQuantity.of(SECONDS, 1);
TimeUnitQuantity microSecond = TimeUnitQuantity.of(MICROSECONDS, 1);
TimeUnitQuantity milliSecond = TimeUnitQuantity.of(MILLISECONDS, 1);
TimeUnitQuantity nanoSecond = TimeUnitQuantity.of(NANOSECONDS, 1);
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.TimeUnitQuantity in project indriya by unitsofmeasurement.
the class TimeQuantitiesConcurrentTest method ofQuantityTest.
@Test
public void ofQuantityTest() {
Quantity<Time> hour = Quantities.getQuantity(1, Units.HOUR);
TimeUnitQuantity timeQuantity = TimeUnitQuantity.of(hour);
assertEquals(TimeUnit.SECONDS, timeQuantity.getTimeUnit());
assertEquals(SECOND, timeQuantity.toUnit());
assertEquals(Integer.valueOf(3600), timeQuantity.getValue());
}
Aggregations