Practice for the SWE 437 final exam

Design and implement tests for the following method findRoots().

  1. Input Space Partitioning
  2. Draw the control flow graph for findRoots().
  3. Label your control flow graph with predicates for each decision. Make sure you include a clear mapping of your graph to the source code (this can be on the graph or using a key).
  4. Graph-based Testing
  5. Logic-based Testing
public class root
{
   private static double Root1, Root2;

   // Finds the quadratic root, A must be non-zero
   public boolean findRoots(int A, int B, int C) {
      double D;
      boolean Result;
      D = (double)(B*B) - (double)(4.0*A*C);
      if (D < 0.0)
      {
         Result = false;
         return(Result);
      }
      Root1 = (double) ((-B + Math.sqrt(D)) / (2.0*A));
      Root2 = (double) ((-B - Math.sqrt(D)) / (2.0*A));
      Result = true;
      return(Result);
   } // End method findRoots

   public double getRoot1() {
      return(Root1);
   }

   public double getRoot2() {
      return(Root2);
   }
} // End class root

Exercises in the AO Book (more practice)

Input Space Partitioning:
Graph-based Testing:
Logic-based testing