add missed radix sort tests

This commit is contained in:
2026-05-06 05:47:11 -05:00
parent 9b56a240d1
commit b6b2500944

View File

@@ -1,4 +1,7 @@
#include "../include/types.h" #include "../include/types.h"
#include "../include/radix.h"
#include "../include/lsort.h"
#include <stdio.h>
int test_array_i_append(lsort_array_i* array) { int test_array_i_append(lsort_array_i* array) {
@@ -24,11 +27,54 @@ int test_array_i_swap(lsort_array_i* array) {
return 0; return 0;
} }
int main(void) { int test_append_swap() {
lsort_array_i array = {0}; lsort_array_i array_append_swap = {0};
if (test_array_i_append(&array)) return 1; if (test_array_i_append(&array_append_swap)) return 1;
if (test_array_i_swap(&array)) return 2; if (test_array_i_swap(&array_append_swap)) return 1;
lsort_array_i array_sort_check = {0};
lsort_array_i_append(&array_sort_check, 1);
lsort_array_i_append(&array_sort_check, 5);
lsort_array_i_append(&array_sort_check, 7);
lsort_array_i_append(&array_sort_check, 8);
lsort_array_i_append(&array_sort_check, 15);
lsort_array_i_append(&array_sort_check, 28);
if (check_sorted(&array_sort_check) == 1) return 1;
lsort_array_i_swap(&array_sort_check, 2, 4);
lsort_array_i_swap(&array_sort_check, 0, 3);
if (check_sorted(&array_sort_check) == 0) return 1;
return 0; return 0;
} }
int test_radix_sort() {
lsort_array_i array_radix = {0};
lsort_array_i_append(&array_radix, -2);
lsort_array_i_append(&array_radix, -15);
lsort_array_i_append(&array_radix, 25);
lsort_array_i_append(&array_radix, 56);
lsort_array_i_append(&array_radix, 23);
lsort_array_i_append(&array_radix, -222);
lsort_array_i_append(&array_radix, -58);
lsort_array_i array_radix_return = {0};
lsort_radix(&array_radix, &array_radix_return);
if (check_sorted(&array_radix_return) != 0) return 1;
return 0;
}
int main(void) {
if (
test_append_swap() ||
test_radix_sort()
) return 1;
printf("Test completed successfully.\n");
return 0;
}