Search in sources :

Example 1 with TemporalQuantity

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());
}
Also used : TemporalQuantity(tech.units.indriya.quantity.time.TemporalQuantity) Test(org.junit.jupiter.api.Test)

Example 2 with TemporalQuantity

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());
}
Also used : TemporalQuantity(tech.units.indriya.quantity.time.TemporalQuantity) Test(org.junit.jupiter.api.Test)

Example 3 with TemporalQuantity

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);
}
Also used : TemporalQuantity(tech.units.indriya.quantity.time.TemporalQuantity) Test(org.junit.jupiter.api.Test)

Example 4 with TemporalQuantity

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));
}
Also used : Frequency(javax.measure.quantity.Frequency) TemporalQuantity(tech.units.indriya.quantity.time.TemporalQuantity) Test(org.junit.jupiter.api.Test)

Example 5 with TemporalQuantity

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());
}
Also used : TemporalQuantity(tech.units.indriya.quantity.time.TemporalQuantity) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)6 TemporalQuantity (tech.units.indriya.quantity.time.TemporalQuantity)6 LocalTime (java.time.LocalTime)1 Frequency (javax.measure.quantity.Frequency)1 Time (javax.measure.quantity.Time)1