code.pass.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. // <future>
  11. // class future_error
  12. // future_error(error_code __ec); // exposition only
  13. // explicit future_error(future_errc _Ev) : __ec_(make_error_code(_Ev)) {} // C++17
  14. // const error_code& code() const throw();
  15. #include <future>
  16. #include <cassert>
  17. #include "test_macros.h"
  18. int main(int, char**)
  19. {
  20. {
  21. std::error_code ec = std::make_error_code(std::future_errc::broken_promise);
  22. std::future_error f(ec);
  23. assert(f.code() == ec);
  24. }
  25. {
  26. std::error_code ec = std::make_error_code(std::future_errc::future_already_retrieved);
  27. std::future_error f(ec);
  28. assert(f.code() == ec);
  29. }
  30. {
  31. std::error_code ec = std::make_error_code(std::future_errc::promise_already_satisfied);
  32. std::future_error f(ec);
  33. assert(f.code() == ec);
  34. }
  35. {
  36. std::error_code ec = std::make_error_code(std::future_errc::no_state);
  37. std::future_error f(ec);
  38. assert(f.code() == ec);
  39. }
  40. #if TEST_STD_VER > 14
  41. {
  42. std::future_error f(std::future_errc::broken_promise);
  43. assert(f.code() == std::make_error_code(std::future_errc::broken_promise));
  44. }
  45. {
  46. std::future_error f(std::future_errc::no_state);
  47. assert(f.code() == std::make_error_code(std::future_errc::no_state));
  48. }
  49. #endif
  50. return 0;
  51. }