E
- the type of element returned by the iteratorI
- the type of the iterator (Iterator
or ListIterator
)abstract class AbstractIteratorTester<E,I extends java.util.Iterator<E>>
extends java.lang.Object
IteratorTester
and ListIteratorTester
.Modifier and Type | Class and Description |
---|---|
private static interface |
AbstractIteratorTester.IteratorOperation |
static class |
AbstractIteratorTester.KnownOrder |
protected class |
AbstractIteratorTester.MultiExceptionListIterator
Quasi-implementation of
ListIterator that works from a list of elements and a set of
features to support (from the enclosing AbstractIteratorTester instance). |
private static class |
AbstractIteratorTester.PermittedMetaException
Meta-exception thrown by
AbstractIteratorTester.MultiExceptionListIterator instead of
throwing any particular exception type. |
(package private) static class |
AbstractIteratorTester.Stimulus<E,T extends java.util.Iterator<E>> |
private static class |
AbstractIteratorTester.UnknownElementException |
Constructor and Description |
---|
AbstractIteratorTester(int steps,
java.lang.Iterable<E> elementsToInsertIterable,
java.lang.Iterable<? extends IteratorFeature> features,
java.lang.Iterable<E> expectedElements,
AbstractIteratorTester.KnownOrder knownOrder,
int startIndex) |
Modifier and Type | Method and Description |
---|---|
private void |
compareResultsForThisListOfStimuli() |
protected abstract java.lang.Iterable<? extends AbstractIteratorTester.Stimulus<E,? super I>> |
getStimulusValues()
I'd like to make this a parameter to the constructor, but I can't because the stimulus
instances refer to
this . |
private <T extends java.util.Iterator<E>> |
internalExecuteAndCompare(T reference,
T target,
AbstractIteratorTester.IteratorOperation method)
Apply this method to both iterators and return normally only if both produce the same response.
|
(package private) java.util.List<AbstractIteratorTester.Stimulus<E,java.util.Iterator<E>>> |
iteratorStimuli() |
(package private) java.util.List<AbstractIteratorTester.Stimulus<E,java.util.ListIterator<E>>> |
listIteratorStimuli() |
private AbstractIteratorTester.IteratorOperation |
newAddMethod() |
private AbstractIteratorTester.IteratorOperation |
newSetMethod() |
protected abstract I |
newTargetIterator()
Returns a new target iterator each time it's called.
|
private void |
recurse(int level) |
private static java.util.List<java.lang.Object> |
subListCopy(java.lang.Object[] source,
int size) |
void |
test()
Executes the test.
|
void |
testForEachRemaining() |
protected void |
verify(java.util.List<E> elements)
Override this to verify anything after running a list of Stimuli.
|
private AbstractIteratorTester.Stimulus<E,? super I extends java.util.Iterator<E>>[] stimuli
private final java.util.Iterator<E> elementsToInsert
private final java.util.Set<IteratorFeature> features
private final java.util.List<E> expectedElements
private final int startIndex
private final AbstractIteratorTester.KnownOrder knownOrder
private static final AbstractIteratorTester.IteratorOperation REMOVE_METHOD
private static final AbstractIteratorTester.IteratorOperation NEXT_METHOD
private static final AbstractIteratorTester.IteratorOperation PREVIOUS_METHOD
AbstractIteratorTester.Stimulus<E,java.util.Iterator<E>> hasNext
AbstractIteratorTester.Stimulus<E,java.util.Iterator<E>> next
AbstractIteratorTester.Stimulus<E,java.util.Iterator<E>> remove
AbstractIteratorTester.Stimulus<E,java.util.ListIterator<E>> hasPrevious
AbstractIteratorTester.Stimulus<E,java.util.ListIterator<E>> nextIndex
AbstractIteratorTester.Stimulus<E,java.util.ListIterator<E>> previousIndex
AbstractIteratorTester.Stimulus<E,java.util.ListIterator<E>> previous
AbstractIteratorTester.Stimulus<E,java.util.ListIterator<E>> add
AbstractIteratorTester.Stimulus<E,java.util.ListIterator<E>> set
AbstractIteratorTester(int steps, java.lang.Iterable<E> elementsToInsertIterable, java.lang.Iterable<? extends IteratorFeature> features, java.lang.Iterable<E> expectedElements, AbstractIteratorTester.KnownOrder knownOrder, int startIndex)
protected abstract java.lang.Iterable<? extends AbstractIteratorTester.Stimulus<E,? super I>> getStimulusValues()
this
.protected abstract I newTargetIterator()
protected void verify(java.util.List<E> elements)
For example, verify that calls to remove() actually removed the correct elements.
elements
- the expected elements passed to the constructor, as mutated by remove()
, set()
, and add()
callspublic final void test()
public void testForEachRemaining()
private void recurse(int level)
private void compareResultsForThisListOfStimuli()
private static java.util.List<java.lang.Object> subListCopy(java.lang.Object[] source, int size)
private <T extends java.util.Iterator<E>> void internalExecuteAndCompare(T reference, T target, AbstractIteratorTester.IteratorOperation method)
private final AbstractIteratorTester.IteratorOperation newAddMethod()
private final AbstractIteratorTester.IteratorOperation newSetMethod()
java.util.List<AbstractIteratorTester.Stimulus<E,java.util.Iterator<E>>> iteratorStimuli()
java.util.List<AbstractIteratorTester.Stimulus<E,java.util.ListIterator<E>>> listIteratorStimuli()