Esempio n. 1
0
 private List<Integer> getRandomUnsortedList() {
   List<Integer> list = getRandomList();
   while (BaseSort.isSorted(list)) {
     list = getRandomList();
   }
   return list;
 }
Esempio n. 2
0
 private void testSort(List<Integer> list, List<Integer> sortedList) {
   assertEquals("sort() returned an array of different length.", list.size(), sortedList.size());
   assertEquals(
       "sort() didn't return a permutation of same elements of the original list.",
       true,
       isPermutation(list, sortedList));
   assertEquals("sort() didn't return the sorted list.", true, BaseSort.isSorted(sortedList));
   assertNotSame("sort() changed the original array.", sortedList, list);
 }
Esempio n. 3
0
 @Test
 public void testIsNotSorted() {
   Integer[] arr = {0, -5, -12, 1000, 56, 4, 3, 1};
   List<Integer> list = Arrays.asList(arr);
   assertEquals("List should not be returned as sorted.", false, BaseSort.isSorted(list));
 }
Esempio n. 4
0
 @Test
 public void testIsSorted() {
   Integer[] arr = {-12, -5, 0, 1, 3, 4, 56, 1000};
   List<Integer> list = Arrays.asList(arr);
   assertEquals("List should be returned as sorted.", true, BaseSort.isSorted(list));
 }