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