提交 5a11bc7f 编写于 作者: R rriggs

8023639: Difference between LocalTime.now(Clock.systemDefaultZone()) and...

8023639: Difference between LocalTime.now(Clock.systemDefaultZone()) and LocalTime.now() executed successively is more than 100 000 000 nanoseconds for slow machines
Summary: Test timed out on a slow machine; it is not a conformance test and should be in the test subtree
Reviewed-by: darcy, sherman
上级 516d1e97
......@@ -282,17 +282,6 @@ public class TCKLocalTime extends AbstractDateTimeTest {
check(LocalTime.MAX, 23, 59, 59, 999999999);
}
//-----------------------------------------------------------------------
// now()
//-----------------------------------------------------------------------
@Test
public void now() {
LocalTime expected = LocalTime.now(Clock.systemDefaultZone());
LocalTime test = LocalTime.now();
long diff = Math.abs(test.toNanoOfDay() - expected.toNanoOfDay());
assertTrue(diff < 100000000); // less than 0.1 secs
}
//-----------------------------------------------------------------------
// now(ZoneId)
//-----------------------------------------------------------------------
......
......@@ -61,7 +61,9 @@ package test.java.time;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertTrue;
import java.time.Clock;
import java.time.LocalTime;
import org.testng.annotations.Test;
......@@ -176,4 +178,23 @@ public class TestLocalTime extends AbstractTest {
}
}
//-----------------------------------------------------------------------
// now()
//-----------------------------------------------------------------------
@Test
public void now() {
// Warmup the TimeZone data so the following test does not include
// one-time initialization
LocalTime expected = LocalTime.now(Clock.systemDefaultZone());
expected = LocalTime.now(Clock.systemDefaultZone());
LocalTime test = LocalTime.now();
long diff = test.toNanoOfDay() - expected.toNanoOfDay();
if (diff < 0) {
// Adjust if for rollover around midnight
diff += 24 * 60 * 60 * 1_000_000_000L; // Nanos Per Day
}
assertTrue(diff < 500000000); // less than 0.5 secs
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册