[libcxx-commits] [libcxx] [libc++][test] Fix copy-paste damage in `ranges.rotate_copy.pass.cpp` (PR #74544)
Stephan T. Lavavej via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Dec 5 17:17:31 PST 2023
https://github.com/StephanTLavavej created https://github.com/llvm/llvm-project/pull/74544
Found while running libc++'s tests with MSVC's STL.
`ranges::rotate_copy` takes `forward_iterator`s as this test's comment banner correctly depicts. However, this test had bogus assertions expecting that `ranges::rotate_copy` would be constrained away for not-quite-**bidi** iterators. @philnik777 confirmed that these were copy-paste relics from the `ranges::reverse_copy` test (which does need bidi).
I fixed this by replacing the assertions with the test types that aren't quite forward iterators/ranges. Additionally, I noticed that the top-level `test()` function was missing coverage with the weakest possible `forward_iterator<int*>`.
Note: The fact that this test was passing for you is quite curious. From a quick glance, I don't see a problem with the libc++ product code constraints, so I'm not sure where the behavior difference is.
>From 0f6102c6890e263fd78c98e475b90bd54f63d09f Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Tue, 5 Dec 2023 17:04:32 -0800
Subject: [PATCH] Fix copy-paste damage in ranges.rotate_copy.pass.cpp.
---
.../alg.rotate/ranges.rotate_copy.pass.cpp | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/libcxx/test/std/algorithms/alg.modifying.operations/alg.rotate/ranges.rotate_copy.pass.cpp b/libcxx/test/std/algorithms/alg.modifying.operations/alg.rotate/ranges.rotate_copy.pass.cpp
index 1f18d787c2f4c..58b0f75d9b5f2 100644
--- a/libcxx/test/std/algorithms/alg.modifying.operations/alg.rotate/ranges.rotate_copy.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.modifying.operations/alg.rotate/ranges.rotate_copy.pass.cpp
@@ -34,16 +34,16 @@ template <class Range, class Out = int*>
concept HasRotateCopyR = requires(Range range, Out out) { std::ranges::rotate_copy(range, nullptr, out); };
static_assert(HasRotateCopyIt<int*>);
-static_assert(!HasRotateCopyIt<BidirectionalIteratorNotDerivedFrom>);
-static_assert(!HasRotateCopyIt<BidirectionalIteratorNotDecrementable>);
+static_assert(!HasRotateCopyIt<ForwardIteratorNotDerivedFrom>);
+static_assert(!HasRotateCopyIt<ForwardIteratorNotIncrementable>);
static_assert(!HasRotateCopyIt<int*, SentinelForNotSemiregular>);
static_assert(!HasRotateCopyIt<int*, SentinelForNotWeaklyEqualityComparableWith>);
static_assert(!HasRotateCopyIt<int*, OutputIteratorNotIndirectlyWritable>);
static_assert(!HasRotateCopyIt<int*, OutputIteratorNotInputOrOutputIterator>);
static_assert(HasRotateCopyR<UncheckedRange<int*>>);
-static_assert(!HasRotateCopyR<BidirectionalRangeNotDerivedFrom>);
-static_assert(!HasRotateCopyR<BidirectionalRangeNotDecrementable>);
+static_assert(!HasRotateCopyR<ForwardRangeNotDerivedFrom>);
+static_assert(!HasRotateCopyR<ForwardRangeNotIncrementable>);
static_assert(!HasRotateCopyR<UncheckedRange<int*, SentinelForNotSemiregular>>);
static_assert(!HasRotateCopyR<UncheckedRange<int*>, OutputIteratorNotIndirectlyWritable>);
static_assert(!HasRotateCopyR<UncheckedRange<int*>, OutputIteratorNotInputOrOutputIterator>);
@@ -112,6 +112,7 @@ constexpr void test_out_iterators() {
}
constexpr bool test() {
+ test_out_iterators<forward_iterator<int*>>();
test_out_iterators<bidirectional_iterator<int*>>();
test_out_iterators<random_access_iterator<int*>>();
test_out_iterators<contiguous_iterator<int*>>();
More information about the libcxx-commits
mailing list