use of java.time.Clock in project j2objc by google.
the class TCKInstant method now_Clock_allSecsInDay_utc.
@Test
public void now_Clock_allSecsInDay_utc() {
for (int i = 0; i < (2 * 24 * 60 * 60); i++) {
Instant expected = Instant.ofEpochSecond(i).plusNanos(123456789L);
Clock clock = Clock.fixed(expected, ZoneOffset.UTC);
Instant test = Instant.now(clock);
assertEquals(test, expected);
}
}
use of java.time.Clock in project j2objc by google.
the class TCKClock_Tick method test_tick_ClockDuration_1nsDuration.
public void test_tick_ClockDuration_1nsDuration() {
Clock underlying = Clock.system(PARIS);
Clock test = Clock.tick(underlying, Duration.ofNanos(1));
// spec says same
assertSame(test, underlying);
}
use of java.time.Clock in project j2objc by google.
the class TCKClock_Tick method test_tickMinutes_ZoneId.
// -----------------------------------------------------------------------
public void test_tickMinutes_ZoneId() {
Clock test = Clock.tickMinutes(PARIS);
assertEquals(test.getZone(), PARIS);
Instant instant = test.instant();
assertEquals(instant.getEpochSecond() % 60, 0);
assertEquals(instant.getNano(), 0);
}
use of java.time.Clock in project j2objc by google.
the class TCKClock_Tick method test_tick_ClockDuration_250millis.
// -----------------------------------------------------------------------
public void test_tick_ClockDuration_250millis() {
for (int i = 0; i < 1000; i++) {
Clock test = Clock.tick(Clock.fixed(ZDT.withNano(i * 1000_000).toInstant(), PARIS), Duration.ofMillis(250));
assertEquals(test.instant(), ZDT.withNano((i / 250) * 250_000_000).toInstant());
assertEquals(test.getZone(), PARIS);
}
}
use of java.time.Clock in project j2objc by google.
the class TCKClock_Offset method test_offset_ClockDuration_zeroDuration.
public void test_offset_ClockDuration_zeroDuration() {
Clock underlying = Clock.system(PARIS);
Clock test = Clock.offset(underlying, Duration.ZERO);
// spec says same
assertSame(test, underlying);
}
Aggregations