Class ListIteratorTester<E>


  • @GwtCompatible
    public abstract class ListIteratorTester<E>
    extends java.lang.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.

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected ListIteratorTester​(int steps, java.lang.Iterable<E> elementsToInsert, java.lang.Iterable<? extends IteratorFeature> features, java.lang.Iterable<E> expectedElements, int startIndex)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.Iterable<? extends com.google.common.collect.testing.AbstractIteratorTester.Stimulus<E,​? super java.util.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.
      protected abstract java.util.ListIterator<E> newTargetIterator()
      Returns a new target iterator each time it's called.
      void test()
      Executes the test.
      protected void verify​(java.util.List<E> elements)
      Override this to verify anything after running a list of Stimuli.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ListIteratorTester

        protected ListIteratorTester​(int steps,
                                     java.lang.Iterable<E> elementsToInsert,
                                     java.lang.Iterable<? extends IteratorFeature> features,
                                     java.lang.Iterable<E> expectedElements,
                                     int startIndex)
    • Method Detail

      • getStimulusValues

        protected final java.lang.Iterable<? extends com.google.common.collect.testing.AbstractIteratorTester.Stimulus<E,​? super java.util.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 java.util.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​(java.util.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.