Skip to content

Commit

Permalink
[oneDPL][ranges][test][copy_if] support size limit for output in a te…
Browse files Browse the repository at this point in the history
…st checker
  • Loading branch information
MikeDvorskiy committed Nov 28, 2024
1 parent 0a11218 commit 62b82e4
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions test/parallel_api/ranges/std_ranges_copy_if.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,22 @@ main()
namespace dpl_ranges = oneapi::dpl::ranges;

auto copy_if_checker = [](std::ranges::random_access_range auto&& r_in,
std::ranges::random_access_range auto&& r_out, auto&&... args)
std::ranges::random_access_range auto&& r_out, auto pred, auto proj)
{
auto res = std::ranges::copy_if(std::forward<decltype(r_in)>(r_in), std::ranges::begin(r_out),
std::forward<decltype(args)>(args)...);

using ret_type = std::ranges::copy_if_result<std::ranges::borrowed_iterator_t<decltype(r_in)>,
std::ranges::borrowed_iterator_t<decltype(r_out)>>;
return ret_type{res.in, res.out};

auto it_in = std::ranges::begin(r_in);
auto it_out = std::ranges::begin(r_out);
for(; it_in != std::ranges::end(r_in) && it_out != std::ranges::end(r_out); ++it_in)
{
if (std::invoke(pred, std::invoke(proj, *it_in)))
{
*it_out = *it_in;
++it_out;
}
}
return ret_type{it_in, it_out};
};

test_range_algo<0, int, data_in_out>{big_sz}(dpl_ranges::copy_if, copy_if_checker, pred);
Expand Down

0 comments on commit 62b82e4

Please sign in to comment.