1 |
|
/* |
2 |
< |
* Written by members of JCP JSR-166 Expert Group and released to the |
3 |
< |
* public domain. Use, modify, and redistribute this code in any way |
4 |
< |
* without acknowledgement. Other contributors include Andrew Wright, |
5 |
< |
* Jeffrey Hayes, Pat Fischer, Mike Judd. |
2 |
> |
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
> |
* Expert Group and released to the public domain, as explained at |
4 |
> |
* http://creativecommons.org/licenses/publicdomain |
5 |
> |
* Other contributors include Andrew Wright, Jeffrey Hayes, |
6 |
> |
* Pat Fisher, Mike Judd. |
7 |
|
*/ |
8 |
|
|
9 |
|
import junit.framework.*; |
10 |
|
|
11 |
|
public class SystemTest extends JSR166TestCase { |
12 |
|
public static void main(String[] args) { |
13 |
< |
junit.textui.TestRunner.run(suite()); |
13 |
> |
junit.textui.TestRunner.run(suite()); |
14 |
|
} |
15 |
|
|
16 |
|
public static Test suite() { |
17 |
< |
return new TestSuite(SystemTest.class); |
17 |
> |
return new TestSuite(SystemTest.class); |
18 |
|
} |
19 |
|
|
20 |
|
/** |
21 |
< |
* Nanos between readings of millis is no longer than millis. |
21 |
> |
* Nanos between readings of millis is no longer than millis (plus |
22 |
> |
* one milli to allow for rounding). |
23 |
|
* This shows only that nano timing not (much) worse than milli. |
24 |
|
*/ |
25 |
|
public void testNanoTime1() { |
35 |
|
long nanos = n2 - n1; |
36 |
|
|
37 |
|
assertTrue(nanos >= 0); |
38 |
< |
assertTrue(nanos <= millis * 1000000); |
38 |
> |
assertTrue(nanos < (millis+1) * 1000000); |
39 |
|
} |
40 |
|
catch(InterruptedException ie) { |
41 |
< |
fail("unexpected exception"); |
41 |
> |
unexpectedException(); |
42 |
|
} |
43 |
|
} |
44 |
|
|
62 |
|
assertTrue(millis * 1000000 <= nanos); |
63 |
|
} |
64 |
|
catch(InterruptedException ie) { |
65 |
< |
fail("unexpected exception"); |
65 |
> |
unexpectedException(); |
66 |
|
} |
67 |
|
} |
68 |
|
|