1 |
|
/* |
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 |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
* Other contributors include Andrew Wright, Jeffrey Hayes, |
6 |
|
* Pat Fisher, Mike Judd. |
7 |
|
*/ |
8 |
|
|
9 |
|
import junit.framework.*; |
10 |
< |
import java.util.*; |
10 |
> |
import java.util.Arrays; |
11 |
> |
import java.util.ArrayList; |
12 |
> |
import java.util.Iterator; |
13 |
> |
import java.util.NoSuchElementException; |
14 |
> |
import java.util.concurrent.BlockingQueue; |
15 |
> |
import java.util.concurrent.CountDownLatch; |
16 |
> |
import java.util.concurrent.Delayed; |
17 |
> |
import java.util.concurrent.DelayQueue; |
18 |
> |
import java.util.concurrent.Executors; |
19 |
> |
import java.util.concurrent.ExecutorService; |
20 |
> |
import java.util.concurrent.TimeUnit; |
21 |
|
import static java.util.concurrent.TimeUnit.MILLISECONDS; |
12 |
– |
import java.util.concurrent.*; |
22 |
|
|
23 |
|
public class DelayQueueTest extends JSR166TestCase { |
24 |
+ |
|
25 |
+ |
public static class Generic extends BlockingQueueTest { |
26 |
+ |
protected BlockingQueue emptyCollection() { |
27 |
+ |
return new DelayQueue(); |
28 |
+ |
} |
29 |
+ |
protected PDelay makeElement(int i) { |
30 |
+ |
return new PDelay(i); |
31 |
+ |
} |
32 |
+ |
} |
33 |
+ |
|
34 |
|
public static void main(String[] args) { |
35 |
|
junit.textui.TestRunner.run(suite()); |
36 |
|
} |
37 |
|
|
38 |
|
public static Test suite() { |
39 |
< |
return new TestSuite(DelayQueueTest.class); |
39 |
> |
return newTestSuite(DelayQueueTest.class, |
40 |
> |
new Generic().testSuite()); |
41 |
|
} |
42 |
|
|
43 |
|
private static final int NOCAP = Integer.MAX_VALUE; |
69 |
|
return other.pseudodelay == pseudodelay; |
70 |
|
} |
71 |
|
|
52 |
– |
|
72 |
|
public long getDelay(TimeUnit ignore) { |
73 |
|
return pseudodelay; |
74 |
|
} |
81 |
|
} |
82 |
|
} |
83 |
|
|
65 |
– |
|
84 |
|
/** |
85 |
|
* Delayed implementation that actually delays |
86 |
|
*/ |
122 |
|
} |
123 |
|
} |
124 |
|
|
107 |
– |
|
125 |
|
/** |
126 |
|
* Create a queue of given size containing consecutive |
127 |
|
* PDelays 0 ... n. |
128 |
|
*/ |
129 |
< |
private DelayQueue populatedQueue(int n) { |
130 |
< |
DelayQueue q = new DelayQueue(); |
129 |
> |
private DelayQueue<PDelay> populatedQueue(int n) { |
130 |
> |
DelayQueue<PDelay> q = new DelayQueue<PDelay>(); |
131 |
|
assertTrue(q.isEmpty()); |
132 |
|
for (int i = n-1; i >= 0; i-=2) |
133 |
|
assertTrue(q.offer(new PDelay(i))); |
226 |
|
} |
227 |
|
|
228 |
|
/** |
212 |
– |
* offer(null) throws NPE |
213 |
– |
*/ |
214 |
– |
public void testOfferNull() { |
215 |
– |
try { |
216 |
– |
DelayQueue q = new DelayQueue(); |
217 |
– |
q.offer(null); |
218 |
– |
shouldThrow(); |
219 |
– |
} catch (NullPointerException success) {} |
220 |
– |
} |
221 |
– |
|
222 |
– |
/** |
223 |
– |
* add(null) throws NPE |
224 |
– |
*/ |
225 |
– |
public void testAddNull() { |
226 |
– |
try { |
227 |
– |
DelayQueue q = new DelayQueue(); |
228 |
– |
q.add(null); |
229 |
– |
shouldThrow(); |
230 |
– |
} catch (NullPointerException success) {} |
231 |
– |
} |
232 |
– |
|
233 |
– |
/** |
229 |
|
* offer non-null succeeds |
230 |
|
*/ |
231 |
|
public void testOffer() { |
246 |
|
} |
247 |
|
|
248 |
|
/** |
254 |
– |
* addAll(null) throws NPE |
255 |
– |
*/ |
256 |
– |
public void testAddAll1() { |
257 |
– |
try { |
258 |
– |
DelayQueue q = new DelayQueue(); |
259 |
– |
q.addAll(null); |
260 |
– |
shouldThrow(); |
261 |
– |
} catch (NullPointerException success) {} |
262 |
– |
} |
263 |
– |
|
264 |
– |
|
265 |
– |
/** |
249 |
|
* addAll(this) throws IAE |
250 |
|
*/ |
251 |
|
public void testAddAllSelf() { |
257 |
|
} |
258 |
|
|
259 |
|
/** |
277 |
– |
* addAll of a collection with null elements throws NPE |
278 |
– |
*/ |
279 |
– |
public void testAddAll2() { |
280 |
– |
try { |
281 |
– |
DelayQueue q = new DelayQueue(); |
282 |
– |
PDelay[] ints = new PDelay[SIZE]; |
283 |
– |
q.addAll(Arrays.asList(ints)); |
284 |
– |
shouldThrow(); |
285 |
– |
} catch (NullPointerException success) {} |
286 |
– |
} |
287 |
– |
|
288 |
– |
/** |
260 |
|
* addAll of a collection with any null elements throws NPE after |
261 |
|
* possibly adding some elements |
262 |
|
*/ |
287 |
|
} |
288 |
|
|
289 |
|
/** |
319 |
– |
* put(null) throws NPE |
320 |
– |
*/ |
321 |
– |
public void testPutNull() { |
322 |
– |
try { |
323 |
– |
DelayQueue q = new DelayQueue(); |
324 |
– |
q.put(null); |
325 |
– |
shouldThrow(); |
326 |
– |
} catch (NullPointerException success) {} |
327 |
– |
} |
328 |
– |
|
329 |
– |
/** |
290 |
|
* all elements successfully put are contained |
291 |
|
*/ |
292 |
< |
public void testPut() { |
293 |
< |
DelayQueue q = new DelayQueue(); |
294 |
< |
for (int i = 0; i < SIZE; ++i) { |
295 |
< |
PDelay I = new PDelay(i); |
296 |
< |
q.put(I); |
297 |
< |
assertTrue(q.contains(I)); |
298 |
< |
} |
299 |
< |
assertEquals(SIZE, q.size()); |
292 |
> |
public void testPut() { |
293 |
> |
DelayQueue q = new DelayQueue(); |
294 |
> |
for (int i = 0; i < SIZE; ++i) { |
295 |
> |
PDelay I = new PDelay(i); |
296 |
> |
q.put(I); |
297 |
> |
assertTrue(q.contains(I)); |
298 |
> |
} |
299 |
> |
assertEquals(SIZE, q.size()); |
300 |
|
} |
301 |
|
|
302 |
|
/** |
304 |
|
*/ |
305 |
|
public void testPutWithTake() throws InterruptedException { |
306 |
|
final DelayQueue q = new DelayQueue(); |
307 |
< |
Thread t = new Thread(new CheckedRunnable() { |
307 |
> |
Thread t = newStartedThread(new CheckedRunnable() { |
308 |
|
public void realRun() { |
309 |
|
q.put(new PDelay(0)); |
310 |
|
q.put(new PDelay(0)); |
312 |
|
q.put(new PDelay(0)); |
313 |
|
}}); |
314 |
|
|
315 |
< |
t.start(); |
316 |
< |
Thread.sleep(SHORT_DELAY_MS); |
357 |
< |
q.take(); |
358 |
< |
t.interrupt(); |
359 |
< |
t.join(); |
315 |
> |
awaitTermination(t); |
316 |
> |
assertEquals(4, q.size()); |
317 |
|
} |
318 |
|
|
319 |
|
/** |
321 |
|
*/ |
322 |
|
public void testTimedOffer() throws InterruptedException { |
323 |
|
final DelayQueue q = new DelayQueue(); |
324 |
< |
Thread t = new Thread(new CheckedRunnable() { |
324 |
> |
Thread t = newStartedThread(new CheckedRunnable() { |
325 |
|
public void realRun() throws InterruptedException { |
326 |
|
q.put(new PDelay(0)); |
327 |
|
q.put(new PDelay(0)); |
329 |
|
assertTrue(q.offer(new PDelay(0), LONG_DELAY_MS, MILLISECONDS)); |
330 |
|
}}); |
331 |
|
|
332 |
< |
t.start(); |
376 |
< |
Thread.sleep(SMALL_DELAY_MS); |
377 |
< |
t.interrupt(); |
378 |
< |
t.join(); |
332 |
> |
awaitTermination(t); |
333 |
|
} |
334 |
|
|
335 |
|
/** |
343 |
|
} |
344 |
|
|
345 |
|
/** |
392 |
– |
* take blocks interruptibly when empty |
393 |
– |
*/ |
394 |
– |
public void testTakeFromEmpty() throws InterruptedException { |
395 |
– |
final DelayQueue q = new DelayQueue(); |
396 |
– |
Thread t = new ThreadShouldThrow(InterruptedException.class) { |
397 |
– |
public void realRun() throws InterruptedException { |
398 |
– |
q.take(); |
399 |
– |
}}; |
400 |
– |
|
401 |
– |
t.start(); |
402 |
– |
Thread.sleep(SHORT_DELAY_MS); |
403 |
– |
t.interrupt(); |
404 |
– |
t.join(); |
405 |
– |
} |
406 |
– |
|
407 |
– |
/** |
346 |
|
* Take removes existing elements until empty, then blocks interruptibly |
347 |
|
*/ |
348 |
|
public void testBlockingTake() throws InterruptedException { |
349 |
|
final DelayQueue q = populatedQueue(SIZE); |
350 |
< |
Thread t = new Thread(new CheckedRunnable() { |
350 |
> |
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
351 |
> |
Thread t = newStartedThread(new CheckedRunnable() { |
352 |
|
public void realRun() throws InterruptedException { |
353 |
|
for (int i = 0; i < SIZE; ++i) { |
354 |
|
assertEquals(new PDelay(i), ((PDelay)q.take())); |
355 |
|
} |
356 |
+ |
|
357 |
+ |
Thread.currentThread().interrupt(); |
358 |
|
try { |
359 |
|
q.take(); |
360 |
|
shouldThrow(); |
361 |
|
} catch (InterruptedException success) {} |
362 |
+ |
assertFalse(Thread.interrupted()); |
363 |
+ |
|
364 |
+ |
pleaseInterrupt.countDown(); |
365 |
+ |
try { |
366 |
+ |
q.take(); |
367 |
+ |
shouldThrow(); |
368 |
+ |
} catch (InterruptedException success) {} |
369 |
+ |
assertFalse(Thread.interrupted()); |
370 |
|
}}); |
371 |
|
|
372 |
< |
t.start(); |
373 |
< |
Thread.sleep(SHORT_DELAY_MS); |
372 |
> |
await(pleaseInterrupt); |
373 |
> |
assertThreadStaysAlive(t); |
374 |
|
t.interrupt(); |
375 |
< |
t.join(); |
375 |
> |
awaitTermination(t); |
376 |
|
} |
377 |
|
|
429 |
– |
|
378 |
|
/** |
379 |
|
* poll succeeds unless empty |
380 |
|
*/ |
387 |
|
} |
388 |
|
|
389 |
|
/** |
390 |
< |
* timed pool with zero timeout succeeds when non-empty, else times out |
390 |
> |
* timed poll with zero timeout succeeds when non-empty, else times out |
391 |
|
*/ |
392 |
|
public void testTimedPoll0() throws InterruptedException { |
393 |
|
DelayQueue q = populatedQueue(SIZE); |
398 |
|
} |
399 |
|
|
400 |
|
/** |
401 |
< |
* timed pool with nonzero timeout succeeds when non-empty, else times out |
401 |
> |
* timed poll with nonzero timeout succeeds when non-empty, else times out |
402 |
|
*/ |
403 |
|
public void testTimedPoll() throws InterruptedException { |
404 |
|
DelayQueue q = populatedQueue(SIZE); |
405 |
|
for (int i = 0; i < SIZE; ++i) { |
406 |
< |
assertEquals(new PDelay(i), ((PDelay)q.poll(SHORT_DELAY_MS, MILLISECONDS))); |
407 |
< |
} |
408 |
< |
assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); |
406 |
> |
long startTime = System.nanoTime(); |
407 |
> |
assertEquals(new PDelay(i), ((PDelay)q.poll(LONG_DELAY_MS, MILLISECONDS))); |
408 |
> |
assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS); |
409 |
> |
} |
410 |
> |
long startTime = System.nanoTime(); |
411 |
> |
assertNull(q.poll(timeoutMillis(), MILLISECONDS)); |
412 |
> |
assertTrue(millisElapsedSince(startTime) >= timeoutMillis()); |
413 |
> |
checkEmpty(q); |
414 |
|
} |
415 |
|
|
416 |
|
/** |
418 |
|
* returning timeout status |
419 |
|
*/ |
420 |
|
public void testInterruptedTimedPoll() throws InterruptedException { |
421 |
< |
Thread t = new Thread(new CheckedRunnable() { |
421 |
> |
final CountDownLatch pleaseInterrupt = new CountDownLatch(1); |
422 |
> |
Thread t = newStartedThread(new CheckedRunnable() { |
423 |
|
public void realRun() throws InterruptedException { |
424 |
|
DelayQueue q = populatedQueue(SIZE); |
425 |
|
for (int i = 0; i < SIZE; ++i) { |
426 |
|
assertEquals(new PDelay(i), ((PDelay)q.poll(SHORT_DELAY_MS, MILLISECONDS))); |
427 |
|
} |
474 |
– |
try { |
475 |
– |
q.poll(SMALL_DELAY_MS, MILLISECONDS); |
476 |
– |
shouldThrow(); |
477 |
– |
} catch (InterruptedException success) {} |
478 |
– |
}}); |
479 |
– |
|
480 |
– |
t.start(); |
481 |
– |
Thread.sleep(SHORT_DELAY_MS); |
482 |
– |
t.interrupt(); |
483 |
– |
t.join(); |
484 |
– |
} |
485 |
– |
|
486 |
– |
/** |
487 |
– |
* timed poll before a delayed offer fails; after offer succeeds; |
488 |
– |
* on interruption throws |
489 |
– |
*/ |
490 |
– |
public void testTimedPollWithOffer() throws InterruptedException { |
491 |
– |
final DelayQueue q = new DelayQueue(); |
492 |
– |
final PDelay pdelay = new PDelay(0); |
493 |
– |
final CheckedBarrier barrier = new CheckedBarrier(2); |
494 |
– |
Thread t = new Thread(new CheckedRunnable() { |
495 |
– |
public void realRun() throws InterruptedException { |
496 |
– |
assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); |
497 |
– |
|
498 |
– |
barrier.await(); |
499 |
– |
assertSame(pdelay, q.poll(MEDIUM_DELAY_MS, MILLISECONDS)); |
428 |
|
|
429 |
|
Thread.currentThread().interrupt(); |
430 |
|
try { |
431 |
< |
q.poll(SHORT_DELAY_MS, MILLISECONDS); |
431 |
> |
q.poll(LONG_DELAY_MS, MILLISECONDS); |
432 |
|
shouldThrow(); |
433 |
|
} catch (InterruptedException success) {} |
434 |
+ |
assertFalse(Thread.interrupted()); |
435 |
|
|
436 |
< |
barrier.await(); |
436 |
> |
pleaseInterrupt.countDown(); |
437 |
|
try { |
438 |
< |
q.poll(MEDIUM_DELAY_MS, MILLISECONDS); |
438 |
> |
q.poll(LONG_DELAY_MS, MILLISECONDS); |
439 |
|
shouldThrow(); |
440 |
|
} catch (InterruptedException success) {} |
441 |
+ |
assertFalse(Thread.interrupted()); |
442 |
|
}}); |
443 |
|
|
444 |
< |
t.start(); |
445 |
< |
barrier.await(); |
516 |
< |
assertTrue(q.offer(pdelay, SHORT_DELAY_MS, MILLISECONDS)); |
517 |
< |
barrier.await(); |
518 |
< |
sleep(SHORT_DELAY_MS); |
444 |
> |
await(pleaseInterrupt); |
445 |
> |
assertThreadStaysAlive(t); |
446 |
|
t.interrupt(); |
447 |
< |
t.join(); |
447 |
> |
awaitTermination(t); |
448 |
|
} |
449 |
|
|
523 |
– |
|
450 |
|
/** |
451 |
|
* peek returns next element, or null if empty |
452 |
|
*/ |
593 |
|
Object[] o = q.toArray(); |
594 |
|
Arrays.sort(o); |
595 |
|
for (int i = 0; i < o.length; i++) |
596 |
< |
assertEquals(o[i], q.take()); |
596 |
> |
assertSame(o[i], q.take()); |
597 |
|
} |
598 |
|
|
599 |
|
/** |
600 |
|
* toArray(a) contains all elements |
601 |
|
*/ |
602 |
< |
public void testToArray2() throws InterruptedException { |
603 |
< |
DelayQueue q = populatedQueue(SIZE); |
602 |
> |
public void testToArray2() { |
603 |
> |
DelayQueue<PDelay> q = populatedQueue(SIZE); |
604 |
|
PDelay[] ints = new PDelay[SIZE]; |
605 |
< |
ints = (PDelay[])q.toArray(ints); |
605 |
> |
PDelay[] array = q.toArray(ints); |
606 |
> |
assertSame(ints, array); |
607 |
|
Arrays.sort(ints); |
608 |
|
for (int i = 0; i < ints.length; i++) |
609 |
< |
assertEquals(ints[i], q.take()); |
609 |
> |
assertSame(ints[i], q.remove()); |
610 |
|
} |
611 |
|
|
685 |
– |
|
612 |
|
/** |
613 |
< |
* toArray(null) throws NPE |
688 |
< |
*/ |
689 |
< |
public void testToArray_BadArg() { |
690 |
< |
DelayQueue q = populatedQueue(SIZE); |
691 |
< |
try { |
692 |
< |
Object o[] = q.toArray(null); |
693 |
< |
shouldThrow(); |
694 |
< |
} catch (NullPointerException success) {} |
695 |
< |
} |
696 |
< |
|
697 |
< |
/** |
698 |
< |
* toArray with incompatible array type throws CCE |
613 |
> |
* toArray(incompatible array type) throws ArrayStoreException |
614 |
|
*/ |
615 |
|
public void testToArray1_BadArg() { |
616 |
|
DelayQueue q = populatedQueue(SIZE); |
617 |
|
try { |
618 |
< |
Object o[] = q.toArray(new String[10]); |
618 |
> |
q.toArray(new String[10]); |
619 |
|
shouldThrow(); |
620 |
|
} catch (ArrayStoreException success) {} |
621 |
|
} |
651 |
|
assertFalse(it.hasNext()); |
652 |
|
} |
653 |
|
|
739 |
– |
|
654 |
|
/** |
655 |
|
* toString contains toStrings of elements |
656 |
|
*/ |
658 |
|
DelayQueue q = populatedQueue(SIZE); |
659 |
|
String s = q.toString(); |
660 |
|
for (int i = 0; i < SIZE; ++i) { |
661 |
< |
assertTrue(s.indexOf(String.valueOf(Integer.MIN_VALUE+i)) >= 0); |
661 |
> |
assertTrue(s.contains(String.valueOf(Integer.MIN_VALUE+i))); |
662 |
|
} |
663 |
|
} |
664 |
|
|
665 |
|
/** |
666 |
< |
* offer transfers elements across Executor tasks |
666 |
> |
* timed poll transfers elements across Executor tasks |
667 |
|
*/ |
668 |
|
public void testPollInExecutor() { |
669 |
|
final DelayQueue q = new DelayQueue(); |
670 |
+ |
final CheckedBarrier threadsStarted = new CheckedBarrier(2); |
671 |
|
ExecutorService executor = Executors.newFixedThreadPool(2); |
672 |
|
executor.execute(new CheckedRunnable() { |
673 |
|
public void realRun() throws InterruptedException { |
674 |
|
assertNull(q.poll()); |
675 |
< |
assertTrue(null != q.poll(MEDIUM_DELAY_MS, MILLISECONDS)); |
676 |
< |
assertTrue(q.isEmpty()); |
675 |
> |
threadsStarted.await(); |
676 |
> |
assertTrue(null != q.poll(LONG_DELAY_MS, MILLISECONDS)); |
677 |
> |
checkEmpty(q); |
678 |
|
}}); |
679 |
|
|
680 |
|
executor.execute(new CheckedRunnable() { |
681 |
|
public void realRun() throws InterruptedException { |
682 |
< |
Thread.sleep(SHORT_DELAY_MS); |
682 |
> |
threadsStarted.await(); |
683 |
|
q.put(new PDelay(1)); |
684 |
|
}}); |
685 |
|
|
686 |
|
joinPool(executor); |
687 |
|
} |
688 |
|
|
773 |
– |
|
689 |
|
/** |
690 |
|
* Delayed actions do not occur until their delay elapses |
691 |
|
*/ |
715 |
|
assertNotNull(q.peek()); |
716 |
|
} |
717 |
|
|
803 |
– |
|
718 |
|
/** |
719 |
|
* poll of a non-empty queue returns null if no expired elements. |
720 |
|
*/ |
730 |
|
public void testTimedPollDelayed() throws InterruptedException { |
731 |
|
DelayQueue q = new DelayQueue(); |
732 |
|
q.add(new NanoDelay(LONG_DELAY_MS * 1000000L)); |
733 |
< |
assertNull(q.poll(SHORT_DELAY_MS, MILLISECONDS)); |
820 |
< |
} |
821 |
< |
|
822 |
< |
/** |
823 |
< |
* drainTo(null) throws NPE |
824 |
< |
*/ |
825 |
< |
public void testDrainToNull() { |
826 |
< |
DelayQueue q = populatedQueue(SIZE); |
827 |
< |
try { |
828 |
< |
q.drainTo(null); |
829 |
< |
shouldThrow(); |
830 |
< |
} catch (NullPointerException success) {} |
831 |
< |
} |
832 |
< |
|
833 |
< |
/** |
834 |
< |
* drainTo(this) throws IAE |
835 |
< |
*/ |
836 |
< |
public void testDrainToSelf() { |
837 |
< |
DelayQueue q = populatedQueue(SIZE); |
838 |
< |
try { |
839 |
< |
q.drainTo(q); |
840 |
< |
shouldThrow(); |
841 |
< |
} catch (IllegalArgumentException success) {} |
733 |
> |
assertNull(q.poll(timeoutMillis(), MILLISECONDS)); |
734 |
|
} |
735 |
|
|
736 |
|
/** |
780 |
|
} |
781 |
|
|
782 |
|
/** |
783 |
< |
* drainTo(null, n) throws NPE |
892 |
< |
*/ |
893 |
< |
public void testDrainToNullN() { |
894 |
< |
DelayQueue q = populatedQueue(SIZE); |
895 |
< |
try { |
896 |
< |
q.drainTo(null, 0); |
897 |
< |
shouldThrow(); |
898 |
< |
} catch (NullPointerException success) {} |
899 |
< |
} |
900 |
< |
|
901 |
< |
/** |
902 |
< |
* drainTo(this, n) throws IAE |
903 |
< |
*/ |
904 |
< |
public void testDrainToSelfN() { |
905 |
< |
DelayQueue q = populatedQueue(SIZE); |
906 |
< |
try { |
907 |
< |
q.drainTo(q, 0); |
908 |
< |
shouldThrow(); |
909 |
< |
} catch (IllegalArgumentException success) {} |
910 |
< |
} |
911 |
< |
|
912 |
< |
/** |
913 |
< |
* drainTo(c, n) empties first max {n, size} elements of queue into c |
783 |
> |
* drainTo(c, n) empties first min(n, size) elements of queue into c |
784 |
|
*/ |
785 |
|
public void testDrainToN() { |
786 |
|
for (int i = 0; i < SIZE + 2; ++i) { |
787 |
|
DelayQueue q = populatedQueue(SIZE); |
788 |
|
ArrayList l = new ArrayList(); |
789 |
|
q.drainTo(l, i); |
790 |
< |
int k = (i < SIZE)? i : SIZE; |
790 |
> |
int k = (i < SIZE) ? i : SIZE; |
791 |
|
assertEquals(q.size(), SIZE-k); |
792 |
|
assertEquals(l.size(), k); |
793 |
|
} |
794 |
|
} |
795 |
|
|
926 |
– |
|
796 |
|
} |