Class ListIteratorTester<E extends @Nullable Object>
java.lang.Object
com.google.common.collect.testing.ListIteratorTester<E>
@GwtCompatible
@NullMarked
public abstract class ListIteratorTester<E extends @Nullable Object>
extends Object
A utility similar to
IteratorTester
for testing a ListIterator
against a known
good reference implementation. As with IteratorTester
, a concrete subclass must provide
target iterators on demand. It also requires three additional constructor parameters:
elementsToInsert
, the elements to be passed to set()
and add()
calls;
features
, the features supported by the iterator; and expectedElements
, the elements the
iterator should return in order.
The items in elementsToInsert
will be repeated if steps
is larger than the
number of provided elements.
- Author:
- Chris Povirk
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ListIteratorTester
(int steps, Iterable<E> elementsToInsert, Iterable<? extends IteratorFeature> features, Iterable<E> expectedElements, int startIndex) -
Method Summary
Modifier and TypeMethodDescriptionprotected final Iterable
<? extends com.google.common.collect.testing.AbstractIteratorTester.Stimulus<E, ? super ListIterator<E>>> 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> Returns a new target iterator each time it's called.final void
test()
Executes the test.protected void
Override this to verify anything after running a list of Stimuli.
-
Constructor Details
-
ListIteratorTester
-
-
Method Details
-
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
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.
-