use of java.time.Duration in project jdk8u_jdk by JetBrains.
the class TCKDuration method dividedBy_max.
@Test
public void dividedBy_max() {
Duration test = Duration.ofSeconds(Long.MAX_VALUE);
assertEquals(test.dividedBy(Long.MAX_VALUE), Duration.ofSeconds(1));
}
use of java.time.Duration in project jdk8u_jdk by JetBrains.
the class TCKDuration method factory_seconds_long_long.
//-----------------------------------------------------------------------
// ofSeconds(long,long)
//-----------------------------------------------------------------------
@Test
public void factory_seconds_long_long() {
for (long i = -2; i <= 2; i++) {
for (int j = 0; j < 10; j++) {
Duration t = Duration.ofSeconds(i, j);
assertEquals(t.getSeconds(), i);
assertEquals(t.getNano(), j);
}
for (int j = -10; j < 0; j++) {
Duration t = Duration.ofSeconds(i, j);
assertEquals(t.getSeconds(), i - 1);
assertEquals(t.getNano(), j + 1000000000);
}
for (int j = 999999990; j < 1000000000; j++) {
Duration t = Duration.ofSeconds(i, j);
assertEquals(t.getSeconds(), i);
assertEquals(t.getNano(), j);
}
}
}
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);
}
Aggregations