9 |
|
|
10 |
|
public class SystemTest extends JSR166TestCase { |
11 |
|
public static void main(String[] args) { |
12 |
< |
junit.textui.TestRunner.run(suite()); |
12 |
> |
junit.textui.TestRunner.run(suite()); |
13 |
|
} |
14 |
|
|
15 |
|
public static Test suite() { |
16 |
< |
return new TestSuite(SystemTest.class); |
16 |
> |
return new TestSuite(SystemTest.class); |
17 |
|
} |
18 |
|
|
19 |
|
/** |
20 |
< |
* Nanos between readings of millis is no longer than millis. |
20 |
> |
* Nanos between readings of millis is no longer than millis (plus |
21 |
> |
* one milli to allow for rounding). |
22 |
|
* This shows only that nano timing not (much) worse than milli. |
23 |
|
*/ |
24 |
|
public void testNanoTime1() { |
34 |
|
long nanos = n2 - n1; |
35 |
|
|
36 |
|
assertTrue(nanos >= 0); |
37 |
< |
assertTrue(nanos <= millis * 1000000); |
37 |
> |
assertTrue(nanos < (millis+1) * 1000000); |
38 |
|
} |
39 |
|
catch(InterruptedException ie) { |
40 |
< |
fail("unexpected exception"); |
40 |
> |
unexpectedException(); |
41 |
|
} |
42 |
|
} |
43 |
|
|
61 |
|
assertTrue(millis * 1000000 <= nanos); |
62 |
|
} |
63 |
|
catch(InterruptedException ie) { |
64 |
< |
fail("unexpected exception"); |
64 |
> |
unexpectedException(); |
65 |
|
} |
66 |
|
} |
67 |
|
|