public class ArrayUtilsTest {
    static void getMaxTest() {
        int[] input; // input data to ArrayUtils.getMax()
        int output = 0; // output from ArrayUtils.getMax()
        // this output variable must be initialized, as it used, but not
        // assigned in this scope
        int desiredOutput; // the desired output from ArrayUtils.getMax()
        boolean error; // used to indicate if ArrayUtils.getMax() is wrong

        // test 1: null input array
        System.out.print("Test 1: ");
        input = null;
        error = true;
        try {
            ArrayUtils.getMax(input);
        } catch (IllegalArgumentException e) {
            error = false;
        } finally {
            System.out.println((error) ? "ERROR" : "OK");
        }

        // test 2: empty array
        System.out.print("Test 2: ");
        input = new int[0];
        error = true;
        try {
            ArrayUtils.getMax(input);
        } catch (IllegalArgumentException e) {
            error = false;
        } finally {
            System.out.println((error) ? "ERROR" : "OK");
        }

        // test 3: simple 1 element array
        System.out.print("Test 3: ");
        input = new int[] { -3 };
        desiredOutput = -3;
        error = false;
        try {
            output = ArrayUtils.getMax(input);
        } catch (IllegalArgumentException e) {
            error = true;
        } finally {
            if (! error) {
                error = (output != desiredOutput);
            }
            System.out.println((error) ? "ERROR" : "OK");
        }

        // test 4: array of 7 elements
        System.out.print("Test 4: ");
        input = new int[] { 3, 1, 4, 1, 5, 9, 2 };
        desiredOutput = 9;
        error = false;
        try {
            output = ArrayUtils.getMax(input);
        } catch (IllegalArgumentException e) {
            error = true;
        } finally {
            if (! error) {
                error = (output != desiredOutput);
            }
            System.out.println((error) ? "ERROR" : "OK");
        }

        // test 5: array of 5 elements, all equal
        System.out.print("Test 5: ");
        input = new int[] { 2, 2, 2, 2, 2 };
        desiredOutput = 2;
        error = false;
        try {
            output = ArrayUtils.getMax(input);
        } catch (IllegalArgumentException e) {
            error = true;
        } finally {
            if (! error) {
                error = (output != desiredOutput);
            }
            System.out.println((error) ? "ERROR" : "OK");
        }
    }

    public static void main(String[] args) {
        getMaxTest();
    }
}