1 | //===-- Unittests for heap sort -------------------------------------------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #include "SortingTest.h" |
10 | #include "src/stdlib/qsort_util.h" |
11 | |
12 | void heap_sort(void *array, size_t array_size, size_t elem_size, |
13 | int (*compare)(const void *, const void *)) { |
14 | |
15 | constexpr bool USE_QUICKSORT = false; |
16 | |
17 | const auto is_less = [compare](const void *a, |
18 | const void *b) noexcept -> bool { |
19 | return compare(a, b) < 0; |
20 | }; |
21 | |
22 | LIBC_NAMESPACE::internal::unstable_sort_impl<USE_QUICKSORT>( |
23 | array, array_size, elem_size, is_less); |
24 | } |
25 | |
26 | LIST_SORTING_TESTS(HeapSort, heap_sort); |
27 | |