mardi 25 juillet 2017

Provide statement and branch coverage testing for the following codes?Draw the flow chart? Provide test case cases for full coverage

Provide statement and branch coverage testing for the following codes?Draw the flow chart? Provide test case cases for full coverage.

public static int oddOrPos(int[] x) {
//Effects: if x==null throw NullPointerException
//  else return the number of elements in x that
//      are either odd or positive (or both)
  int count = 0;
  for (int i=0; i < x.length; i++)
  {
    if (x[i]% 2 == 1 || x[i] > 0)
    {
      count++;
    }
  }
  return count;
}
  // test: x=[-3, -2, 0, 1, 4]
  //      Expected = 3

Aucun commentaire:

Enregistrer un commentaire