summaryrefslogtreecommitdiff
path: root/libc/test/src/stdlib/quick_sort_test.cpp
diff options
context:
space:
mode:
authorNAKAMURA Takumi <geek4civic@gmail.com>2025-01-09 18:39:43 +0900
committerNAKAMURA Takumi <geek4civic@gmail.com>2025-01-09 18:39:43 +0900
commitc36c84047e92587931e74aea1b3d91342617400b (patch)
tree3d25b78796205b1f3f1ee5f9c55da298f6449ce8 /libc/test/src/stdlib/quick_sort_test.cpp
parent122393694892e7a718e8c612b5650388075e2833 (diff)
parentbdcf47e4bcb92889665825654bb80a8bbe30379e (diff)
Merge branch 'users/chapuni/cov/single/base' into users/chapuni/cov/single/condopusers/chapuni/cov/single/condop
Conflicts: clang/lib/CodeGen/CoverageMappingGen.cpp
Diffstat (limited to 'libc/test/src/stdlib/quick_sort_test.cpp')
-rw-r--r--libc/test/src/stdlib/quick_sort_test.cpp19
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);