Testing General Cases

This may be obvious, but you should always test your program with several general cases. These should be very similar to what your program will encounter when actually running. General test cases make an important assumption that the class invariants and the preconditionss are met. You will find the following general test case for the constructor in the main method of SearchArray.java.

//test case to check general values of the constructor
System.out.println("General test case for constructor");
int[] testArray4={-5,-6,0,-1,3,6,7,-2,2,3,4,7,-8};
s=new SearchArray(testArray4, -9, 10);

The general test case above in the main method passes a valid range of elements in the array and expects the object to be initiated without any errors.

Objective 3 for this lab

Write a few general test cases for the search() method in the following section of the void main() method.
/*
 * General test case(s) for search()
 */

NOTE:: There may be more than one generic test case for the search method. One of these test cases may be a simple case where the element 'x' is indeed present in the array. The other general test case could be when the array does not contain that element.
Also, once a bug is found with the help of these unit tests, one should go back to the method being tested and make the appropriate changes to it. For this example, once you run multiple general test cases, you might encounter a bug in the search() method which you would want to fix.