diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2023-01-20 15:24:45 +0000 |
---|---|---|
committer | Sam Atkins <atkinssj@gmail.com> | 2023-01-20 17:45:33 +0000 |
commit | 93ca5d47726c42418509b2374fb9af56b40a2e3a (patch) | |
tree | 645e4fd22bb8e755c5599d8a59f50587da453363 /Tests | |
parent | 4b525fc98e7850ccc4526493b242603d7e28aa69 (diff) | |
download | serenity-93ca5d47726c42418509b2374fb9af56b40a2e3a.zip |
Tests: Use AK::shuffle() for shuffling
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/LibC/TestQsort.cpp | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/Tests/LibC/TestQsort.cpp b/Tests/LibC/TestQsort.cpp index c2e7e6434a..dbc0b46b65 100644 --- a/Tests/LibC/TestQsort.cpp +++ b/Tests/LibC/TestQsort.cpp @@ -38,15 +38,6 @@ static int calc_payload_for_pos(size_t pos) return pos ^ (pos << 8) ^ (pos << 16) ^ (pos << 24); } -static void shuffle_vec(Vector<SortableObject>& test_objects) -{ - for (size_t i = 0; i < test_objects.size() * 3; ++i) { - auto i1 = get_random_uniform(test_objects.size()); - auto i2 = get_random_uniform(test_objects.size()); - swap(test_objects[i1], test_objects[i2]); - } -} - TEST_CASE(quick_sort) { // Generate vector of SortableObjects in sorted order, with payloads determined by their sorted positions @@ -56,7 +47,7 @@ TEST_CASE(quick_sort) } for (size_t i = 0; i < NUM_RUNS; i++) { // Shuffle the vector, then sort it again - shuffle_vec(test_objects); + shuffle(test_objects); qsort(test_objects.data(), test_objects.size(), sizeof(SortableObject), compare_sortable_object); // Check that the objects are sorted by key for (auto i = 0u; i + 1 < test_objects.size(); ++i) { |