Work in groups.
First, we'll do a dataflow exercise: Graph III on page 130.
Obtain test requirements from the graph model: node, edge, edge pair, prime-path.
Develop tests that satisfy the test requirements.
Next is a Graph testing exercise.
Consider the following code:
/**
* Returns the mininum element in a list
* @param list Comparable list of elements to search
* @return the minimum element in the list
* @throws NullPointerException if list is null or
* if any list elements are null
* @throws ClassCastException if list elements are not mutually comparable
* @throws IllegalArgumentException if list is empty
*/
public static <T extends Comparable<? super T>> T min (List<? extends T> list) {
Iterator<? extends T> itr = list.iterator();
if (itr.hasNext() == false) {
throw new IllegalArgumentException("min: Empty list");
}
T result = itr.next();
if (result == null) throw new NullPointerException("Min.min");
while (itr.hasNext()) {
T comp = itr.next();
if (comp.compareTo(result) < 0) { // throws NPE, CCE as needed
result = comp;
}
}
return result;
}
Develop a graph model of the code.