-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[libc++] Add missing CPO tests for range adaptors #149557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libc++] Add missing CPO tests for range adaptors #149557
Conversation
@llvm/pr-subscribers-libcxx Author: Louis Dionne (ldionne) ChangesFull diff: https://github.com/llvm/llvm-project/pull/149557.diff 1 Files Affected:
diff --git a/libcxx/test/std/library/description/conventions/customization.point.object/cpo.compile.pass.cpp b/libcxx/test/std/library/description/conventions/customization.point.object/cpo.compile.pass.cpp
index 3f4317a724add..9889ff2e59607 100644
--- a/libcxx/test/std/library/description/conventions/customization.point.object/cpo.compile.pass.cpp
+++ b/libcxx/test/std/library/description/conventions/customization.point.object/cpo.compile.pass.cpp
@@ -15,6 +15,7 @@
#include <concepts>
#include <iterator>
#include <ranges>
+#include <sstream>
#include <type_traits>
#include <utility>
@@ -26,7 +27,7 @@ constexpr bool test(CPO& o, Args&&...) {
static_assert(std::is_trivially_copyable_v<CPO>);
static_assert(std::is_trivially_default_constructible_v<CPO>);
- auto p = o;
+ auto p = o;
using T = decltype(p);
// The type of a customization point object, ignoring cv-qualifiers, shall model semiregular.
@@ -43,7 +44,8 @@ constexpr bool test(CPO& o, Args&&...) {
int a[10];
int arrays[10][10];
-//std::pair<int, int> pairs[10];
+std::pair<int, int> pairs[10];
+std::istringstream stream;
// [concept.swappable]
static_assert(test(std::ranges::swap, a, a));
@@ -77,23 +79,41 @@ static_assert(test(std::ranges::ssize, a));
// [range.factories]
// views::empty<T> is not a CPO
-static_assert(test(std::views::iota, 1));
static_assert(test(std::views::iota, 1, 10));
-//static_assert(test(std::views::istream<int>, 1);
+static_assert(test(std::views::iota, 1));
+static_assert(test(std::views::istream<int>, stream));
+static_assert(test(std::views::repeat, 1));
static_assert(test(std::views::single, 4));
// [range.adaptors]
+// static_assert(test(std::views::adjacent_transform<2>, [](int x, int y) { return x + y; }, a));
+// static_assert(test(std::views::adjacent<2>, a));
static_assert(test(std::views::all, a));
+// static_assert(test(std::views::as_const, a));
+static_assert(test(std::views::as_rvalue, a));
+// static_assert(test(std::views::cache_latest, a));
+// static_assert(test(std::views::cartesian_product, a, a, a));
+static_assert(test(std::views::chunk_by, a, [](int x, int y) { return x < y; }));
+// static_assert(test(std::views::chunk, a, 1));
static_assert(test(std::views::common, a));
+// static_assert(test(std::views::concat, a, a));
static_assert(test(std::views::counted, a, 10));
+static_assert(test(std::views::drop_while, a, [](int x) { return x < 10; }));
static_assert(test(std::views::drop, a, 10));
-//static_assert(test(std::views::drop_while, a, [](int x){ return x < 10; }));
-//static_assert(test(std::views::elements<0>, pairs));
-static_assert(test(std::views::filter, a, [](int x){ return x < 10; }));
+static_assert(test(std::views::elements<0>, pairs));
+// static_assert(test(std::views::enumerate, a));
+static_assert(test(std::views::filter, a, [](int x) { return x < 10; }));
+static_assert(test(std::views::join_with, 1));
static_assert(test(std::views::join, arrays));
-//static_assert(test(std::views::split, a, 4));
+static_assert(test(std::views::keys, pairs));
static_assert(test(std::views::lazy_split, a, 4));
static_assert(test(std::views::reverse, a));
+static_assert(test(std::views::split, a, 4));
+// static_assert(test(std::views::stride, a, 1));
+static_assert(test(std::views::take_while, a, [](int x) { return x < 10; }));
static_assert(test(std::views::take, a, 10));
-//static_assert(test(std::views::take_while, a, [](int x){ return x < 10; }));
-static_assert(test(std::views::transform, a, [](int x){ return x + 1; }));
+// static_assert(test(std::views::to_input, a));
+static_assert(test(std::views::transform, a, [](int x) { return x + 1; }));
+static_assert(test(std::views::values, pairs));
+// static_assert(test(std::views::zip_transform, [](int x, int y) { return x + y; }, a, a));
+static_assert(test(std::views::zip, a, a));
|
libcxx/test/std/library/description/conventions/customization.point.object/cpo.compile.pass.cpp
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I pushed some conflict-resolving changes.
It seems that static_assert(test(std::views::repeat, 1));
wasn't guarded and compiled in C++20. Perhaps we can look into this later.
No. It didn't. It seems that the generic-cxx20 set just didn't run in CI... |
libcxx/test/std/library/description/conventions/customization.point.object/cpo.compile.pass.cpp
Show resolved
Hide resolved
Excuse me for the off-topic question. What is required to push to other people's PR like that? I tried to push into mine Zingam -> H-G-Hristov and I got "no access" error or similar? |
It definitely ran on the latest version of the patch: https://github.com/llvm/llvm-project/actions/runs/16436783672/job/46449613521?pr=149557
I think you might need to be marked as a "maintainer" of the repo, perhaps by being in the |
#if TEST_STD_VER >= 23 | ||
static_assert(test(std::views::repeat, 1)); | ||
#endif | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If tests are grouped by the C++ version, should this be moved down?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think tests are intended to be grouped by sections ([range.factories], [range.adaptors]) first and then the standard modes. But this is up to @ldionne.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty neutral on this, but the tests were previously grouped as described by @frederick-vs-ja , so I decided to stick to that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll merge this now, but I am happy to adjust as a NFC follow-up if we agree on another organization.
No description provided.