-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temporary ranges support for timsort
This notably allows timsort to accept an std::span.
- Loading branch information
Showing
3 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright (c) 2024 Morwenn. | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
#include <algorithm> | ||
#include <numeric> | ||
#include <random> | ||
#include <span> | ||
#include <vector> | ||
#include <catch2/catch_test_macros.hpp> | ||
#include <gfx/timsort.hpp> | ||
#include "test_helpers.hpp" | ||
|
||
TEST_CASE( "support for temporary types" ) { | ||
SECTION( "timsort over std::span" ) { | ||
std::vector<int> vec(50); | ||
std::iota(vec.begin(), vec.end(), -25); | ||
test_helpers::shuffle(vec); | ||
|
||
gfx::timsort(std::span(vec)); | ||
CHECK(std::ranges::is_sorted(vec)); | ||
} | ||
} |