• 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 // 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 
18 // <future>
19 
20 // class future_error
21 
22 // const char* what() const throw();
23 
24 #include <future>
25 #include <cstring>
26 #include <cassert>
27 
28 #include "test_macros.h"
29 
main(int,char **)30 int main(int, char**)
31 {
32     {
33         std::future_error f(std::make_error_code(std::future_errc::broken_promise));
34         LIBCPP_ASSERT(std::strcmp(f.what(), "The associated promise has been destructed prior "
35                       "to the associated state becoming ready.") == 0);
36     }
37     {
38         std::future_error f(std::make_error_code(std::future_errc::future_already_retrieved));
39         LIBCPP_ASSERT(std::strcmp(f.what(), "The future has already been retrieved from "
40                       "the promise or packaged_task.") == 0);
41     }
42     {
43         std::future_error f(std::make_error_code(std::future_errc::promise_already_satisfied));
44         LIBCPP_ASSERT(std::strcmp(f.what(), "The state of the promise has already been set.") == 0);
45     }
46     {
47         std::future_error f(std::make_error_code(std::future_errc::no_state));
48         LIBCPP_ASSERT(std::strcmp(f.what(), "Operation not permitted on an object without "
49                       "an associated state.") == 0);
50     }
51 
52   return 0;
53 }
54