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