Agregación de Quick_Sort
This commit is contained in:
@@ -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
|
||||
|
||||
|
18
test/test.c
18
test/test.c
@@ -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;
|
||||
@@ -104,6 +105,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);
|
||||
|
||||
|
Reference in New Issue
Block a user