• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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: libcpp-has-no-threads
10 
11 // <future>
12 
13 // class future_error
14 //     future_error(error_code __ec);  // exposition only
15 //     explicit future_error(future_errc _Ev) : __ec_(make_error_code(_Ev)) {} // C++17
16 
17 // const error_code& code() const throw();
18 
19 #include <future>
20 #include <cassert>
21 
22 #include "test_macros.h"
23 
main(int,char **)24 int main(int, char**)
25 {
26     {
27         std::error_code ec = std::make_error_code(std::future_errc::broken_promise);
28         std::future_error f(ec);
29         assert(f.code() == ec);
30     }
31     {
32         std::error_code ec = std::make_error_code(std::future_errc::future_already_retrieved);
33         std::future_error f(ec);
34         assert(f.code() == ec);
35     }
36     {
37         std::error_code ec = std::make_error_code(std::future_errc::promise_already_satisfied);
38         std::future_error f(ec);
39         assert(f.code() == ec);
40     }
41     {
42         std::error_code ec = std::make_error_code(std::future_errc::no_state);
43         std::future_error f(ec);
44         assert(f.code() == ec);
45     }
46 #if TEST_STD_VER > 14
47     {
48         std::future_error f(std::future_errc::broken_promise);
49         assert(f.code() == std::make_error_code(std::future_errc::broken_promise));
50     }
51     {
52         std::future_error f(std::future_errc::no_state);
53         assert(f.code() == std::make_error_code(std::future_errc::no_state));
54     }
55 #endif
56 
57   return 0;
58 }
59