diff options
Diffstat (limited to 'test/src/algo/test_ft_heapsort.c')
| -rw-r--r-- | test/src/algo/test_ft_heapsort.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/src/algo/test_ft_heapsort.c b/test/src/algo/test_ft_heapsort.c new file mode 100644 index 0000000..6c2c3fb --- /dev/null +++ b/test/src/algo/test_ft_heapsort.c @@ -0,0 +1,27 @@ +#include "libft_test.h" + +TEST_GROUP(ft_heapsort); + +TEST_SETUP(ft_heapsort) +{} + +TEST_TEAR_DOWN(ft_heapsort) +{} + +static int compar(const void *a, const void *b) +{ + return *(int*)a - *(int*)b; +} + +TEST(ft_heapsort, basic) +{ + TEST_IGNORE(); + int arr[] = {3, 4, 1, 2, 7, 189, -1, -134, 7, 1, 34}; + int sorted_arr[sizeof(arr)]; + + memcpy(sorted_arr, arr, sizeof(arr)); + qsort(sorted_arr, sizeof(arr) / sizeof(int), sizeof(int), compar); + + ft_heapsort(arr, sizeof(arr) / sizeof(int), sizeof(int), compar); + TEST_ASSERT_EQUAL_INT_ARRAY(sorted_arr, arr, sizeof(arr) / sizeof(int)); +} |
