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