blob: aef419aa4398bf6b91b53ed538442a28091c9d06 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include "../prng/prng.h"
#include "../prng/types.h"
#include "test.h"
#include "insertion.h"
#include "selection.h"
#include "merge.h"
int main(void){
uint64_t T[SIZE];
uint64_t res1[SIZE], res2[SIZE], res3[SIZE];
int i;
srand(42);
for (i = 0 ; i < SIZE ; i++)
T[i] = randlong();
/* insertion sort */
if (insert_sort(res1, T) < 0) return -1;
/* selection sort */
if (select_sort(res2, T) < 0) return -2;
/* merge sort */
if (merge_sort(res3, T) < 0) return -3;
/* We should have: res1[i] == res2[i] == res3[i] */
for (i = 0 ; i < SIZE ; i++){
if (!(res1[i] == res2[i] && res2[i] == res3[i]))
return -4;
}
return 0;
}
|