1 | //===----------------------------------------------------------------------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | // UNSUPPORTED: c++03, c++11, c++14 |
10 | // UNSUPPORTED: no-exceptions |
11 | // `check_assertion.h` requires Unix headers and regex support. |
12 | // UNSUPPORTED: !has-unix-headers, no-localization |
13 | |
14 | // UNSUPPORTED: libcpp-has-no-incomplete-pstl |
15 | |
16 | // check that std::equal(ExecutionPolicy) terminates on user-thrown exceptions |
17 | |
18 | #include <algorithm> |
19 | |
20 | #include "check_assertion.h" |
21 | #include "test_execution_policies.h" |
22 | #include "test_iterators.h" |
23 | |
24 | int main(int, char**) { |
25 | test_execution_policies([](auto&& policy) { |
26 | EXPECT_STD_TERMINATE([&] { |
27 | try { |
28 | int a[] = {1, 2}; |
29 | int b[] = {1, 2}; |
30 | (void)std::equal(policy, |
31 | util::throw_on_move_iterator(std::begin(a), 1), |
32 | util::throw_on_move_iterator(std::end(a), 1), |
33 | util::throw_on_move_iterator(std::begin(b), 1)); |
34 | } catch (const util::iterator_error&) { |
35 | assert(false); |
36 | } |
37 | }); |
38 | EXPECT_STD_TERMINATE([&] { |
39 | try { |
40 | int a[] = {1, 2}; |
41 | int b[] = {1, 2}; |
42 | (void)std::equal( |
43 | policy, |
44 | util::throw_on_move_iterator(std::begin(a), 1), |
45 | util::throw_on_move_iterator(std::end(a), 1), |
46 | util::throw_on_move_iterator(std::begin(b), 1), |
47 | util::throw_on_move_iterator(std::end(b), 1)); |
48 | } catch (const util::iterator_error&) { |
49 | assert(false); |
50 | } |
51 | }); |
52 | }); |
53 | } |
54 | |