1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // UNSUPPORTED: libcpp-has-no-threads
11 
12 // LWG 2056 changed the values of future_errc, so if we're using new headers
13 // with an old library we'll get incorrect messages.
14 //
15 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11
16 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12
17 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin13
18 
19 // <future>
20 
21 // class future_error
22 
23 // const char* what() const throw();
24 
25 #include <future>
26 #include <cstring>
27 #include <cassert>
28 
main()29 int main()
30 {
31     {
32         std::future_error f(std::make_error_code(std::future_errc::broken_promise));
33         assert(std::strcmp(f.what(), "The associated promise has been destructed prior "
34                       "to the associated state becoming ready.") == 0);
35     }
36     {
37         std::future_error f(std::make_error_code(std::future_errc::future_already_retrieved));
38         assert(std::strcmp(f.what(), "The future has already been retrieved from "
39                       "the promise or packaged_task.") == 0);
40     }
41     {
42         std::future_error f(std::make_error_code(std::future_errc::promise_already_satisfied));
43         assert(std::strcmp(f.what(), "The state of the promise has already been set.") == 0);
44     }
45     {
46         std::future_error f(std::make_error_code(std::future_errc::no_state));
47         assert(std::strcmp(f.what(), "Operation not permitted on an object without "
48                       "an associated state.") == 0);
49     }
50 }
51