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