import components.sequence.Sequence; /** * JUnit test fixture for {@code Sequence}'s constructor and kernel * methods. * * @author Put your name here * */ public abstract class SequenceTest { /** * Invokes the appropriate {@code Sequence} constructor for the * implementation under test and returns the result. * * @return the new sequence * @ensures constructorTest = <> */ protected abstract Sequence constructorTest(); /** * Invokes the appropriate {@code Sequence} constructor for the reference * implementation and returns the result. * * @return the new sequence * @ensures constructorRef = <> */ protected abstract Sequence constructorRef(); /** * * Creates and returns a {@code Sequence} of the implementation * under test type with the given entries. * * @param args * the entries for the sequence * @return the constructed sequence * @ensures createFromArgsTest = [entries in args] */ private Sequence createFromArgsTest(String... args) { Sequence sequence = this.constructorTest(); for (String s : args) { sequence.add(sequence.length(), s); } return sequence; } /** * * Creates and returns a {@code Sequence} of the reference * implementation type with the given entries. * * @param args * the entries for the sequence * @return the constructed sequence * @ensures createFromArgsRef = [entries in args] */ private Sequence createFromArgsRef(String... args) { Sequence sequence = this.constructorRef(); for (String s : args) { sequence.add(sequence.length(), s); } return sequence; } // TODO - add test cases for constructor, add, remove, and length }