what.pass.cpp 1.9 KB

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