use of java.time.Duration in project jdk8u_jdk by JetBrains.
the class TCKDuration method factory_between_TemporalTemporal_Instant.
@Test(dataProvider = "durationBetweenInstant")
public void factory_between_TemporalTemporal_Instant(long secs1, int nanos1, long secs2, int nanos2, long expectedSeconds, int expectedNanoOfSecond) {
Instant start = Instant.ofEpochSecond(secs1, nanos1);
Instant end = Instant.ofEpochSecond(secs2, nanos2);
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 minusMillis_long.
@Test(dataProvider = "MinusMillis")
public void minusMillis_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
Duration t = Duration.ofSeconds(seconds, nanos);
t = t.minusMillis(amount);
assertEquals(t.getSeconds(), expectedSeconds);
assertEquals(t.getNano(), expectedNanoOfSecond);
}
use of java.time.Duration in project jdk8u_jdk by JetBrains.
the class TCKDuration method factory_minutes_max.
@Test
public void factory_minutes_max() {
Duration test = Duration.ofMinutes(Long.MAX_VALUE / 60);
assertEquals(test.getSeconds(), (Long.MAX_VALUE / 60) * 60);
assertEquals(test.getNano(), 0);
}
use of java.time.Duration in project jdk8u_jdk by JetBrains.
the class TCKDuration method factory_parse.
@Test(dataProvider = "parseSuccess")
public void factory_parse(String text, long expectedSeconds, int expectedNanoOfSecond) {
Duration test = Duration.parse(text);
assertEquals(test.getSeconds(), expectedSeconds);
assertEquals(test.getNano(), expectedNanoOfSecond);
}
use of java.time.Duration in project jdk8u_jdk by JetBrains.
the class TCKDuration method minusNanos_long_overflowTooSmall.
@Test(expectedExceptions = { ArithmeticException.class })
public void minusNanos_long_overflowTooSmall() {
Duration t = Duration.ofSeconds(Long.MIN_VALUE, 0);
t.minusNanos(1);
}
Aggregations