aboutsummaryrefslogtreecommitdiff
path: root/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy_backward.pass.cpp
diff options
context:
space:
mode:
authorKonstantin Varlamov <varconst@apple.com>2022-08-02 22:22:49 -0700
committerTom Stellard <tstellar@redhat.com>2022-08-05 01:04:08 -0700
commite38e97d804e64507fcc0a123038fceb4aab5590c (patch)
tree71758c707fae06fea8e502888f8d4f5b4adf25dd /libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy_backward.pass.cpp
parent33a5980f2f332e748c86c2a03757e078e967407b (diff)
[libc++][ranges] Fix the return value of `{copy,move}_backward`.
The return value for both of these algorithms is specified as ``` `{last, result - N}` for the overloads in namespace `ranges`. ``` But the current implementation instead returns `{first, result - N}`. Also add both algorithms to the relevant "robust" tests. Differential Revision: https://reviews.llvm.org/D130968 (cherry picked from commit f537a01d3989d37aafc050a92c74e69d35381f8c)
Diffstat (limited to 'libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy_backward.pass.cpp')
-rw-r--r--libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy_backward.pass.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy_backward.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy_backward.pass.cpp
index b75eced30b79..d99fa4888430 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy_backward.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy_backward.pass.cpp
@@ -65,7 +65,7 @@ constexpr void test_iterators() {
std::same_as<std::ranges::in_out_result<In, Out>> auto ret =
std::ranges::copy_backward(In(in.data()), Sent(In(in.data() + in.size())), Out(out.data() + out.size()));
assert(in == out);
- assert(base(ret.in) == in.data());
+ assert(base(ret.in) == in.data() + in.size());
assert(base(ret.out) == out.data());
}
{
@@ -75,7 +75,7 @@ constexpr void test_iterators() {
std::same_as<std::ranges::in_out_result<In, Out>> auto ret =
std::ranges::copy_backward(range, Out(out.data() + out.size()));
assert(in == out);
- assert(base(ret.in) == in.data());
+ assert(base(ret.in) == in.data() + in.size());
assert(base(ret.out) == out.data());
}
}
@@ -86,7 +86,7 @@ constexpr void test_iterators() {
std::array<int, 0> out;
auto ret =
std::ranges::copy_backward(In(in.data()), Sent(In(in.data() + in.size())), Out(out.data() + out.size()));
- assert(base(ret.in) == in.data());
+ assert(base(ret.in) == in.data() + in.size());
assert(base(ret.out) == out.data());
}
{
@@ -94,7 +94,7 @@ constexpr void test_iterators() {
std::array<int, 0> out;
auto range = std::ranges::subrange(In(in.data()), Sent(In(in.data() + in.size())));
auto ret = std::ranges::copy_backward(range, Out(out.data()));
- assert(base(ret.in) == in.data());
+ assert(base(ret.in) == in.data() + in.size());
assert(base(ret.out) == out.data());
}
}
@@ -143,7 +143,7 @@ constexpr bool test() {
std::array<int, 4> out;
std::same_as<std::ranges::in_out_result<int*, int*>> auto ret =
std::ranges::copy_backward(std::views::all(in), out.data() + out.size());
- assert(ret.in == in.data());
+ assert(ret.in == in.data() + in.size());
assert(ret.out == out.data());
assert(in == out);
}
@@ -163,7 +163,7 @@ constexpr bool test() {
std::array<CopyOnce, 4> in {};
std::array<CopyOnce, 4> out {};
auto ret = std::ranges::copy_backward(in.begin(), in.end(), out.end());
- assert(ret.in == in.begin());
+ assert(ret.in == in.end());
assert(ret.out == out.begin());
assert(std::all_of(out.begin(), out.end(), [](const auto& e) { return e.copied; }));
}
@@ -171,7 +171,7 @@ constexpr bool test() {
std::array<CopyOnce, 4> in {};
std::array<CopyOnce, 4> out {};
auto ret = std::ranges::copy_backward(in, out.end());
- assert(ret.in == in.begin());
+ assert(ret.in == in.end());
assert(ret.out == out.begin());
assert(std::all_of(out.begin(), out.end(), [](const auto& e) { return e.copied; }));
}
@@ -196,7 +196,7 @@ constexpr bool test() {
out[2].next = &out[1];
out[2].canCopy = true;
auto ret = std::ranges::copy_backward(in, out.end());
- assert(ret.in == in.begin());
+ assert(ret.in == in.end());
assert(ret.out == out.begin());
assert(out[0].canCopy);
assert(out[1].canCopy);
@@ -209,7 +209,7 @@ constexpr bool test() {
out[2].next = &out[1];
out[2].canCopy = true;
auto ret = std::ranges::copy_backward(in.begin(), in.end(), out.end());
- assert(ret.in == in.begin());
+ assert(ret.in == in.end());
assert(ret.out == out.begin());
assert(out[0].canCopy);
assert(out[1].canCopy);