Differential D58852 Diff 188992 test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp
Changeset View
Changeset View
Standalone View
Standalone View
test/std/algorithms/alg.modifying.operations/alg.partitions/partition_copy.pass.cpp
- This file was moved from test/test_partition_copy.cpp.
// -*- C++ -*- | // -*- C++ -*- | ||||
//===-- test_partition_copy.cpp -------------------------------------------===// | //===-- partition_copy.pass.cpp -------------------------------------------===// | ||||
// | // | ||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||||
// See https://llvm.org/LICENSE.txt for license information. | // See https://llvm.org/LICENSE.txt for license information. | ||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// Tests for stable_partition and partition_copy | // Tests for stable_partition and partition_copy | ||||
#include "pstl_test_config.h" | #include "support/pstl_test_config.h" | ||||
#include <type_traits> | |||||
#include <cstdlib> | |||||
#include <iterator> | |||||
#ifdef PSTL_STANDALONE_TESTS | |||||
#include "pstl/execution" | #include "pstl/execution" | ||||
#include "pstl/algorithm" | #include "pstl/algorithm" | ||||
#include "utils.h" | #else | ||||
#include <execution> | |||||
#include <algorithm> | |||||
#endif // PSTL_STANDALONE_TESTS | |||||
#include <cstdlib> | #include "support/parallel_utils.h" | ||||
#include <iterator> | |||||
using namespace TestUtils; | using namespace Parallel_TestUtils; | ||||
struct test_partition_copy | struct test_partition_copy | ||||
{ | { | ||||
template <typename Policy, typename InputIterator, typename OutputIterator, typename OutputIterator2, | template <typename Policy, typename InputIterator, typename OutputIterator, typename OutputIterator2, | ||||
typename UnaryOp> | typename UnaryOp> | ||||
void | void | ||||
operator()(Policy&& exec, InputIterator first, InputIterator last, OutputIterator true_first, | operator()(Policy&& exec, InputIterator first, InputIterator last, OutputIterator true_first, | ||||
OutputIterator true_last, OutputIterator2 false_first, OutputIterator2 false_last, UnaryOp unary_op) | OutputIterator true_last, OutputIterator2 false_first, OutputIterator2 false_last, UnaryOp unary_op) | ||||
{ | { | ||||
auto actual_ret = std::partition_copy(exec, first, last, true_first, false_first, unary_op); | auto actual_ret = std::partition_copy(exec, first, last, true_first, false_first, unary_op); | ||||
EXPECT_TRUE(std::distance(true_first, actual_ret.first) == std::count_if(first, last, unary_op), | EXPECT_TRUE(std::distance(true_first, actual_ret.first) == std::count_if(first, last, unary_op), | ||||
"partition_copy has wrong effect from true sequence"); | "partition_copy has wrong effect from true sequence"); | ||||
EXPECT_TRUE(std::distance(false_first, actual_ret.second) == | EXPECT_TRUE(std::distance(false_first, actual_ret.second) == | ||||
std::count_if(first, last, __pstl::internal::not_pred<UnaryOp>(unary_op)), | std::count_if(first, last, __pstl::internal::not_pred<UnaryOp>(unary_op)), | ||||
"partition_copy has wrong effect from false sequence"); | "partition_copy has wrong effect from false sequence"); | ||||
} | } | ||||
//dummy specialization by iterator type and policy type, in case of broken configuration | //dummy specialization by iterator type and policy type, in case of broken configuration | ||||
#if __PSTL_ICC_1800_TEST_MONOTONIC_RELEASE_64_BROKEN | #if __PSTL_ICC_1800_TEST_MONOTONIC_RELEASE_64_BROKEN | ||||
template <typename InputIterator, typename OutputIterator, typename OutputIterator2, typename UnaryOp> | template <typename InputIterator, typename OutputIterator, typename OutputIterator2, typename UnaryOp> | ||||
void | void | ||||
operator()(pstl::execution::unsequenced_policy, std::reverse_iterator<InputIterator> first, | operator()(__pstl::execution::unsequenced_policy, std::reverse_iterator<InputIterator> first, | ||||
std::reverse_iterator<InputIterator> last, std::reverse_iterator<OutputIterator> true_first, | std::reverse_iterator<InputIterator> last, std::reverse_iterator<OutputIterator> true_first, | ||||
std::reverse_iterator<OutputIterator> true_last, std::reverse_iterator<OutputIterator2> false_first, | std::reverse_iterator<OutputIterator> true_last, std::reverse_iterator<OutputIterator2> false_first, | ||||
OutputIterator2 false_last, UnaryOp unary_op) | OutputIterator2 false_last, UnaryOp unary_op) | ||||
{ | { | ||||
} | } | ||||
template <typename InputIterator, typename OutputIterator, typename OutputIterator2, typename UnaryOp> | template <typename InputIterator, typename OutputIterator, typename OutputIterator2, typename UnaryOp> | ||||
void | void | ||||
operator()(pstl::execution::parallel_unsequenced_policy, std::reverse_iterator<InputIterator> first, | operator()(__pstl::execution::parallel_unsequenced_policy, std::reverse_iterator<InputIterator> first, | ||||
std::reverse_iterator<InputIterator> last, std::reverse_iterator<OutputIterator> true_first, | std::reverse_iterator<InputIterator> last, std::reverse_iterator<OutputIterator> true_first, | ||||
std::reverse_iterator<OutputIterator> true_last, std::reverse_iterator<OutputIterator2> false_first, | std::reverse_iterator<OutputIterator> true_last, std::reverse_iterator<OutputIterator2> false_first, | ||||
OutputIterator2 false_last, UnaryOp unary_op) | OutputIterator2 false_last, UnaryOp unary_op) | ||||
{ | { | ||||
} | } | ||||
#endif | #endif | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |