src/share/vm/utilities/quickSort.cpp

changeset 3335
3c648b9ad052
parent 3266
6fd81579526f
child 4962
6f817ce50129
equal deleted inserted replaced
3328:6d7d0790074d 3335:3c648b9ad052
91 bool QuickSort::sort_and_compare(int* arrayToSort, int* expectedResult, int length, C comparator, bool idempotent) { 91 bool QuickSort::sort_and_compare(int* arrayToSort, int* expectedResult, int length, C comparator, bool idempotent) {
92 sort<int, C>(arrayToSort, length, comparator, idempotent); 92 sort<int, C>(arrayToSort, length, comparator, idempotent);
93 return compare_arrays(arrayToSort, expectedResult, length); 93 return compare_arrays(arrayToSort, expectedResult, length);
94 } 94 }
95 95
96 bool QuickSort::test_quick_sort() { 96 void QuickSort::test_quick_sort() {
97 tty->print_cr("test_quick_sort");
98 { 97 {
99 int* test_array = NULL; 98 int* test_array = NULL;
100 int* expected_array = NULL; 99 int* expected_array = NULL;
101 assert(sort_and_compare(test_array, expected_array, 0, test_comparator), "Empty array not handled"); 100 assert(sort_and_compare(test_array, expected_array, 0, test_comparator), "Empty array not handled");
102 } 101 }
212 assert(compare_arrays(test_array, expected_array, length), "Sorting already sorted array changed order of elements - not idempotent"); 211 assert(compare_arrays(test_array, expected_array, length), "Sorting already sorted array changed order of elements - not idempotent");
213 212
214 delete[] test_array; 213 delete[] test_array;
215 delete[] expected_array; 214 delete[] expected_array;
216 } 215 }
217 return true;
218 } 216 }
219 217
220 #endif 218 #endif

mercurial