Skip to content

Commit 4724f60

Browse files
committed
fix up heap operation tests
1 parent dfd3c3f commit 4724f60

File tree

4 files changed

+12
-41
lines changed

4 files changed

+12
-41
lines changed

libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/make.heap/ranges_make_heap.pass.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,7 @@ static_assert(!HasMakeHeapR<UncheckedRange<const int*>>); // Doesn't satisfy `so
6161
template <std::size_t N, class T, class Iter>
6262
constexpr void verify_heap(const std::array<T, N>& heapified, Iter last, std::array<T, N> expected) {
6363
assert(heapified == expected);
64-
assert(last == heapified.end());
65-
assert(std::is_heap(heapified.begin(), heapified.end()));
66-
}
67-
68-
template <std::size_t N, class T, class Iter>
69-
constexpr void verify_heap_iterator(const std::array<T, N>& heapified, Iter last, std::array<T, N> expected) {
70-
assert(heapified == expected);
71-
assert(base(last) == heapified.data() + heapified.size());
64+
assert(std::to_address(base(last)) == heapified.data() + heapified.size());
7265
assert(std::is_heap(heapified.begin(), heapified.end()));
7366
}
7467

@@ -80,7 +73,7 @@ constexpr void test_one(const std::array<int, N> input, std::array<int, N> expec
8073
auto e = Sent(Iter(heapified.data() + heapified.size()));
8174

8275
std::same_as<Iter> decltype(auto) last = std::ranges::make_heap(b, e);
83-
verify_heap_iterator(heapified, last, expected);
76+
verify_heap(heapified, last, expected);
8477
}
8578

8679
{ // (range) overload.
@@ -90,7 +83,7 @@ constexpr void test_one(const std::array<int, N> input, std::array<int, N> expec
9083
auto range = std::ranges::subrange(b, e);
9184

9285
std::same_as<Iter> decltype(auto) last = std::ranges::make_heap(range);
93-
verify_heap_iterator(heapified, last, expected);
86+
verify_heap(heapified, last, expected);
9487
}
9588
}
9689

libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/pop.heap/ranges_pop_heap.pass.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,7 @@ static_assert(!HasPopHeapR<UncheckedRange<const int*>>); // Doesn't satisfy `sor
6161
template <std::size_t N, class T, class Iter>
6262
constexpr void verify_heap(const std::array<T, N>& heapified, Iter last, std::array<T, N> expected) {
6363
assert(heapified == expected);
64-
assert(last == heapified.end());
65-
assert(std::is_heap(heapified.begin(), heapified.end() - 1));
66-
assert(*std::max_element(heapified.begin(), heapified.end()) == heapified.back());
67-
}
68-
69-
template <std::size_t N, class T, class Iter>
70-
constexpr void verify_heap_iterator(const std::array<T, N>& heapified, Iter last, std::array<T, N> expected) {
71-
assert(heapified == expected);
72-
assert(base(last) == heapified.data() + heapified.size());
64+
assert(std::to_address(base(last)) == heapified.data() + heapified.size());
7365
assert(std::is_heap(heapified.begin(), heapified.end() - 1));
7466
assert(*std::max_element(heapified.begin(), heapified.end()) == heapified.back());
7567
}
@@ -85,7 +77,7 @@ constexpr void test_one(const std::array<int, N> input, std::array<int, N> expec
8577
auto e = Sent(Iter(heapified.data() + heapified.size()));
8678

8779
std::same_as<Iter> decltype(auto) last = std::ranges::pop_heap(b, e);
88-
verify_heap_iterator(heapified, last, expected);
80+
verify_heap(heapified, last, expected);
8981
}
9082

9183
{ // (range) overload.
@@ -95,7 +87,7 @@ constexpr void test_one(const std::array<int, N> input, std::array<int, N> expec
9587
auto range = std::ranges::subrange(b, e);
9688

9789
std::same_as<Iter> decltype(auto) last = std::ranges::pop_heap(range);
98-
verify_heap_iterator(heapified, last, expected);
90+
verify_heap(heapified, last, expected);
9991
}
10092
}
10193

libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/push.heap/ranges_push_heap.pass.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,7 @@ static_assert(!HasPushHeapR<UncheckedRange<const int*>>); // Doesn't satisfy `so
6161
template <std::size_t N, class T, class Iter>
6262
constexpr void verify_heap(const std::array<T, N>& heapified, Iter last, std::array<T, N> expected) {
6363
assert(heapified == expected);
64-
assert(last == heapified.end());
65-
assert(std::is_heap(heapified.begin(), heapified.end()));
66-
}
67-
68-
template <std::size_t N, class T, class Iter>
69-
constexpr void verify_heap_iterator(const std::array<T, N>& heapified, Iter last, std::array<T, N> expected) {
70-
assert(heapified == expected);
71-
assert(base(last) == heapified.data() + heapified.size());
64+
assert(std::to_address(base(last)) == heapified.data() + heapified.size());
7265
assert(std::is_heap(heapified.begin(), heapified.end()));
7366
}
7467

@@ -84,7 +77,7 @@ constexpr void test_one(const std::array<int, N> input, std::array<int, N> expec
8477
auto e = Sent(Iter(heapified.data() + heapified.size()));
8578

8679
std::same_as<Iter> decltype(auto) last = std::ranges::push_heap(b, e);
87-
verify_heap_iterator(heapified, last, expected);
80+
verify_heap(heapified, last, expected);
8881
}
8982

9083
{ // (range) overload.
@@ -94,7 +87,7 @@ constexpr void test_one(const std::array<int, N> input, std::array<int, N> expec
9487
auto range = std::ranges::subrange(b, e);
9588

9689
std::same_as<Iter> decltype(auto) last = std::ranges::push_heap(range);
97-
verify_heap_iterator(heapified, last, expected);
90+
verify_heap(heapified, last, expected);
9891
}
9992
}
10093

libcxx/test/std/algorithms/alg.sorting/alg.heap.operations/sort.heap/ranges_sort_heap.pass.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,7 @@ static_assert(!HasSortHeapR<UncheckedRange<const int*>>); // Doesn't satisfy `so
6262
template <std::size_t N, class T, class Iter>
6363
constexpr void verify_sorted(const std::array<T, N>& sorted, Iter last, std::array<T, N> expected) {
6464
assert(sorted == expected);
65-
assert(last == sorted.end());
66-
assert(std::is_sorted(sorted.begin(), sorted.end()));
67-
}
68-
69-
template <std::size_t N, class T, class Iter>
70-
constexpr void verify_sorted_iterator(const std::array<T, N>& sorted, Iter last, std::array<T, N> expected) {
71-
assert(sorted == expected);
72-
assert(base(last) == sorted.data() + sorted.size());
65+
assert(std::to_address(base(last)) == sorted.data() + sorted.size());
7366
assert(std::is_sorted(sorted.begin(), sorted.end()));
7467
}
7568

@@ -83,7 +76,7 @@ constexpr void test_one(const std::array<int, N> input, std::array<int, N> expec
8376
auto e = Sent(Iter(sorted.data() + sorted.size()));
8477

8578
std::same_as<Iter> decltype(auto) last = std::ranges::sort_heap(b, e);
86-
verify_sorted_iterator(sorted, last, expected);
79+
verify_sorted(sorted, last, expected);
8780
}
8881

8982
{ // (range) overload.
@@ -93,7 +86,7 @@ constexpr void test_one(const std::array<int, N> input, std::array<int, N> expec
9386
auto range = std::ranges::subrange(b, e);
9487

9588
std::same_as<Iter> decltype(auto) last = std::ranges::sort_heap(range);
96-
verify_sorted_iterator(sorted, last, expected);
89+
verify_sorted(sorted, last, expected);
9790
}
9891
}
9992

0 commit comments

Comments
 (0)