Merge branch 'quicksort' of UBB/sort into master

This commit is contained in:
2018-11-13 12:03:12 -03:00
committed by Gitea
6 changed files with 79 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
OBJ+=../src/random.o ../src/bubble_sort.o ../src/timer.o ../src/quick_sort.o
all: test

View File

@@ -19,6 +19,7 @@
#include <unistd.h>
#include "random.h"
#include "bubble_sort.h"
#include "quick_sort.h"
static int *test_case;
static int *test_array;
@@ -106,6 +107,23 @@ int main(int argc, char **argv) {
}
pass = 1;
// Test quick sort
fprintf(stdout, "\tquick sort: ");
fflush(stdout);
quick_sort(test_array, n);
for (i = 0; i < n; i++) {
if (test_array[i] != qarray[i] && pass) {
fprintf(stdout, "fail\n");
failed++;
pass = 0;
}
}
if (pass) {
fprintf(stdout, "pass\n");
passed++;
}
pass = 1;
fprintf(stdout, "%d tests passed\n", passed);
fprintf(stdout, "%d tests failed\n", failed);