/** Test InsertionIndex.sort() on given array */
 public void testSelectionSort(int[] arr) {
   System.out.println(String.format("Selection sort on input: %s", Arrays.toString(arr)));
   SelectionSort.sort(arr);
   System.out.println(String.format("Result: %s", Arrays.toString(arr)));
   System.out.println();
   assertTrue(TestUtil.isArraySorted(arr));
 }
  @Test
  public void testRecursiveSort3() throws Exception {

    int a[] = new int[5];
    selectionSort.recursiveSort(a);
    assertEquals("[0,0,0,0,0]", ArrayHelper.arrayAsString(a));
  }
  @Test
  public void testRecursiveSort4() throws Exception {

    int a[] = {1, 5, 2, 7, 3};
    selectionSort.recursiveSort(a);
    assertEquals("[1,2,3,5,7]", ArrayHelper.arrayAsString(a));
  }
  @Test
  public void testRecursiveSort1() throws Exception {

    int a[] = null;
    selectionSort.recursiveSort(a);
    assertNull(a);
  }
예제 #5
0
 @Test
 public void testSelectionSort() {
   List<Integer> list = getRandomUnsortedList();
   testSort(list, SelectionSort.sort(list));
 }