From 622047244f6bba35d2001aca7e669d8baddebadf Mon Sep 17 00:00:00 2001 From: MikeDvorskiy Date: Fri, 29 Nov 2024 19:14:43 +0100 Subject: [PATCH] [oneDPL][ranges][test][copy_if] support size limit for output in a test checker --- .../ranges/std_ranges_copy_if.pass.cpp | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/test/parallel_api/ranges/std_ranges_copy_if.pass.cpp b/test/parallel_api/ranges/std_ranges_copy_if.pass.cpp index 842d9038b52..d343d0d6ac3 100644 --- a/test/parallel_api/ranges/std_ranges_copy_if.pass.cpp +++ b/test/parallel_api/ranges/std_ranges_copy_if.pass.cpp @@ -23,17 +23,25 @@ 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(r_in), std::ranges::begin(r_out), - std::forward(args)...); - using ret_type = std::ranges::copy_if_result, std::ranges::borrowed_iterator_t>; - 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); + test_range_algo<0, int, data_in_out>{big_sz}(dpl_ranges::copy_if, copy_if_checker, pred, std::identity{}); test_range_algo<1, int, data_in_out>{}(dpl_ranges::copy_if, copy_if_checker, pred, proj); test_range_algo<2, P2, data_in_out>{}(dpl_ranges::copy_if, copy_if_checker, pred, &P2::x); test_range_algo<3, P2, data_in_out>{}(dpl_ranges::copy_if, copy_if_checker, pred, &P2::proj);