comparison src/share/vm/utilities/quickSort.cpp @ 3981:e807478bf9ca

7091366: re-enable quicksort tests Summary: Added extern "C" to make it build with JDK6 compilers Reviewed-by: jwilhelm, kvn
author brutisso
date Mon, 26 Sep 2011 10:14:30 +0200
parents 8ab2f4108d20
children 6fd81579526f
comparison
equal deleted inserted replaced
3980:8229bd737950 3981:e807478bf9ca
52 return -1; 52 return -1;
53 } 53 }
54 return 1; 54 return 1;
55 } 55 }
56 56
57 static int test_stdlib_comparator(const void* a, const void* b) { 57 extern "C" {
58 int ai = *(int*)a; 58 static int test_stdlib_comparator(const void* a, const void* b) {
59 int bi = *(int*)b; 59 int ai = *(int*)a;
60 if (ai == bi) { 60 int bi = *(int*)b;
61 return 0; 61 if (ai == bi) {
62 } 62 return 0;
63 if (ai < bi) { 63 }
64 return -1; 64 if (ai < bi) {
65 } 65 return -1;
66 return 1; 66 }
67 return 1;
68 }
67 } 69 }
68 70
69 void QuickSort::print_array(const char* prefix, int* array, int length) { 71 void QuickSort::print_array(const char* prefix, int* array, int length) {
70 tty->print("%s:", prefix); 72 tty->print("%s:", prefix);
71 for (int i = 0; i < length; i++) { 73 for (int i = 0; i < length; i++) {
90 sort<int, C>(arrayToSort, length, comparator, idempotent); 92 sort<int, C>(arrayToSort, length, comparator, idempotent);
91 return compare_arrays(arrayToSort, expectedResult, length); 93 return compare_arrays(arrayToSort, expectedResult, length);
92 } 94 }
93 95
94 bool QuickSort::test_quick_sort() { 96 bool QuickSort::test_quick_sort() {
95 #if 0
96 tty->print_cr("test_quick_sort\n"); 97 tty->print_cr("test_quick_sort\n");
97 { 98 {
98 int* test_array = NULL; 99 int* test_array = NULL;
99 int* expected_array = NULL; 100 int* expected_array = NULL;
100 assert(sort_and_compare(test_array, expected_array, 0, test_comparator), "Empty array not handled"); 101 assert(sort_and_compare(test_array, expected_array, 0, test_comparator), "Empty array not handled");
211 assert(compare_arrays(test_array, expected_array, length), "Sorting already sorted array changed order of elements - not idempotent"); 212 assert(compare_arrays(test_array, expected_array, length), "Sorting already sorted array changed order of elements - not idempotent");
212 213
213 delete[] test_array; 214 delete[] test_array;
214 delete[] expected_array; 215 delete[] expected_array;
215 } 216 }
217 return true;
218 }
219
216 #endif 220 #endif
217 return true;
218 }
219
220 #endif