本文整理汇总了Java中java.time.Clock.tick方法的典型用法代码示例。如果您正苦于以下问题:Java Clock.tick方法的具体用法?Java Clock.tick怎么用?Java Clock.tick使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.Clock
的用法示例。
在下文中一共展示了Clock.tick方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test__equals
import java.time.Clock; //导入方法依赖的package包/类
public void test__equals() {
Clock a = Clock.tick(Clock.system(PARIS), Duration.ofMillis(500));
Clock b = Clock.tick(Clock.system(PARIS), Duration.ofMillis(500));
assertEquals(a.equals(a), true);
assertEquals(a.equals(b), true);
assertEquals(b.equals(a), true);
assertEquals(b.equals(b), true);
Clock c = Clock.tick(Clock.system(MOSCOW), Duration.ofMillis(500));
assertEquals(a.equals(c), false);
Clock d = Clock.tick(Clock.system(PARIS), Duration.ofMillis(499));
assertEquals(a.equals(d), false);
assertEquals(a.equals(null), false);
assertEquals(a.equals("other type"), false);
assertEquals(a.equals(Clock.systemUTC()), false);
}
示例2: test_hashCode
import java.time.Clock; //导入方法依赖的package包/类
public void test_hashCode() {
Clock a = Clock.tick(Clock.system(PARIS), Duration.ofMillis(500));
Clock b = Clock.tick(Clock.system(PARIS), Duration.ofMillis(500));
assertEquals(a.hashCode(), a.hashCode());
assertEquals(a.hashCode(), b.hashCode());
Clock c = Clock.tick(Clock.system(MOSCOW), Duration.ofMillis(500));
assertEquals(a.hashCode() == c.hashCode(), false);
Clock d = Clock.tick(Clock.system(PARIS), Duration.ofMillis(499));
assertEquals(a.hashCode() == d.hashCode(), false);
}
示例3: test_tick_ClockDuration_subMilliNotDivisible_123ns
import java.time.Clock; //导入方法依赖的package包/类
@Test(expectedExceptions = IllegalArgumentException.class)
public void test_tick_ClockDuration_subMilliNotDivisible_123ns() {
Clock.tick(Clock.systemUTC(), Duration.ofSeconds(0, 123));
}
示例4: test_tick_ClockDuration_zeroDuration
import java.time.Clock; //导入方法依赖的package包/类
public void test_tick_ClockDuration_zeroDuration() {
Clock underlying = Clock.system(PARIS);
Clock test = Clock.tick(underlying, Duration.ZERO);
assertSame(test, underlying); // spec says same
}
示例5: test_tick_ClockDuration_1nsDuration
import java.time.Clock; //导入方法依赖的package包/类
public void test_tick_ClockDuration_1nsDuration() {
Clock underlying = Clock.system(PARIS);
Clock test = Clock.tick(underlying, Duration.ofNanos(1));
assertSame(test, underlying); // spec says same
}
示例6: test_tick_ClockDuration_maxDuration
import java.time.Clock; //导入方法依赖的package包/类
@Test(expectedExceptions = ArithmeticException.class)
public void test_tick_ClockDuration_maxDuration() {
Clock.tick(Clock.systemUTC(), Duration.ofSeconds(Long.MAX_VALUE));
}
示例7: test_tick_ClockDuration_subMilliNotDivisible_999ns
import java.time.Clock; //导入方法依赖的package包/类
@Test(expectedExceptions = IllegalArgumentException.class)
public void test_tick_ClockDuration_subMilliNotDivisible_999ns() {
Clock.tick(Clock.systemUTC(), Duration.ofSeconds(0, 999));
}
示例8: test_tick_ClockDuration_negative1ns
import java.time.Clock; //导入方法依赖的package包/类
@Test(expectedExceptions = IllegalArgumentException.class)
public void test_tick_ClockDuration_negative1ns() {
Clock.tick(Clock.systemUTC(), Duration.ofSeconds(0, -1));
}
示例9: test_withZone
import java.time.Clock; //导入方法依赖的package包/类
public void test_withZone() {
Clock test = Clock.tick(Clock.system(PARIS), Duration.ofMillis(500));
Clock changed = test.withZone(MOSCOW);
assertEquals(test.getZone(), PARIS);
assertEquals(changed.getZone(), MOSCOW);
}
示例10: test_tick_ClockDuration_nullClock
import java.time.Clock; //导入方法依赖的package包/类
@Test(expectedExceptions = NullPointerException.class)
public void test_tick_ClockDuration_nullClock() {
Clock.tick(null, Duration.ZERO);
}
示例11: test_tick_ClockDuration_negative1s
import java.time.Clock; //导入方法依赖的package包/类
@Test(expectedExceptions = IllegalArgumentException.class)
public void test_tick_ClockDuration_negative1s() {
Clock.tick(Clock.systemUTC(), Duration.ofSeconds(-1));
}
示例12: test_withZone_equal
import java.time.Clock; //导入方法依赖的package包/类
public void test_withZone_equal() {
Clock test = Clock.tick(Clock.system(PARIS), Duration.ofMillis(500));
Clock changed = test.withZone(PARIS);
assertEquals(test, changed);
}
示例13: test_withZone_same
import java.time.Clock; //导入方法依赖的package包/类
public void test_withZone_same() {
Clock test = Clock.tick(Clock.system(PARIS), Duration.ofMillis(500));
Clock changed = test.withZone(PARIS);
assertSame(test, changed);
}