20 |
|
} |
21 |
|
|
22 |
|
/** |
23 |
< |
* |
23 |
> |
* convert correctly converts sample values across the four units |
24 |
|
*/ |
25 |
|
public void testConvert() { |
26 |
|
for (long t = 0; t < 10; ++t) { |
76 |
|
} |
77 |
|
|
78 |
|
/** |
79 |
< |
* |
79 |
> |
* toNanos correctly converts sample values in different units to |
80 |
> |
* nanoseconds |
81 |
|
*/ |
82 |
|
public void testToNanos() { |
83 |
|
for (long t = 0; t < 10; ++t) { |
94 |
|
} |
95 |
|
|
96 |
|
/** |
97 |
< |
* |
97 |
> |
* toMicros correctly converts sample values in different units to |
98 |
> |
* microseconds |
99 |
|
*/ |
100 |
|
public void testToMicros() { |
101 |
|
for (long t = 0; t < 10; ++t) { |
112 |
|
} |
113 |
|
|
114 |
|
/** |
115 |
< |
* |
115 |
> |
* toMillis correctly converts sample values in different units to |
116 |
> |
* milliseconds |
117 |
|
*/ |
118 |
|
public void testToMillis() { |
119 |
|
for (long t = 0; t < 10; ++t) { |
130 |
|
} |
131 |
|
|
132 |
|
/** |
133 |
< |
* |
133 |
> |
* toSeconds correctly converts sample values in different units to |
134 |
> |
* seconds |
135 |
|
*/ |
136 |
|
public void testToSeconds() { |
137 |
|
for (long t = 0; t < 10; ++t) { |
149 |
|
|
150 |
|
|
151 |
|
/** |
152 |
< |
* |
152 |
> |
* convert saturates positive too-large values to Long.MAX_VALUE |
153 |
> |
* and negative to LONG.MIN_VALUE |
154 |
|
*/ |
155 |
|
public void testConvertSaturate() { |
156 |
|
assertEquals(Long.MAX_VALUE, |
159 |
|
assertEquals(Long.MIN_VALUE, |
160 |
|
TimeUnit.NANOSECONDS.convert(-Long.MAX_VALUE / 4, |
161 |
|
TimeUnit.SECONDS)); |
157 |
– |
|
162 |
|
} |
163 |
|
|
164 |
|
/** |
165 |
< |
* |
165 |
> |
* toNanos saturates positive too-large values to Long.MAX_VALUE |
166 |
> |
* and negative to LONG.MIN_VALUE |
167 |
|
*/ |
168 |
|
public void testToNanosSaturate() { |
169 |
|
assertEquals(Long.MAX_VALUE, |
170 |
|
TimeUnit.MILLISECONDS.toNanos(Long.MAX_VALUE / 2)); |
171 |
|
assertEquals(Long.MIN_VALUE, |
172 |
|
TimeUnit.MILLISECONDS.toNanos(-Long.MAX_VALUE / 3)); |
168 |
– |
|
173 |
|
} |
174 |
|
|
175 |
|
|
176 |
|
/** |
177 |
< |
* |
177 |
> |
* toString returns string containing commn name of unit |
178 |
|
*/ |
179 |
|
public void testToString() { |
180 |
|
String s = TimeUnit.SECONDS.toString(); |
186 |
|
* Timed wait without holding lock throws |
187 |
|
* IllegalMonitorStateException |
188 |
|
*/ |
185 |
– |
/** |
186 |
– |
* |
187 |
– |
*/ |
189 |
|
public void testTimedWait_IllegalMonitorException() { |
190 |
|
//created a new thread with anonymous runnable |
191 |
|
|
216 |
|
} |
217 |
|
|
218 |
|
/** |
219 |
< |
* timedWait will throw InterruptedException. |
219 |
< |
* Thread t waits on timedWait while the main thread interrupts it. |
220 |
< |
* Note: This does not throw IllegalMonitorException since timeWait |
221 |
< |
* is synchronized on o |
222 |
< |
*/ |
223 |
< |
/** |
224 |
< |
* |
219 |
> |
* timedWait throws InterruptedException when interrupted |
220 |
|
*/ |
221 |
|
public void testTimedWait() { |
222 |
|
Thread t = new Thread(new Runnable() { |
248 |
|
|
249 |
|
|
250 |
|
/** |
251 |
< |
* timedJoin will throw InterruptedException. |
257 |
< |
* Thread t waits on timedJoin while the main thread interrupts it. |
258 |
< |
*/ |
259 |
< |
/** |
260 |
< |
* |
251 |
> |
* timedJoin throws InterruptedException when interrupted |
252 |
|
*/ |
253 |
|
public void testTimedJoin() { |
254 |
|
Thread t = new Thread(new Runnable() { |
280 |
|
} |
281 |
|
|
282 |
|
/** |
283 |
< |
* timedSleep will throw InterruptedException. |
293 |
< |
* Thread t waits on timedSleep while the main thread interrupts it. |
294 |
< |
*/ |
295 |
< |
/** |
296 |
< |
* |
283 |
> |
* timedSleep throws InterruptedException when interrupted |
284 |
|
*/ |
285 |
|
public void testTimedSleep() { |
286 |
|
//created a new thread with anonymous runnable |
306 |
|
} |
307 |
|
|
308 |
|
/** |
309 |
< |
* |
309 |
> |
* a deserialized serialized unit is equal |
310 |
|
*/ |
311 |
|
public void testSerialization() { |
312 |
|
TimeUnit q = TimeUnit.MILLISECONDS; |