resolve conflicts

This commit is contained in:
2018-11-17 11:55:26 -03:00
9 changed files with 301 additions and 38 deletions

View File

@@ -2,7 +2,8 @@ CC=gcc
CFLAGS=-Wall -I../src/include -DDEBUG -g
SRC=test.c
OBJ=$(SRC:.c=.o)
OBJ+=../src/random.o ../src/bubble_sort.o ../src/timer.o ../src/count_sort.o ../src/quick_sort.o ../src/bitonic_sort.o ../src/selection_sort.o
OBJ+=../src/random.o ../src/bubble_sort.o ../src/timer.o ../src/count_sort.o ../src/quick_sort.o ../src/merge_sort.o ../src/bitonic_sort.o ../src/selection_sort.o
all: test

View File

@@ -20,9 +20,10 @@
#include "random.h"
#include "bubble_sort.h"
#include "count_sort.h"
#include "quick_sort.h"
#include "bitonic_sort.h"
#include "selection_sort.h"
#include "bitonic_sort.h"
#include "merge_sort.h"
#include "quick_sort.h"
static int *test_case;
static int *test_array;
@@ -51,7 +52,7 @@ void cleanup() {
* El programa de test
*/
int main(int argc, char **argv) {
int n = 65536;
int n = 32768;
int i;
int gen;
int pass;
@@ -59,8 +60,20 @@ int main(int argc, char **argv) {
int failed = 0;
test_case = malloc(sizeof(int) * n);
if (test_case == NULL) {
fprintf(stderr, "Error: Out of heap space!\n");
exit(1);
}
qarray = malloc(sizeof(int) * n);
if (qarray == NULL) {
fprintf(stderr, "Error: Out of heap space!\n");
exit(1);
}
test_array = malloc(sizeof(int) * n);
if (test_array == NULL) {
fprintf(stderr, "Error: Out of heap space!\n");
exit(1);
}
atexit(cleanup);
@@ -148,7 +161,7 @@ int main(int argc, char **argv) {
passed++;
}
//test bitonic
// Test bitonic sort
pass = 1;
memcpy(test_array, test_case, sizeof(int) * n);
fprintf(stdout, "\tbitonic sort: ");
@@ -167,7 +180,7 @@ int main(int argc, char **argv) {
passed++;
}
// Test selection sort
// Test selection sort
pass = 1;
memcpy(test_array, test_case, sizeof(int) * n);
fprintf(stdout, "\tselection sort: ");
@@ -186,6 +199,25 @@ int main(int argc, char **argv) {
passed++;
}
// Test merge sort
pass = 1;
memcpy(test_array, test_case, sizeof(int) * n);
fprintf(stdout, "\tmerge sort: ");
fflush(stdout);
merge_sort(test_array, n);
for (i = 0; i < n; i++) {
if (test_array[i] != qarray[i]) {
fprintf(stdout, "fail\n");
failed++;
pass = 0;
break;
}
}
if (pass) {
fprintf(stdout, "pass\n");
passed++;
}
fprintf(stdout, "%d tests passed\n", passed);
fprintf(stdout, "%d tests failed\n", failed);