9 |
|
import java.util.Deque; |
10 |
|
import java.util.NoSuchElementException; |
11 |
|
import java.util.Queue; |
12 |
+ |
import java.util.function.Consumer; |
13 |
|
|
14 |
|
import junit.framework.Test; |
15 |
|
|
46 |
|
Object[] a = new Object[0]; |
47 |
|
assertSame(a, c.toArray(a)); |
48 |
|
} |
49 |
< |
c.forEach((e) -> { throw new AssertionError(); }); |
49 |
> |
assertIteratorExhausted(c.iterator()); |
50 |
> |
Consumer alwaysThrows = (e) -> { throw new AssertionError(); }; |
51 |
> |
c.forEach(alwaysThrows); |
52 |
> |
c.iterator().forEachRemaining(alwaysThrows); |
53 |
> |
c.spliterator().forEachRemaining(alwaysThrows); |
54 |
> |
assertFalse(c.spliterator().tryAdvance(alwaysThrows)); |
55 |
|
if (Queue.class.isAssignableFrom(impl.klazz())) { |
56 |
|
Queue q = (Queue) c; |
57 |
|
assertNull(q.peek()); |
63 |
|
assertNull(d.peekLast()); |
64 |
|
assertNull(d.pollFirst()); |
65 |
|
assertNull(d.pollLast()); |
66 |
+ |
assertIteratorExhausted(d.descendingIterator()); |
67 |
|
} |
68 |
|
} |
69 |
|
|
104 |
|
|
105 |
|
public void testNoSuchElementExceptions() { |
106 |
|
Collection c = impl.emptyCollection(); |
107 |
+ |
assertThrows( |
108 |
+ |
NoSuchElementException.class, |
109 |
+ |
() -> c.iterator().next()); |
110 |
|
|
111 |
|
if (Queue.class.isAssignableFrom(impl.klazz())) { |
112 |
|
Queue q = (Queue) c; |
123 |
|
() -> d.getLast(), |
124 |
|
() -> d.removeFirst(), |
125 |
|
() -> d.removeLast(), |
126 |
< |
() -> d.pop()); |
126 |
> |
() -> d.pop(), |
127 |
> |
() -> d.descendingIterator().next()); |
128 |
|
} |
129 |
|
} |
130 |
|
|
131 |
< |
// public void testCollectionDebugFail() { fail(); } |
131 |
> |
// public void testCollectionDebugFail() { |
132 |
> |
// fail(impl.klazz().getSimpleName()); |
133 |
> |
// } |
134 |
|
} |