use of java.time.Duration in project jdk8u_jdk by JetBrains.
the class TCKDuration method plusNanos_long.
@Test(dataProvider = "PlusNanos")
public void plusNanos_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
Duration t = Duration.ofSeconds(seconds, nanos);
t = t.plusNanos(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_parse_minus.
@Test(dataProvider = "parseSuccess")
public void factory_parse_minus(String text, long expectedSeconds, int expectedNanoOfSecond) {
Duration test;
try {
test = Duration.parse("-" + text);
} catch (DateTimeParseException ex) {
assertEquals(expectedSeconds == Long.MIN_VALUE, true);
return;
}
// not inside try/catch or it breaks test
assertEquals(test, Duration.ofSeconds(expectedSeconds, expectedNanoOfSecond).negated());
}
use of java.time.Duration in project jdk8u_jdk by JetBrains.
the class TCKDuration method minusOverflowTooSmall.
@Test(expectedExceptions = ArithmeticException.class)
public void minusOverflowTooSmall() {
Duration t = Duration.ofSeconds(Long.MIN_VALUE);
t.minus(Duration.ofSeconds(0, 1));
}
use of java.time.Duration in project jdk8u_jdk by JetBrains.
the class TCKDuration method factory_nanos_max.
@Test
public void factory_nanos_max() {
Duration test = Duration.ofNanos(Long.MAX_VALUE);
assertEquals(test.getSeconds(), Long.MAX_VALUE / 1000000000);
assertEquals(test.getNano(), Long.MAX_VALUE % 1000000000);
}
use of java.time.Duration in project jdk8u_jdk by JetBrains.
the class TCKDuration method plusMillis_long_minusOneLess.
@Test(dataProvider = "PlusMillis")
public void plusMillis_long_minusOneLess(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
Duration t = Duration.ofSeconds(seconds - 1, nanos);
t = t.plusMillis(amount);
assertEquals(t.getSeconds(), expectedSeconds - 1);
assertEquals(t.getNano(), expectedNanoOfSecond);
}
Aggregations