Unit Testing 'BoundedArray'

In this lab, we will attempt to thoroughly unit test the sample class BoundedArray.

  1. Open the LabAssignments project.
  2. Create a new package called lab5.
  3. Create a new class, BoundedArray.
  4. Copy the code from here into this new class.
BoundedArray implements an array of integers with values between a specified minimum and maximum range. The code includes two methods and a constructor:
  1. public BoundedArray(int[] array, int minVal, int maxVal)
    The constructor takes in an integer array to be copied as its first argument. The second and the third arguments specify the inclusive range of valid values for all elements of the array.

  2. public boolean contains(int x)
    The contains method determines whether the value x exists win the array. The input argument 'x' is the number to be searched for.

  3. public static void main(String[] args)
    Many developers prefer writing the unit testing code for a class inside that class's main method. Please note that the 'real' main for the whole program should be in a separate Driver class.