use of java.time.Instant in project jdk8u_jdk by JetBrains.
the class TCKInstant method minusMillis_long_min.
@Test
public void minusMillis_long_min() {
Instant i = Instant.ofEpochSecond(MIN_SECOND, 1000000);
i = i.minusMillis(1);
assertEquals(i.getEpochSecond(), MIN_SECOND);
assertEquals(i.getNano(), 0);
}
use of java.time.Instant in project jdk8u_jdk by JetBrains.
the class TCKInstant method test_with_longTemporalField.
@Test(dataProvider = "with_longTemporalField")
public void test_with_longTemporalField(Instant test, TemporalField field, long value, Instant expected, Class<?> expectedEx) {
if (expectedEx == null) {
Instant result = test.with(field, value);
assertEquals(result, expected);
} else {
try {
Instant result = test.with(field, value);
fail();
} catch (Exception ex) {
assertTrue(expectedEx.isInstance(ex));
}
}
}
use of java.time.Instant in project jdk8u_jdk by JetBrains.
the class TCKDuration method factory_between_TemporalTemporal_Instant_negated.
@Test(dataProvider = "durationBetweenInstant")
public void factory_between_TemporalTemporal_Instant_negated(long secs1, int nanos1, long secs2, int nanos2, long expectedSeconds, int expectedNanoOfSecond) {
Instant start = Instant.ofEpochSecond(secs1, nanos1);
Instant end = Instant.ofEpochSecond(secs2, nanos2);
assertEquals(Duration.between(end, start), Duration.between(start, end).negated());
}
use of java.time.Instant in project jdk8u_jdk by JetBrains.
the class TCKInstant method minusMillis_long_max.
@Test
public void minusMillis_long_max() {
Instant i = Instant.ofEpochSecond(MAX_SECOND, 998999999);
i = i.minusMillis(-1);
assertEquals(i.getEpochSecond(), MAX_SECOND);
assertEquals(i.getNano(), 999999999);
}
use of java.time.Instant in project jdk8u_jdk by JetBrains.
the class TCKInstant method plusSeconds_long.
@Test(dataProvider = "PlusSeconds")
public void plusSeconds_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
Instant t = Instant.ofEpochSecond(seconds, nanos);
t = t.plusSeconds(amount);
assertEquals(t.getEpochSecond(), expectedSeconds);
assertEquals(t.getNano(), expectedNanoOfSecond);
}
Aggregations