Class ListIteratorTester<E>


  • @GwtCompatible
    public abstract class ListIteratorTester<E>
    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
    • 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 to this.
      • newTargetIterator

        protected abstract ListIterator<EnewTargetIterator()
        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 by remove(), set(), and add() calls
      • test

        public final void test()
        Executes the test.