• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
29 #include "test_macros.h"
30 
main()31 int main()
32 {
33     {
34         std::future_error f(std::make_error_code(std::future_errc::broken_promise));
35         LIBCPP_ASSERT(std::strcmp(f.what(), "The associated promise has been destructed prior "
36                       "to the associated state becoming ready.") == 0);
37     }
38     {
39         std::future_error f(std::make_error_code(std::future_errc::future_already_retrieved));
40         LIBCPP_ASSERT(std::strcmp(f.what(), "The future has already been retrieved from "
41                       "the promise or packaged_task.") == 0);
42     }
43     {
44         std::future_error f(std::make_error_code(std::future_errc::promise_already_satisfied));
45         LIBCPP_ASSERT(std::strcmp(f.what(), "The state of the promise has already been set.") == 0);
46     }
47     {
48         std::future_error f(std::make_error_code(std::future_errc::no_state));
49         LIBCPP_ASSERT(std::strcmp(f.what(), "Operation not permitted on an object without "
50                       "an associated state.") == 0);
51     }
52 }
53