SWE 637 In Class Exercise Number 12


Consider a Java method, and also a "refactored" version.
    public static > T min (List list) {
       if (list.size() == 0) {
          throw new IllegalArgumentException("min: Empty list");
       }

       T result = list.get(0);

       for (T comp: list) {
           if (comp.compareTo(result) < 0) {    // throws NPE, CCE as needed
               result = comp;
           }
       }
       return result;
    }
    public static > T min (List list) {
       if (list.size() == 0) {
          throw new IllegalArgumentException ("Min.min");
       }

       Iterator itr = list.iterator();
       T result = itr.next();

       while (itr.hasNext())
       {   // throws NPE, CCE as needed
           T comp = itr.next();
           if (comp.compareTo (result) < 0) {
               result = comp;
           }
       }
       return result;
    }
Consider these possible tests:
  t1:  list = [];            expected = IAE
  t2:  list = null;          expected = NPE
  t3:  list = [null];        expected = NPE
  t4:  list = ["cat"];       expected = "cat"
  t5:  list = ["cat","dog"]; expected = "cat"
  t6:  list = ["dog","cat"]; expected = "cat"
Work through a reasonable google-based model for this example supposing:
  1. The initial test set is empty.
  2. The initial test set is {t4}
  3. The initial test set is {t4,t5}
  4. The initial test set is {t5,t6}
Consider possible mutations (where appropriate) and classify as "useful" (or not).