Changeset View
Changeset View
Standalone View
Standalone View
test/std/algorithms/alg.nonmodifying/mismatch.pass.cpp
- This file was moved from test/test_mismatch.cpp.
// -*- C++ -*- | // -*- C++ -*- | ||||
//===-- test_mismatch.cpp -------------------------------------------------===// | //===-- mismatch.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 the rest algorithms; temporary approach to check compiling | // test mismatch | ||||
#include "support/pstl_test_config.h" | |||||
#ifdef PSTL_STANDALONE_TESTS | |||||
#include "pstl/execution" | #include "pstl/execution" | ||||
#include "pstl/algorithm" | #include "pstl/algorithm" | ||||
#include "pstl/numeric" | #else | ||||
#include "pstl/memory" | #include <execution> | ||||
#include <algorithm> | |||||
#endif // PSTL_STANDALONE_TESTS | |||||
#include "utils.h" | #include "support/parallel_utils.h" | ||||
using namespace TestUtils; | using namespace Parallel_TestUtils; | ||||
struct test_mismatch | struct test_mismatch | ||||
{ | { | ||||
template <typename Policy, typename Iterator1, typename Iterator2> | template <typename Policy, typename Iterator1, typename Iterator2> | ||||
void | void | ||||
operator()(Policy&& exec, Iterator1 first1, Iterator1 last1, Iterator2 first2) | operator()(Policy&& exec, Iterator1 first1, Iterator1 last1, Iterator2 first2) | ||||
{ | { | ||||
using namespace std; | using namespace std; | ||||
typedef typename iterator_traits<Iterator1>::value_type T; | typedef typename iterator_traits<Iterator1>::value_type T; | ||||
{ | { | ||||
const auto expected = std::mismatch(first1, last1, first2, std::equal_to<T>()); | const auto expected = std::mismatch(first1, last1, first2, std::equal_to<T>()); | ||||
const auto res3 = mismatch(exec, first1, last1, first2, std::equal_to<T>()); | const auto res3 = mismatch(exec, first1, last1, first2, std::equal_to<T>()); | ||||
EXPECT_TRUE(expected == res3, "wrong return result from mismatch"); | EXPECT_TRUE(expected == res3, "wrong return result from mismatch"); | ||||
const auto res4 = mismatch(exec, first1, last1, first2); | const auto res4 = mismatch(exec, first1, last1, first2); | ||||
EXPECT_TRUE(expected == res4, "wrong return result from mismatch"); | EXPECT_TRUE(expected == res4, "wrong return result from mismatch"); | ||||
} | } | ||||
} | } | ||||
template <typename Policy, typename Iterator1, typename Iterator2> | template <typename Policy, typename Iterator1, typename Iterator2> | ||||
void | void | ||||
operator()(Policy&& exec, Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2) | operator()(Policy&& exec, Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2) | ||||
{ | { | ||||
using namespace std; | using namespace std; | ||||
typedef typename iterator_traits<Iterator1>::value_type T; | typedef typename iterator_traits<Iterator1>::value_type T; | ||||
{ | { | ||||
const auto expected = mismatch(pstl::execution::seq, first1, last1, first2, last2, std::equal_to<T>()); | const auto expected = mismatch(__pstl::execution::seq, first1, last1, first2, last2, std::equal_to<T>()); | ||||
const auto res1 = mismatch(exec, first1, last1, first2, last2, std::equal_to<T>()); | const auto res1 = mismatch(exec, first1, last1, first2, last2, std::equal_to<T>()); | ||||
EXPECT_TRUE(expected == res1, "wrong return result from mismatch"); | EXPECT_TRUE(expected == res1, "wrong return result from mismatch"); | ||||
const auto res2 = mismatch(exec, first1, last1, first2, last2); | const auto res2 = mismatch(exec, first1, last1, first2, last2); | ||||
EXPECT_TRUE(expected == res2, "wrong return result from mismatch"); | EXPECT_TRUE(expected == res2, "wrong return result from mismatch"); | ||||
} | } | ||||
} | } | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 80 Lines • Show Last 20 Lines |