@Test public void testSort() { HeapSort heapSort = new HeapSort(); int[] testArray = {50, 1, 0, -20, 123, 3, 434, 2, 3, 4, 5, 2, 556, 432, 4, 56}; try { int[] result = heapSort.Sort(testArray); Assert.assertEquals(true, IsSorted(result)); } catch (NullPointerException e) { System.out.println("Caught an unexpected NullPointerException"); fail("Caught an unexpected NullPointerException"); } }
@Test public void testSortNullArray() { HeapSort heapSort = new HeapSort(); int[] testArray = null; try { int[] result = heapSort.Sort(testArray); } catch (NullPointerException e) { System.out.println("Caught an expected NullPointerReference"); // Bullshit code. boolean result = true; Assert.assertEquals(true, result); } }