Class ListIteratorTester<E>
- java.lang.Object
-
- com.google.common.collect.testing.ListIteratorTester<E>
-
@GwtCompatible public abstract class ListIteratorTester<E> extends Object
A utility similar toIteratorTesterfor testing aListIteratoragainst a known good reference implementation. As withIteratorTester, a concrete subclass must provide target iterators on demand. It also requires three additional constructor parameters:elementsToInsert, the elements to be passed toset()andadd()calls;features, the features supported by the iterator; andexpectedElements, the elements the iterator should return in order.The items in
elementsToInsertwill be repeated ifstepsis larger than the number of provided elements.- Author:
- Chris Povirk
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedListIteratorTester(int steps, Iterable<E> elementsToInsert, Iterable<? extends IteratorFeature> features, Iterable<E> expectedElements, int startIndex)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected Iterable<? extends com.google.common.collect.testing.AbstractIteratorTester.Stimulus<E,? super ListIterator<E>>>getStimulusValues()I'd like to make this a parameter to the constructor, but I can't because the stimulus instances refer tothis.protected abstract ListIterator<E>newTargetIterator()Returns a new target iterator each time it's called.voidtest()Executes the test.voidtestForEachRemaining()protected voidverify(List<E> elements)Override this to verify anything after running a list of Stimuli.
-
-
-
Constructor Detail
-
ListIteratorTester
protected ListIteratorTester(int steps, Iterable<E> elementsToInsert, Iterable<? extends IteratorFeature> features, Iterable<E> expectedElements, int startIndex)
-
-
Method Detail
-
getStimulusValues
protected final Iterable<? extends com.google.common.collect.testing.AbstractIteratorTester.Stimulus<E,? super ListIterator<E>>> getStimulusValues()
I'd like to make this a parameter to the constructor, but I can't because the stimulus instances refer tothis.
-
newTargetIterator
protected abstract ListIterator<E> 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
protected void verify(List<E> elements)
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()
-
-