25 |
|
} |
26 |
|
|
27 |
|
public static Test suite() { |
28 |
< |
return new TestSuite(ConcurrentLinkedDequeTest.class); |
28 |
> |
class Implementation implements CollectionImplementation { |
29 |
> |
public Class<?> klazz() { return ConcurrentLinkedDeque.class; } |
30 |
> |
public Collection emptyCollection() { return new ConcurrentLinkedDeque(); } |
31 |
> |
public Object makeElement(int i) { return i; } |
32 |
> |
public boolean isConcurrent() { return true; } |
33 |
> |
public boolean permitsNulls() { return false; } |
34 |
> |
} |
35 |
> |
return newTestSuite(ConcurrentLinkedDequeTest.class, |
36 |
> |
CollectionTest.testSuite(new Implementation())); |
37 |
|
} |
38 |
|
|
39 |
|
/** |
447 |
|
assertTrue(q.contains(i)); |
448 |
|
assertTrue(q.remove(i)); |
449 |
|
assertFalse(q.contains(i)); |
450 |
< |
assertTrue(q.contains(i-1)); |
450 |
> |
assertTrue(q.contains(i - 1)); |
451 |
|
} |
452 |
|
for (int i = 0; i < SIZE; i += 2) { |
453 |
|
assertTrue(q.contains(i)); |
454 |
|
assertTrue(q.remove(i)); |
455 |
|
assertFalse(q.contains(i)); |
456 |
< |
assertFalse(q.remove(i+1)); |
457 |
< |
assertFalse(q.contains(i+1)); |
456 |
> |
assertFalse(q.remove(i + 1)); |
457 |
> |
assertFalse(q.contains(i + 1)); |
458 |
|
} |
459 |
|
assertTrue(q.isEmpty()); |
460 |
|
} |
558 |
|
} |
559 |
|
for (int i = 0; i < SIZE; i += 2) { |
560 |
|
assertTrue(q.removeFirstOccurrence(new Integer(i))); |
561 |
< |
assertFalse(q.removeFirstOccurrence(new Integer(i+1))); |
561 |
> |
assertFalse(q.removeFirstOccurrence(new Integer(i + 1))); |
562 |
|
} |
563 |
|
assertTrue(q.isEmpty()); |
564 |
|
} |
573 |
|
} |
574 |
|
for (int i = 0; i < SIZE; i += 2) { |
575 |
|
assertTrue(q.removeLastOccurrence(new Integer(i))); |
576 |
< |
assertFalse(q.removeLastOccurrence(new Integer(i+1))); |
576 |
> |
assertFalse(q.removeLastOccurrence(new Integer(i + 1))); |
577 |
|
} |
578 |
|
assertTrue(q.isEmpty()); |
579 |
|
} |
761 |
|
final Random rng = new Random(); |
762 |
|
for (int iters = 0; iters < 100; ++iters) { |
763 |
|
int max = rng.nextInt(5) + 2; |
764 |
< |
int split = rng.nextInt(max-1) + 1; |
764 |
> |
int split = rng.nextInt(max - 1) + 1; |
765 |
|
for (int j = 1; j <= max; ++j) |
766 |
|
q.add(new Integer(j)); |
767 |
|
Iterator it = q.iterator(); |
768 |
|
for (int j = 1; j <= split; ++j) |
769 |
|
assertEquals(it.next(), new Integer(j)); |
770 |
|
it.remove(); |
771 |
< |
assertEquals(it.next(), new Integer(split+1)); |
771 |
> |
assertEquals(it.next(), new Integer(split + 1)); |
772 |
|
for (int j = 1; j <= split; ++j) |
773 |
|
q.remove(new Integer(j)); |
774 |
|
it = q.iterator(); |
775 |
< |
for (int j = split+1; j <= max; ++j) { |
775 |
> |
for (int j = split + 1; j <= max; ++j) { |
776 |
|
assertEquals(it.next(), new Integer(j)); |
777 |
|
it.remove(); |
778 |
|
} |
829 |
|
final Random rng = new Random(); |
830 |
|
for (int iters = 0; iters < 100; ++iters) { |
831 |
|
int max = rng.nextInt(5) + 2; |
832 |
< |
int split = rng.nextInt(max-1) + 1; |
832 |
> |
int split = rng.nextInt(max - 1) + 1; |
833 |
|
for (int j = max; j >= 1; --j) |
834 |
|
q.add(new Integer(j)); |
835 |
|
Iterator it = q.descendingIterator(); |
836 |
|
for (int j = 1; j <= split; ++j) |
837 |
|
assertEquals(it.next(), new Integer(j)); |
838 |
|
it.remove(); |
839 |
< |
assertEquals(it.next(), new Integer(split+1)); |
839 |
> |
assertEquals(it.next(), new Integer(split + 1)); |
840 |
|
for (int j = 1; j <= split; ++j) |
841 |
|
q.remove(new Integer(j)); |
842 |
|
it = q.descendingIterator(); |
843 |
< |
for (int j = split+1; j <= max; ++j) { |
843 |
> |
for (int j = split + 1; j <= max; ++j) { |
844 |
|
assertEquals(it.next(), new Integer(j)); |
845 |
|
it.remove(); |
846 |
|
} |