[libcxx-commits] [libcxx] 2e9058c - [libc++][NFC] Update precondition comments when testing subspan assertions
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Apr 11 09:45:34 PDT 2023
Author: Louis Dionne
Date: 2023-04-11T17:45:12+01:00
New Revision: 2e9058ced9f154b972e0caac99bc20f284161250
URL: https://github.com/llvm/llvm-project/commit/2e9058ced9f154b972e0caac99bc20f284161250
DIFF: https://github.com/llvm/llvm-project/commit/2e9058ced9f154b972e0caac99bc20f284161250.diff
LOG: [libc++][NFC] Update precondition comments when testing subspan assertions
Added:
Modified:
libcxx/test/libcxx/containers/views/views.span/span.sub/assert.subspan.pass.cpp
libcxx/test/std/containers/views/views.span/span.sub/subspan.verify.cpp
Removed:
################################################################################
diff --git a/libcxx/test/libcxx/containers/views/views.span/span.sub/assert.subspan.pass.cpp b/libcxx/test/libcxx/containers/views/views.span/span.sub/assert.subspan.pass.cpp
index 10e54c1983ea9..a66ca5402f078 100644
--- a/libcxx/test/libcxx/containers/views/views.span/span.sub/assert.subspan.pass.cpp
+++ b/libcxx/test/libcxx/containers/views/views.span/span.sub/assert.subspan.pass.cpp
@@ -9,11 +9,15 @@
// <span>
//
+// template<size_t Offset, size_t Count = dynamic_extent>
+// constexpr span<element_type, see-below> subspan() const;
+//
+// Requires: Offset <= size() && (Count == dynamic_extent || Count <= size() - Offset)
+//
// constexpr span<element_type, dynamic_extent> subspan(
// size_type offset, size_type count = dynamic_extent) const;
//
-// Requires: (0 <= Offset && Offset <= size())
-// && (Count == dynamic_extent || Count >= 0 && Offset + Count <= size())
+// Requires: offset <= size() && (count == dynamic_extent || count <= size() - offset)
// Make sure that creating a sub-span with an incorrect number of elements triggers an assertion.
@@ -44,13 +48,13 @@ int main(int, char**) {
std::array<int, 3> array{0, 1, 2};
std::span<int, 3> const s(array.data(), array.size());
TEST_LIBCPP_ASSERT_FAILURE(s.subspan(4), "span<T, N>::subspan(offset, count): offset out of range");
- // s.subspan<4>() caught at compile-time (tested elsewhere)
+ // s.subspan<4>() caught at compile-time (tested in libcxx/test/std/containers/views/views.span/span.sub/subspan.verify.cpp)
TEST_LIBCPP_ASSERT_FAILURE(s.subspan(0, 4), "span<T, N>::subspan(offset, count): count out of range");
- // s.subspan<0, 4>() caught at compile-time (tested elsewhere)
+ // s.subspan<0, 4>() caught at compile-time (tested in libcxx/test/std/containers/views/views.span/span.sub/subspan.verify.cpp)
TEST_LIBCPP_ASSERT_FAILURE(s.subspan(1, 3), "span<T, N>::subspan(offset, count): offset + count out of range");
- // s.subspan<1, 3>() caught at compile-time (tested elsewhere)
+ // s.subspan<1, 3>() caught at compile-time (tested in libcxx/test/std/containers/views/views.span/span.sub/subspan.verify.cpp)
}
return 0;
diff --git a/libcxx/test/std/containers/views/views.span/span.sub/subspan.verify.cpp b/libcxx/test/std/containers/views/views.span/span.sub/subspan.verify.cpp
index e74674e800fff..d6bc21197098a 100644
--- a/libcxx/test/std/containers/views/views.span/span.sub/subspan.verify.cpp
+++ b/libcxx/test/std/containers/views/views.span/span.sub/subspan.verify.cpp
@@ -14,7 +14,7 @@
// <span>
// template<size_t Offset, size_t Count = dynamic_extent>
-// constexpr span<element_type, see below> subspan() const;
+// constexpr span<element_type, see-below> subspan() const;
//
// Mandates: Offset <= Extent && (Count == dynamic_extent || Count <= Extent - Offset) is true.
More information about the libcxx-commits
mailing list