use of java.time.Duration in project jdk8u_jdk by JetBrains.
the class TCKDuration method factory_between_TemporalTemporal_LT.
@Test(dataProvider = "durationBetweenLocalTime")
public void factory_between_TemporalTemporal_LT(LocalTime start, LocalTime end, long expectedSeconds, int expectedNanoOfSecond) {
Duration t = Duration.between(start, end);
assertEquals(t.getSeconds(), expectedSeconds);
assertEquals(t.getNano(), expectedNanoOfSecond);
}
use of java.time.Duration in project jdk8u_jdk by JetBrains.
the class TCKDuration method test_toMillis.
//-----------------------------------------------------------------------
// toMillis()
//-----------------------------------------------------------------------
@Test
public void test_toMillis() {
Duration test = Duration.ofSeconds(321, 123456789);
assertEquals(test.toMillis(), 321000 + 123);
}
use of java.time.Duration in project jdk8u_jdk by JetBrains.
the class TCKDuration method minusDays_long.
@Test(dataProvider = "MinusDays")
public void minusDays_long(long days, long amount, long expectedDays) {
Duration t = Duration.ofDays(days);
t = t.minusDays(amount);
assertEquals(t.toDays(), expectedDays);
}
use of java.time.Duration in project jdk8u_jdk by JetBrains.
the class TCKDuration method test_equals.
//-----------------------------------------------------------------------
// equals()
//-----------------------------------------------------------------------
@Test
public void test_equals() {
Duration test5a = Duration.ofSeconds(5L, 20);
Duration test5b = Duration.ofSeconds(5L, 20);
Duration test5n = Duration.ofSeconds(5L, 30);
Duration test6 = Duration.ofSeconds(6L, 20);
assertEquals(test5a.equals(test5a), true);
assertEquals(test5a.equals(test5b), true);
assertEquals(test5a.equals(test5n), false);
assertEquals(test5a.equals(test6), false);
assertEquals(test5b.equals(test5a), true);
assertEquals(test5b.equals(test5b), true);
assertEquals(test5b.equals(test5n), false);
assertEquals(test5b.equals(test6), false);
assertEquals(test5n.equals(test5a), false);
assertEquals(test5n.equals(test5b), false);
assertEquals(test5n.equals(test5n), true);
assertEquals(test5n.equals(test6), false);
assertEquals(test6.equals(test5a), false);
assertEquals(test6.equals(test5b), false);
assertEquals(test6.equals(test5n), false);
assertEquals(test6.equals(test6), true);
}
use of java.time.Duration in project jdk8u_jdk by JetBrains.
the class TCKDuration method plusSeconds_long_overflowTooSmall.
@Test(expectedExceptions = { ArithmeticException.class })
public void plusSeconds_long_overflowTooSmall() {
Duration t = Duration.ofSeconds(-1, 0);
t.plusSeconds(Long.MIN_VALUE);
}
Aggregations