104 |
|
*/ |
105 |
|
public void testConstructor5() { |
106 |
|
Integer[] ints = new Integer[SIZE]; |
107 |
< |
for (int i = 0; i < SIZE-1; ++i) |
107 |
> |
for (int i = 0; i < SIZE - 1; ++i) |
108 |
|
ints[i] = i; |
109 |
|
Collection<Integer> elements = Arrays.asList(ints); |
110 |
|
try { |
166 |
|
assertEquals(i, q.remove()); |
167 |
|
} |
168 |
|
for (int i = 0; i < SIZE; ++i) { |
169 |
< |
assertEquals(SIZE-i, q.remainingCapacity()); |
169 |
> |
assertEquals(SIZE - i, q.remainingCapacity()); |
170 |
|
assertEquals(SIZE, q.size() + q.remainingCapacity()); |
171 |
|
assertTrue(q.add(i)); |
172 |
|
} |
214 |
|
public void testAddAll3() { |
215 |
|
ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE); |
216 |
|
Integer[] ints = new Integer[SIZE]; |
217 |
< |
for (int i = 0; i < SIZE-1; ++i) |
217 |
> |
for (int i = 0; i < SIZE - 1; ++i) |
218 |
|
ints[i] = new Integer(i); |
219 |
|
try { |
220 |
|
q.addAll(Arrays.asList(ints)); |
572 |
|
assertTrue(changed); |
573 |
|
|
574 |
|
assertTrue(q.containsAll(p)); |
575 |
< |
assertEquals(SIZE-i, q.size()); |
575 |
> |
assertEquals(SIZE - i, q.size()); |
576 |
|
p.remove(); |
577 |
|
} |
578 |
|
} |
585 |
|
ArrayBlockingQueue q = populatedQueue(SIZE); |
586 |
|
ArrayBlockingQueue p = populatedQueue(i); |
587 |
|
assertTrue(q.removeAll(p)); |
588 |
< |
assertEquals(SIZE-i, q.size()); |
588 |
> |
assertEquals(SIZE - i, q.size()); |
589 |
|
for (int j = 0; j < i; ++j) { |
590 |
|
Integer x = (Integer)(p.remove()); |
591 |
|
assertFalse(q.contains(x)); |
619 |
|
checkToArray(q); |
620 |
|
assertEquals(i, q.poll()); |
621 |
|
checkToArray(q); |
622 |
< |
q.add(SIZE+i); |
622 |
> |
q.add(SIZE + i); |
623 |
|
} |
624 |
|
for (int i = 0; i < SIZE; i++) { |
625 |
|
checkToArray(q); |
626 |
< |
assertEquals(SIZE+i, q.poll()); |
626 |
> |
assertEquals(SIZE + i, q.poll()); |
627 |
|
} |
628 |
|
} |
629 |
|
|
673 |
|
checkToArray2(q); |
674 |
|
assertEquals(i, q.poll()); |
675 |
|
checkToArray2(q); |
676 |
< |
q.add(SIZE+i); |
676 |
> |
q.add(SIZE + i); |
677 |
|
} |
678 |
|
for (int i = 0; i < SIZE; i++) { |
679 |
|
checkToArray2(q); |
680 |
< |
assertEquals(SIZE+i, q.poll()); |
680 |
> |
assertEquals(SIZE + i, q.poll()); |
681 |
|
} |
682 |
|
} |
683 |
|
|
881 |
|
final ArrayBlockingQueue q = populatedQueue(SIZE); |
882 |
|
Thread t = new Thread(new CheckedRunnable() { |
883 |
|
public void realRun() throws InterruptedException { |
884 |
< |
q.put(new Integer(SIZE+1)); |
884 |
> |
q.put(new Integer(SIZE + 1)); |
885 |
|
}}); |
886 |
|
|
887 |
|
t.start(); |
898 |
|
* drainTo(c, n) empties first min(n, size) elements of queue into c |
899 |
|
*/ |
900 |
|
public void testDrainToN() { |
901 |
< |
ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE*2); |
901 |
> |
ArrayBlockingQueue q = new ArrayBlockingQueue(SIZE * 2); |
902 |
|
for (int i = 0; i < SIZE + 2; ++i) { |
903 |
|
for (int j = 0; j < SIZE; j++) |
904 |
|
assertTrue(q.offer(new Integer(j))); |
906 |
|
q.drainTo(l, i); |
907 |
|
int k = (i < SIZE) ? i : SIZE; |
908 |
|
assertEquals(k, l.size()); |
909 |
< |
assertEquals(SIZE-k, q.size()); |
909 |
> |
assertEquals(SIZE - k, q.size()); |
910 |
|
for (int j = 0; j < k; ++j) |
911 |
|
assertEquals(l.get(j), new Integer(j)); |
912 |
|
do {} while (q.poll() != null); |