From d5830580b74d9717d4691e432ade5ec9112780fb Mon Sep 17 00:00:00 2001 From: Mikhail Dvorskiy Date: Thu, 28 Mar 2024 15:36:42 +0100 Subject: [PATCH] [oneDPL][ranges] + tests for count, count_if, is_sorted, equal --- test/parallel_api/ranges/std_ranges.pass.cpp | 8 ----- .../parallel_api/ranges/std_ranges_2.pass.cpp | 34 +++++++++++++++++++ test/parallel_api/ranges/std_ranges_test.h | 9 +++++ 3 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 test/parallel_api/ranges/std_ranges_2.pass.cpp diff --git a/test/parallel_api/ranges/std_ranges.pass.cpp b/test/parallel_api/ranges/std_ranges.pass.cpp index 8e8c6e3a334..7484ce38a10 100644 --- a/test/parallel_api/ranges/std_ranges.pass.cpp +++ b/test/parallel_api/ranges/std_ranges.pass.cpp @@ -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); diff --git a/test/parallel_api/ranges/std_ranges_2.pass.cpp b/test/parallel_api/ranges/std_ranges_2.pass.cpp new file mode 100644 index 00000000000..85a3a627823 --- /dev/null +++ b/test/parallel_api/ranges/std_ranges_2.pass.cpp @@ -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{}(oneapi::dpl::ranges::equal, std::ranges::equal, pred_2, proj); + +#endif //_ENABLE_STD_RANGES_TESTING + + return TestUtils::done(_ENABLE_STD_RANGES_TESTING); +} diff --git a/test/parallel_api/ranges/std_ranges_test.h b/test/parallel_api/ranges/std_ranges_test.h index d632ff65b39..cc3ce08b966 100644 --- a/test/parallel_api/ranges/std_ranges_test.h +++ b/test/parallel_api/ranges/std_ranges_test.h @@ -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{}(val1, val2); }; + }; //namespace test_std_ranges #endif //_ENABLE_STD_RANGES_TESTING