-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[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
Changes from all commits
8ab1211
21ecd59
3937383
5af76f6
a5bdab3
56334ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
#include <concepts> | ||
#include <iterator> | ||
#include <ranges> | ||
#include <sstream> | ||
#include <type_traits> | ||
#include <utility> | ||
|
||
|
@@ -45,7 +46,10 @@ 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]; | ||
#ifndef TEST_HAS_NO_LOCALIZATION | ||
std::istringstream stream; | ||
#endif | ||
|
||
// [concept.swappable] | ||
static_assert(test(std::ranges::swap, a, a)); | ||
|
@@ -81,25 +85,50 @@ static_assert(test(std::ranges::ssize, a)); | |
// 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); | ||
#ifndef TEST_HAS_NO_LOCALIZATION | ||
static_assert(test(std::views::istream<int>, stream)); | ||
#endif | ||
static_assert(test(std::views::single, 4)); | ||
|
||
#if TEST_STD_VER >= 23 | ||
static_assert(test(std::views::repeat, 1)); | ||
#endif | ||
|
||
Comment on lines
+93
to
+96
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe 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 commentThe 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. |
||
// [range.adaptors] | ||
static_assert(test(std::views::all, a)); | ||
static_assert(test(std::views::common, a)); | ||
static_assert(test(std::views::counted, a, 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::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::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::take, a, 10)); | ||
//static_assert(test(std::views::take_while, a, [](int x){ return x < 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::values, pairs)); | ||
|
||
#if TEST_STD_VER >= 23 | ||
// 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::as_const, a)); | ||
static_assert(test(std::views::as_rvalue, 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::enumerate, a)); | ||
static_assert(test(std::views::join_with, 1)); | ||
// static_assert(test(std::views::stride, a, 1)); | ||
static_assert(test(std::views::zip_transform, [](int x, int y) { return x + y; }, a, a)); | ||
static_assert(test(std::views::zip, a, a)); | ||
#endif | ||
|
||
#if TEST_STD_VER >= 26 | ||
// static_assert(test(std::views::cache_latest, a)); | ||
// static_assert(test(std::views::concat, a, a)); | ||
// static_assert(test(std::views::to_input, a)); | ||
#endif |
Uh oh!
There was an error while loading. Please reload this page.