xref: /llvm-project/libcxx/test/libcxx/thread/futures/futures.promise/assert.set_exception.pass.cpp (revision 58780b811c23df3d928d8452ee21c862dde754a2)
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 // REQUIRES: has-unix-headers
10 // UNSUPPORTED: c++03, no-threads
11 // REQUIRES: libcpp-hardening-mode={{extensive|debug}}
12 // XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing
13 
14 // <future>
15 
16 // class promise<R>
17 
18 // void set_exception(exception_ptr p);
19 // Test that a null exception_ptr is diagnosed.
20 
21 #include <future>
22 #include <exception>
23 
24 #include "check_assertion.h"
25 
main(int,char **)26 int main(int, char**) {
27     {
28         typedef int T;
29         std::promise<T> p;
30         TEST_LIBCPP_ASSERT_FAILURE(p.set_exception(std::exception_ptr()), "promise::set_exception: received nullptr");
31     }
32 
33     {
34         typedef int& T;
35         std::promise<T> p;
36         TEST_LIBCPP_ASSERT_FAILURE(p.set_exception(std::exception_ptr()), "promise::set_exception: received nullptr");
37     }
38 
39     return 0;
40 }
41