Merge branch 'fixmem' of UBB/sort into master
This commit is contained in:
commit
751e6d9cb4
13
test/test.c
13
test/test.c
@ -221,22 +221,16 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
// Test bitonic sort with 2^n
|
// Test bitonic sort with 2^n
|
||||||
pass = 1;
|
pass = 1;
|
||||||
int *bitonic_test_case = malloc(sizeof(int) * n2);
|
|
||||||
if (bitonic_test_case == NULL) {
|
|
||||||
fprintf(stderr, "Error: Out of heap space!\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
int *bitonic_test_array = malloc(sizeof(int) * n2);
|
int *bitonic_test_array = malloc(sizeof(int) * n2);
|
||||||
if (bitonic_test_array == NULL) {
|
if (bitonic_test_array == NULL) {
|
||||||
fprintf(stderr, "Error: Out of heap space!\n");
|
fprintf(stderr, "Error: Out of heap space!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n2; i++) {
|
||||||
bitonic_test_case[i] = gen_rand(-1000000, 1000000);
|
bitonic_test_array[i] = gen_rand(-1000000, 1000000);
|
||||||
}
|
}
|
||||||
memcpy(qarray, bitonic_test_case, sizeof(int) * n2);
|
memcpy(qarray, bitonic_test_array, sizeof(int) * n2);
|
||||||
qsort(qarray, n2, sizeof(int), compar);
|
qsort(qarray, n2, sizeof(int), compar);
|
||||||
memcpy(bitonic_test_array, bitonic_test_case, sizeof(int) * n2);
|
|
||||||
fprintf(stdout, "\tbitonic sort 2^n: ");
|
fprintf(stdout, "\tbitonic sort 2^n: ");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
bitonic_sort(bitonic_test_array, n2);
|
bitonic_sort(bitonic_test_array, n2);
|
||||||
@ -252,6 +246,7 @@ int main(int argc, char **argv) {
|
|||||||
fprintf(stdout, "pass\n");
|
fprintf(stdout, "pass\n");
|
||||||
passed++;
|
passed++;
|
||||||
}
|
}
|
||||||
|
free(bitonic_test_array);
|
||||||
|
|
||||||
fprintf(stdout, "%d tests passed\n", passed);
|
fprintf(stdout, "%d tests passed\n", passed);
|
||||||
fprintf(stdout, "%d tests failed\n", failed);
|
fprintf(stdout, "%d tests failed\n", failed);
|
||||||
|
Loading…
Reference in New Issue
Block a user