Skip to content

Commit

Permalink
[oneDPL][ranges][test] + test_range_algo::test_view functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeDvorskiy committed Oct 17, 2024
1 parent 47a1dcc commit c39f6d6
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions test/parallel_api/ranges/std_ranges_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,13 @@ struct test
auto expected_res = checker(expected_view, args...);

typename Container::type& A = cont_in();
auto res = algo(exec, tr_in(A), args...);
auto r_in = tr_in(A);
auto res = algo(exec, r_in, args...);

//check result
static_assert(std::is_same_v<decltype(res), decltype(checker(tr_in(A), args...))>, "Wrong return type");
static_assert(std::is_same_v<decltype(res), decltype(checker(r_in, args...))>, "Wrong return type");

auto bres = ret_in_val(expected_res, expected_view.begin()) == ret_in_val(res, tr_in(A).begin());
auto bres = ret_in_val(expected_res, expected_view.begin()) == ret_in_val(res, r_in.begin());
EXPECT_TRUE(bres, (std::string("wrong return value from algo with ranges: ") + typeid(Algo).name() +
typeid(decltype(tr_in(std::declval<Container&>()()))).name()).c_str());

Expand Down Expand Up @@ -505,6 +506,14 @@ template<int call_id = 0, typename T = int, TestDataMode mode = data_in>
struct test_range_algo
{
const int max_n = 10;
void test_view(auto view, auto algo, auto& checker, auto... args)
{
test<T, host_subrange<T>, mode>{max_n}(host_policies(), algo, checker, view, std::identity{}, args...);
#if TEST_DPCPP_BACKEND_PRESENT
test<T, usm_subrange<T>, mode>{max_n}(dpcpp_policy<call_id>(), algo, checker, view, std::identity{}, args...);
#endif //TEST_DPCPP_BACKEND_PRESENT
}

void operator()(auto algo, auto& checker, auto... args)
{

Expand Down

0 comments on commit c39f6d6

Please sign in to comment.