Skip to content

Commit 01e66d6

Browse files
Remove inline comments from is_sorted_projection test
1 parent f91eb8d commit 01e66d6

1 file changed

Lines changed: 0 additions & 39 deletions

File tree

libs/core/algorithms/tests/unit/algorithms/is_sorted_projection.cpp

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@
44
// Distributed under the Boost Software License, Version 1.0. (See accompanying
55
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
66

7-
// Regression test: hpx::is_sorted, hpx::is_sorted_until, and
8-
// hpx::is_partitioned did not expose a projection parameter in their CPO
9-
// (tag_fallback_invoke) overloads, despite the internal algorithm
10-
// implementations fully supporting projections. This file validates that
11-
// all three algorithms accept a projection with seq and par policies.
12-
137
#include <hpx/algorithm.hpp>
148
#include <hpx/init.hpp>
159
#include <hpx/modules/testing.hpp>
@@ -19,153 +13,120 @@
1913
#include <utility>
2014
#include <vector>
2115

22-
// ---------------------------------------------------------------------------
23-
// is_sorted with projection
24-
// ---------------------------------------------------------------------------
2516
void test_is_sorted_projection()
2617
{
2718
using namespace hpx::execution;
2819
using element = std::pair<int, int>;
2920

30-
// sorted by .second: 1, 3, 5, 8
3121
std::vector<element> sorted_c = {{10, 1}, {20, 3}, {30, 5}, {40, 8}};
32-
// NOT sorted by .second: 1, 5, 3, 8
3322
std::vector<element> unsorted_c = {{10, 1}, {20, 5}, {30, 3}, {40, 8}};
3423

3524
auto proj = [](element const& p) { return p.second; };
3625

37-
// sequential, no policy
3826
HPX_TEST(hpx::is_sorted(
3927
sorted_c.begin(), sorted_c.end(), std::less<int>{}, proj));
4028
HPX_TEST(!hpx::is_sorted(
4129
unsorted_c.begin(), unsorted_c.end(), std::less<int>{}, proj));
4230

43-
// seq policy
4431
HPX_TEST(hpx::is_sorted(
4532
seq, sorted_c.begin(), sorted_c.end(), std::less<int>{}, proj));
4633
HPX_TEST(!hpx::is_sorted(
4734
seq, unsorted_c.begin(), unsorted_c.end(), std::less<int>{}, proj));
4835

49-
// par policy
5036
HPX_TEST(hpx::is_sorted(
5137
par, sorted_c.begin(), sorted_c.end(), std::less<int>{}, proj));
5238
HPX_TEST(!hpx::is_sorted(
5339
par, unsorted_c.begin(), unsorted_c.end(), std::less<int>{}, proj));
5440

55-
// par(task) policy
5641
HPX_TEST(hpx::is_sorted(
5742
par(task), sorted_c.begin(), sorted_c.end(), std::less<int>{}, proj)
5843
.get());
5944
HPX_TEST(!hpx::is_sorted(
6045
par(task), unsorted_c.begin(), unsorted_c.end(), std::less<int>{}, proj)
6146
.get());
6247

63-
// empty range always returns true
6448
HPX_TEST(hpx::is_sorted(
6549
par, sorted_c.begin(), sorted_c.begin(), std::less<int>{}, proj));
66-
// single element range always returns true
6750
HPX_TEST(hpx::is_sorted(
6851
par, sorted_c.begin(), sorted_c.begin() + 1, std::less<int>{}, proj));
6952
}
7053

71-
// ---------------------------------------------------------------------------
72-
// is_sorted_until with projection
73-
// ---------------------------------------------------------------------------
7454
void test_is_sorted_until_projection()
7555
{
7656
using namespace hpx::execution;
7757
using element = std::pair<int, int>;
7858

79-
// sorted by .second: 1, 3, 8; then unsorted at index 3 (value 5)
8059
std::vector<element> c = {{10, 1}, {20, 3}, {30, 8}, {40, 5}, {50, 9}};
8160

8261
auto proj = [](element const& p) { return p.second; };
8362

84-
// sequential, no policy
8563
auto it_seq =
8664
hpx::is_sorted_until(c.begin(), c.end(), std::less<int>{}, proj);
8765
HPX_TEST(it_seq != c.end());
8866
HPX_TEST_EQ(it_seq->second, 5);
8967

90-
// seq policy
9168
auto it_seq2 =
9269
hpx::is_sorted_until(seq, c.begin(), c.end(), std::less<int>{}, proj);
9370
HPX_TEST(it_seq2 != c.end());
9471
HPX_TEST_EQ(it_seq2->second, 5);
9572

96-
// par policy
9773
auto it_par =
9874
hpx::is_sorted_until(par, c.begin(), c.end(), std::less<int>{}, proj);
9975
HPX_TEST(it_par != c.end());
10076
HPX_TEST_EQ(it_par->second, 5);
10177

102-
// par(task) policy
10378
auto it_task = hpx::is_sorted_until(
10479
par(task), c.begin(), c.end(), std::less<int>{}, proj)
10580
.get();
10681
HPX_TEST(it_task != c.end());
10782
HPX_TEST_EQ(it_task->second, 5);
10883

109-
// fully sorted range should return end
11084
std::vector<element> fully_sorted = {{10, 1}, {20, 3}, {30, 5}};
11185
auto it_end = hpx::is_sorted_until(
11286
par, fully_sorted.begin(), fully_sorted.end(), std::less<int>{}, proj);
11387
HPX_TEST(it_end == fully_sorted.end());
11488

115-
// empty range should return end (begin == end)
11689
auto it_empty = hpx::is_sorted_until(par, fully_sorted.begin(),
11790
fully_sorted.begin(), std::less<int>{}, proj);
11891
HPX_TEST(it_empty == fully_sorted.begin());
11992
}
12093

121-
// ---------------------------------------------------------------------------
122-
// is_partitioned with projection
123-
// ---------------------------------------------------------------------------
12494
void test_is_partitioned_projection()
12595
{
12696
using namespace hpx::execution;
12797
using element = std::pair<int, int>;
12898

129-
// partitioned by .second % 2 == 0: all even seconds first, then odd
130-
// second values: 2, 4, 1, 3 => partitioned (even before odd)
13199
std::vector<element> partitioned_c = {{10, 2}, {20, 4}, {30, 1}, {40, 3}};
132-
// NOT partitioned by .second % 2 == 0: 2, 1, 4, 3
133100
std::vector<element> not_partitioned_c = {
134101
{10, 2}, {20, 1}, {30, 4}, {40, 3}};
135102

136103
auto proj = [](element const& p) { return p.second; };
137104
auto pred = [](int v) { return v % 2 == 0; };
138105

139-
// sequential, no policy
140106
HPX_TEST(hpx::is_partitioned(
141107
partitioned_c.begin(), partitioned_c.end(), pred, proj));
142108
HPX_TEST(!hpx::is_partitioned(
143109
not_partitioned_c.begin(), not_partitioned_c.end(), pred, proj));
144110

145-
// seq policy
146111
HPX_TEST(hpx::is_partitioned(
147112
seq, partitioned_c.begin(), partitioned_c.end(), pred, proj));
148113
HPX_TEST(!hpx::is_partitioned(
149114
seq, not_partitioned_c.begin(), not_partitioned_c.end(), pred, proj));
150115

151-
// par policy
152116
HPX_TEST(hpx::is_partitioned(
153117
par, partitioned_c.begin(), partitioned_c.end(), pred, proj));
154118
HPX_TEST(!hpx::is_partitioned(
155119
par, not_partitioned_c.begin(), not_partitioned_c.end(), pred, proj));
156120

157-
// par(task) policy
158121
HPX_TEST(hpx::is_partitioned(
159122
par(task), partitioned_c.begin(), partitioned_c.end(), pred, proj)
160123
.get());
161124
HPX_TEST(!hpx::is_partitioned(par(task), not_partitioned_c.begin(),
162125
not_partitioned_c.end(), pred, proj)
163126
.get());
164127

165-
// empty range is always partitioned
166128
HPX_TEST(hpx::is_partitioned(
167129
par, partitioned_c.begin(), partitioned_c.begin(), pred, proj));
168-
// single element range is always partitioned
169130
HPX_TEST(hpx::is_partitioned(
170131
par, partitioned_c.begin(), partitioned_c.begin() + 1, pred, proj));
171132
}

0 commit comments

Comments
 (0)