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 // LWG 2056 changed the values of future_errc, so if we're using new headers
12 // with an old library we'll get incorrect messages.
13 //
14 // XFAIL: with_system_cxx_lib=macosx10.11
15 // XFAIL: with_system_cxx_lib=macosx10.10
16 // XFAIL: with_system_cxx_lib=macosx10.9
17 // XFAIL: with_system_cxx_lib=macosx10.7
18 // XFAIL: with_system_cxx_lib=macosx10.8
19 
20 // <future>
21 
22 // class future_error
23 
24 // const char* what() const throw();
25 
26 #include <future>
27 #include <cstring>
28 #include <cassert>
29 
30 #include "test_macros.h"
31 
32 int main(int, char**)
33 {
34     {
35         std::future_error f(std::make_error_code(std::future_errc::broken_promise));
36         LIBCPP_ASSERT(std::strcmp(f.what(), "The associated promise has been destructed prior "
37                       "to the associated state becoming ready.") == 0);
38     }
39     {
40         std::future_error f(std::make_error_code(std::future_errc::future_already_retrieved));
41         LIBCPP_ASSERT(std::strcmp(f.what(), "The future has already been retrieved from "
42                       "the promise or packaged_task.") == 0);
43     }
44     {
45         std::future_error f(std::make_error_code(std::future_errc::promise_already_satisfied));
46         LIBCPP_ASSERT(std::strcmp(f.what(), "The state of the promise has already been set.") == 0);
47     }
48     {
49         std::future_error f(std::make_error_code(std::future_errc::no_state));
50         LIBCPP_ASSERT(std::strcmp(f.what(), "Operation not permitted on an object without "
51                       "an associated state.") == 0);
52     }
53 
54   return 0;
55 }
56