Search

16 October, 2017

A program sorts an array of integer. Write down the code that tests the sorting algorithms written in the program.

@Test
public void testSort() {
  String[] arr = {4, 5, 3};
  String[] expected = {3, 4, 5};
  sort(arr); // or whatever your sort method call it like
  assertArrayEquals(expected, arr);
}

1. Set up an array.
2. Set up another array with the expected result.
3. Call swap on the first array
4. use an assertArrayEquals call.