aboutsummaryrefslogtreecommitdiff
path: root/tests/test_sort.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_sort.c')
-rw-r--r--tests/test_sort.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_sort.c b/tests/test_sort.c
new file mode 100644
index 0000000..d996df2
--- /dev/null
+++ b/tests/test_sort.c
@@ -0,0 +1,20 @@
+#include "sort.c"
+
+#include <assert.h>
+#include <stdio.h>
+
+int main() {
+ printf("[TEST] sort\n");
+
+ int arr[] = {2,4,5,7,4,6,7,8,8,5,4};
+ int arrlen = sizeof(arr) / sizeof(int);
+ Int_qsort(arr, arrlen);
+ for (int i = 0; i < arrlen - 1; i++) {
+ assert(arr[i] <= arr[i+1]);
+ }
+ Int_qsort(arr, arrlen);
+ for (int i = 0; i < arrlen - 1; i++) {
+ assert(arr[i] <= arr[i+1]);
+ }
+ printf("[PASS] sort\n");
+}