Skip to content

Commit

Permalink
Add test case for partition
Browse files Browse the repository at this point in the history
  • Loading branch information
GabTux committed Mar 26, 2024
1 parent f8cf33f commit 88b321d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/source/ppqsort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,20 @@ TEST(StaticInputs, EmptyContainer) {
ASSERT_THAT(in, ::testing::ContainerEq(std::vector<int>{}));
}

TEST(StaticInputs, TriggerSeqPartition) {
std::vector<int> in = {52, 0, 5, 1, 2, 3, 45, 8, 1, 10,
52, 0, 5, 1, 2, 3, 45, 8, 1, 10};
std::vector ref(in);
ppqsort::impl::cpp::ThreadPool<> threadpool(4);
auto res = ppqsort::impl::cpp::partition_right_branchless_par(in.begin(), in.end(), std::less<>(), 4, threadpool);
auto pivot = *res.first;
ASSERT_TRUE(std::is_partitioned(in.begin(), in.end(), [&](const int & i){ return i < pivot;}));
res = ppqsort::impl::cpp::partition_to_right_par(in.begin(), in.end(), std::less<>(), 4, threadpool);
pivot = *res.first;
ASSERT_TRUE(std::is_partitioned(in.begin(), in.end(), [&](const int & i){ return i < pivot;}));
}


TEST(Patterns, Ascending) {
for (auto const & size: sizes) {
std::vector<int> in(size);
Expand Down

0 comments on commit 88b321d

Please sign in to comment.