aboutsummaryrefslogtreecommitdiffstats
path: root/test/mppa/sort/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/mppa/sort/main.c')
-rw-r--r--test/mppa/sort/main.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/mppa/sort/main.c b/test/mppa/sort/main.c
new file mode 100644
index 00000000..aef419aa
--- /dev/null
+++ b/test/mppa/sort/main.c
@@ -0,0 +1,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;
+}