Skip to content

Commit

Permalink
[oneDPL][ranges] + tests for count, count_if, is_sorted, equal
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeDvorskiy committed Mar 28, 2024
1 parent 415c1e2 commit d583058
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 8 deletions.
8 changes: 0 additions & 8 deletions test/parallel_api/ranges/std_ranges.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ main()
{
#if _ENABLE_STD_RANGES_TESTING

auto f_mutuable = [](auto&& val) -> decltype(auto) { return val *= val; };
auto proj_mutuable = [](auto&& val) -> decltype(auto) { return val *= 2; };

auto f = [](auto&& val) -> decltype(auto) { return val * val; };
auto proj = [](auto&& val) -> decltype(auto) { return val * 2; };
auto pred = [](auto&& val) -> decltype(auto) { return val == 5; };
auto pred_2 = [](auto&& val1, auto&& val2) -> decltype(auto) { return val1 == val2; };

using namespace test_std_ranges;

test_range_algo{}(oneapi::dpl::ranges::for_each, std::ranges::for_each, f_mutuable, proj_mutuable);
Expand Down
34 changes: 34 additions & 0 deletions test/parallel_api/ranges/std_ranges_2.pass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// Copyright (C) Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// This file incorporates work covered by the following copyright and permission
// notice:
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
//
//===----------------------------------------------------------------------===//

#include "std_ranges_test.h"

std::int32_t
main()
{
#if _ENABLE_STD_RANGES_TESTING

using namespace test_std_ranges;

test_range_algo{}(oneapi::dpl::ranges::count_if, std::ranges::count_if, pred, proj);
test_range_algo{}(oneapi::dpl::ranges::count, std::ranges::count, 4, proj);

test_range_algo{}(oneapi::dpl::ranges::is_sorted, std::ranges::is_sorted, comp, proj);
test_range_algo<data_in_in>{}(oneapi::dpl::ranges::equal, std::ranges::equal, pred_2, proj);

#endif //_ENABLE_STD_RANGES_TESTING

return TestUtils::done(_ENABLE_STD_RANGES_TESTING);
}
9 changes: 9 additions & 0 deletions test/parallel_api/ranges/std_ranges_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,15 @@ struct test_range_algo
}
};

decltype(auto) f_mutuable = [](auto&& val) { return val *= val; };
decltype(auto) proj_mutuable = [](auto&& val) { return val *= 2; };

auto f = [](auto&& val) { return val * val; };
auto proj = [](auto&& val){ return val * 2; };
auto pred = [](auto&& val) { return val == 5; };
auto pred_2 = [](auto&& val1, auto&& val2) { return val1 == val2; };
auto comp = [](auto&& val1, auto&& val2) { return std::less<void>{}(val1, val2); };

}; //namespace test_std_ranges

#endif //_ENABLE_STD_RANGES_TESTING
Expand Down

0 comments on commit d583058

Please sign in to comment.