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 (IteratororListIterator)
- Direct Known Subclasses:
IteratorTester,ListIteratorTester
Most of the logic for
IteratorTester and ListIteratorTester.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static interfacestatic enumprotected final classQuasi-implementation ofListIteratorthat works from a list of elements and a set of features to support (from the enclosingAbstractIteratorTesterinstance).private static classMeta-exception thrown byAbstractIteratorTester.MultiExceptionListIteratorinstead of throwing any particular exception type.(package private) static classAbstractIteratorTester.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 intprivate 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 voidprotected 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.IteratorOperationprivate final AbstractIteratorTester.IteratorOperationprotected abstract IReturns a new target iterator each time it's called.private voidrecurse(int level) subListCopy(Object[] source, int size) final voidtest()Executes the test.voidprotected voidOverride 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()
-