Class AbstractIteratorTester<E,I extends Iterator<E>>
java.lang.Object
com.google.common.collect.testing.AbstractIteratorTester<E,I>
- Type Parameters:
E
- the type of element returned by the iteratorI
- the type of the iterator (Iterator
orListIterator
)
- Direct Known Subclasses:
IteratorTester
,ListIteratorTester
Most of the logic for
IteratorTester
and ListIteratorTester
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static interface
static enum
protected final class
Quasi-implementation ofListIterator
that works from a list of elements and a set of features to support (from the enclosingAbstractIteratorTester
instance).private static class
Meta-exception thrown byAbstractIteratorTester.MultiExceptionListIterator
instead of throwing any particular exception type.(package private) static class
AbstractIteratorTester.Stimulus<E,
T extends Iterator<E>> private static final class
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) AbstractIteratorTester.Stimulus
<E, ListIterator<E>> private final Set
<IteratorFeature> (package private) AbstractIteratorTester.Stimulus
<E, Iterator<E>> (package private) AbstractIteratorTester.Stimulus
<E, ListIterator<E>> private final AbstractIteratorTester.KnownOrder
(package private) AbstractIteratorTester.Stimulus
<E, Iterator<E>> private static final AbstractIteratorTester.IteratorOperation
(package private) AbstractIteratorTester.Stimulus
<E, ListIterator<E>> (package private) AbstractIteratorTester.Stimulus
<E, ListIterator<E>> private static final AbstractIteratorTester.IteratorOperation
(package private) AbstractIteratorTester.Stimulus
<E, ListIterator<E>> (package private) AbstractIteratorTester.Stimulus
<E, Iterator<E>> private static final AbstractIteratorTester.IteratorOperation
(package private) AbstractIteratorTester.Stimulus
<E, ListIterator<E>> private final int
private AbstractIteratorTester.Stimulus<E,
? super I>[] -
Constructor Summary
ConstructorsConstructorDescriptionAbstractIteratorTester
(int steps, Iterable<E> elementsToInsertIterable, Iterable<? extends IteratorFeature> features, Iterable<E> expectedElements, AbstractIteratorTester.KnownOrder knownOrder, int startIndex) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
protected abstract Iterable
<? extends AbstractIteratorTester.Stimulus<E, ? super I>> I'd like to make this a parameter to the constructor, but I can't because the stimulus instances refer tothis
.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) List
<AbstractIteratorTester.Stimulus<E, Iterator<E>>> (package private) List
<AbstractIteratorTester.Stimulus<E, ListIterator<E>>> private final AbstractIteratorTester.IteratorOperation
private final AbstractIteratorTester.IteratorOperation
protected abstract I
Returns a new target iterator each time it's called.private void
recurse
(int level) subListCopy
(Object[] source, int size) final void
test()
Executes the test.void
protected void
Override this to verify anything after running a list of Stimuli.
-
Field Details
-
stimuli
-
elementsToInsert
-
features
-
expectedElements
-
startIndex
private final int startIndex -
knownOrder
-
REMOVE_METHOD
-
NEXT_METHOD
-
PREVIOUS_METHOD
-
hasNext
AbstractIteratorTester.Stimulus<E,Iterator<E>> hasNext -
next
-
remove
AbstractIteratorTester.Stimulus<E,Iterator<E>> remove -
hasPrevious
AbstractIteratorTester.Stimulus<E,ListIterator<E>> hasPrevious -
nextIndex
AbstractIteratorTester.Stimulus<E,ListIterator<E>> nextIndex -
previousIndex
AbstractIteratorTester.Stimulus<E,ListIterator<E>> previousIndex -
previous
AbstractIteratorTester.Stimulus<E,ListIterator<E>> previous -
add
-
set
-
-
Constructor Details
-
AbstractIteratorTester
AbstractIteratorTester(int steps, Iterable<E> elementsToInsertIterable, Iterable<? extends IteratorFeature> features, Iterable<E> expectedElements, AbstractIteratorTester.KnownOrder knownOrder, int startIndex)
-
-
Method Details
-
getStimulusValues
protected abstract 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 tothis
. -
newTargetIterator
Returns a new target iterator each time it's called. This is the iterator you are trying to test. This must return an Iterator that returns the expected elements passed to the constructor in the given order. Warning: it is not enough to simply pull multiple iterators from the same source Iterable, unless that Iterator is unmodifiable. -
verify
Override this to verify anything after running a list of Stimuli.For example, verify that calls to remove() actually removed the correct elements.
- Parameters:
elements
- the expected elements passed to the constructor, as mutated byremove()
,set()
, andadd()
calls
-
test
public final void test()Executes the test. -
testForEachRemaining
public void testForEachRemaining() -
recurse
private void recurse(int level) -
compareResultsForThisListOfStimuli
private void compareResultsForThisListOfStimuli() -
subListCopy
-
internalExecuteAndCompare
private <T extends Iterator<E>> void internalExecuteAndCompare(T reference, T target, AbstractIteratorTester.IteratorOperation method) Apply this method to both iterators and return normally only if both produce the same response.- See Also:
-
newAddMethod
-
newSetMethod
-
iteratorStimuli
List<AbstractIteratorTester.Stimulus<E,Iterator<E>>> iteratorStimuli() -
listIteratorStimuli
List<AbstractIteratorTester.Stimulus<E,ListIterator<E>>> listIteratorStimuli()
-