32 SECTION(
"non-empty") {
33 vector<int> v = {1, 2, 3, 4, 5};
55 SECTION(
"non-empty") {
56 std::list<int> l = {1, 2, 3, 4, 5};
92 SECTION(
"non-empty") {
93 vector<int> v = {1, 2, 3, 4, 5};
115 SECTION(
"non-empty") {
116 std::list<int> l = {1, 2, 3, 4, 5};
133 vector<int> in = {1, 2, 3, 4};
134 for (
const auto& e :
reverse(in)) out.push_back(e);
135 CHECK(out == vector<int>{4, 3, 2, 1});
138 for (
const auto& e :
reverse(getVector(3))) out.push_back(e);
139 CHECK(out == vector<int>{2, 1, 0});
141 SECTION(
"2 x reverse") {
142 for (
const auto& e :
reverse(
reverse(getVector(4)))) out.push_back(e);
143 CHECK(out == vector<int>{0, 1, 2, 3});
149 auto square = [](
auto& x) {
return x * x; };
151 auto plus_i = [&](
auto& x) {
return int(x + i); };
154 vector<int> v = {1, 2, 3, 4};
212 SECTION(
"std::map") {
213 std::map<int, int> m = {{1, 2}, {3, 4}, {5, 6}, {7, 8}};
214 check(
keys (m), vector<int>{1, 3, 5, 7});
215 check(
values(m), vector<int>{2, 4, 6, 8});
217 SECTION(
"std::vector<std::pair>") {
218 vector<std::pair<int, int>> v = {{1, 2}, {3, 4}, {5, 6}, {7, 8}};
219 check(
keys (v), vector<int>{1, 3, 5, 7});
220 check(
values(v), vector<int>{2, 4, 6, 8});
222 SECTION(
"hash_map") {
224 {
"foo", 1}, {
"bar", 2}, {
"qux", 3},
225 {
"baz", 4}, {
"a", 5}, {
"z", 6}
227 check_unordered(
keys(m), vector<std::string>{
228 "foo",
"bar",
"qux",
"baz",
"a",
"z"});
229 check_unordered(
values(m), vector<int>{1, 2, 3, 4, 5, 6});
231 SECTION(
"std::vector<std::tuple>") {
232 vector<std::tuple<int, char, double, std::string>> v = {
233 std::tuple(1, 2, 1.2,
"foo"),
234 std::tuple(3, 4, 3.4,
"bar"),
235 std::tuple(5, 6, 5.6,
"qux")
237 check(
keys (v), vector<int>{1, 3, 5});
238 check(
values(v), vector<char>{2, 4, 6});
250 vector v = {1, 2, 3, 4, 5, 6, 7, 8, 9};
252 SECTION(
"removed front") {
256 SECTION(
"removed back") {
260 SECTION(
"keep front and back") {
262 vector{1, 3, 5, 7, 9});
264 SECTION(
"remove front and back") {
265 check(
view::filter(v, [](
int i) {
return (i & 1) == 0; }),
269 SECTION(
"projection") {
270 vector<F> f = {1, 2, 3, 4, 5};
272 auto it =
view.begin();
273 auto et =
view.end();
289 vector v = {1, 2, 3, 4};
298 SECTION(
"split_view") {
299 std::string_view str =
"abc def\t \tghi jkl mno pqr";
300 auto v =
view::take(StringOp::split_view<StringOp::EmptyParts::REMOVE>(str,
" \t"), 3);