diff options
Diffstat (limited to 'libc/test/src/stdlib/quick_sort_test.cpp')
| -rw-r--r-- | libc/test/src/stdlib/quick_sort_test.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/libc/test/src/stdlib/quick_sort_test.cpp b/libc/test/src/stdlib/quick_sort_test.cpp index d6bf77ebfd40..2832c855370b 100644 --- a/libc/test/src/stdlib/quick_sort_test.cpp +++ b/libc/test/src/stdlib/quick_sort_test.cpp @@ -1,4 +1,4 @@ -//===-- Unittests for quick sort ------------------------------------------===// +//===-- Unittests for qsort -----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -7,10 +7,19 @@ //===----------------------------------------------------------------------===// #include "SortingTest.h" -#include "src/stdlib/quick_sort.h" +#include "src/stdlib/qsort_util.h" -void sort(const LIBC_NAMESPACE::internal::Array &array) { - LIBC_NAMESPACE::internal::quick_sort(array); +void quick_sort(void *array, size_t array_size, size_t elem_size, + int (*compare)(const void *, const void *)) { + constexpr bool USE_QUICKSORT = true; + + const auto is_less = [compare](const void *a, + const void *b) noexcept -> bool { + return compare(a, b) < 0; + }; + + LIBC_NAMESPACE::internal::unstable_sort_impl<USE_QUICKSORT>( + array, array_size, elem_size, is_less); } -LIST_SORTING_TESTS(QuickSort, sort); +LIST_SORTING_TESTS(Qsort, quick_sort); |
