Question: Define tests for change scenarios. INTERFACE: public interface IndexedUnsortedList extends Iterable { /** * Adds the specified element to the front of this list. *
Define tests for change scenarios.
INTERFACE:
public interface IndexedUnsortedList extends Iterable { /** * Adds the specified element to the front of this list. * * @param element the element to be added to the front of this list */ public void addToFront(T element);
/** * Adds the specified element to the rear of this list. * * @param element the element to be added to the rear of this list */ public void addToRear(T element);
/** * Adds the specified element to the rear of this list. * * @param element the element to be added to the rear of the list */ public void add(T element);
/** * Adds the specified element after the specified target. * * @param element the element to be added after the target * @param target the target is the item that the element will be added after * @throws NoSuchElementException if target element is not in this list */ public void addAfter(T element, T target); /** * Inserts the specified element at the specified index. * * @param index the index into the array to which the element is to be inserted. * @param element the element to be inserted into the array * @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index > size) */ public void add(int index, T element);
/** * Removes and returns the first element from this list. * * @return the first element from this list * @throws NoSuchElementException if list contains no elements */ public T removeFirst();
/** * Removes and returns the last element from this list. * * @return the last element from this list * @throws NoSuchElementException if list contains no elements */ public T removeLast();
/** * Removes and returns the first element from the list matching the specified element. * * @param element the element to be removed from the list * @return removed element * @throws NoSuchElementException if element is not in this list */ public T remove(T element);
/** * Removes and returns the element at the specified index. * * @param index the index of the element to be retrieved * @return the element at the given index * @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size) */ public T remove(int index); /** * Replace the element at the specified index with the given element. * * @param index the index of the element to replace * @param element the replacement element to be set into the list * @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size) */ public void set(int index, T element);
/** * Returns a reference to the element at the specified index. * * @param index the index to which the reference is to be retrieved from * @return the element at the specified index * @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size) */ public T get(int index);
/** * Returns the index of the first element from the list matching the specified element. * * @param element the element for the index is to be retrieved * @return the integer index for this element or -1 if element is not in the list */ public int indexOf(T element);
/** * Returns a reference to the first element in this list. * * @return a reference to the first element in this list * @throws NoSuchElementException if list contains no elements */ public T first();
/** * Returns a reference to the last element in this list. * * @return a reference to the last element in this list * @throws NoSuchElementException if list contains no elements */ public T last();
/** * Returns true if this list contains the specified target element. * * @param target the target that is being sought in the list * @return true if the list contains this element, else false */ public boolean contains(T target);
/** * Returns true if this list contains no elements. * * @return true if this list contains no elements */ public boolean isEmpty();
/** * Returns the number of elements in this list. * * @return the integer representation of number of elements in this list */ public int size();
/** * Returns a string representation of this list. * * @return a string representation of this list */ public String toString();
/** * Returns an Iterator for the elements in this list. * * @return an Iterator over the elements in this list */ public Iterator iterator();
/** * Returns a ListIterator for the elements in this list. * * @return a ListIterator over the elements in this list * * @throws UnsupportedOperationException if not implemented */ public ListIterator listIterator();
/** * Returns a ListIterator for the elements in this list, with * the iterator positioned before the specified index. * * @return a ListIterator over the elements in this list * * @throws UnsupportedOperationException if not implemented */ public ListIterator listIterator(int startingIndex); }
EXAMPLE TEST FOR SCENARIO:
1) no list -> constructor -> [ ] Tests: addToFront(A) throws no Exception addToRear(A) throws no Exception addAfter(A, B) throws NoSuchElementException add(A) throws no Exception add(-1, A) throws IndexOutOfBoundsException add(0, A) throws no Exception add(1, A) throws IndexOutOfBoundsException removeFirst() throws NoSuchElementException removeLast() throws NoSuchElementException remove(A) throws NoSuchElementException remove(-1) throws IndexOutOfBoundsException remove(0) throws IndexOutOfBoundsException set(-1, A) throws IndexOutOfBoundsException set(0, A) throws IndexOutOfBoundsException get(-1) throws IndexOutOfBoundsException get(0) throws IndexOutOfBoundsException indexOf(A) returns -1 first() throws NoSuchElementException last() throws NoSuchElementException contains(A) returns false isEmpty() returns true size() returns 0 iterator() returns an Iterator reference listIterator() throws UnsupportedOperationException listIterator(0) throws UnsupportedOperationException toString returns "[ ]"
CHANGE SCENARIO IN QUESTION:
A) [ ] -> addToFront(A) -> [A]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
