aboutsummaryrefslogtreecommitdiff
path: root/tests/test_sort.c
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2025-06-08 21:11:11 +0800
committerMistivia <i@mistivia.com>2025-06-08 21:11:11 +0800
commit9b98985d16e92e728d28d6c8ce4294f8a7230d9d (patch)
treea706b6812711ba432e97ad326a8aa535dc9ee4c2 /tests/test_sort.c
parent445fe6e07e3b8f5343f4a728d7ad96fbbfd0345e (diff)
generic pq
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");
+}