merge changes

This commit is contained in:
2018-11-13 12:20:01 -03:00
6 changed files with 83 additions and 3 deletions

View File

@@ -2,7 +2,7 @@ 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
OBJ+=../src/random.o ../src/bubble_sort.o ../src/timer.o ../src/count_sort.o ../src/quick_sort.o
all: test

View File

@@ -20,6 +20,7 @@
#include "random.h"
#include "bubble_sort.h"
#include "count_sort.h"
#include "quick_sort.h"
static int *test_case;
static int *test_array;
@@ -126,6 +127,25 @@ int main(int argc, char **argv) {
passed++;
}
// Test quick sort
pass = 1;
memcpy(test_array, test_case, sizeof(int) * n);
fprintf(stdout, "\tquick sort: ");
fflush(stdout);
quick_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);