[FMV][AArch64] Changes in fmv-features metadata. (#122192)
[llvm-project.git] / libcxx / test / std / thread / futures / futures.future_error / what.pass.cpp
blob87d056f6309dc94059d3b654c61e80ed2e72ddb8
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
11 // VC Runtime's std::exception::what() method is not marked as noexcept, so
12 // this fails.
13 // UNSUPPORTED: target=x86_64-pc-windows-msvc
15 // <future>
17 // class future_error
19 // const char* what() const noexcept;
21 #include <cassert>
22 #include <future>
23 #include <string_view>
24 #include <utility>
26 #include "test_macros.h"
28 int main(int, char**) {
29 ASSERT_NOEXCEPT(std::declval<std::future_error const&>().what());
30 ASSERT_SAME_TYPE(decltype(std::declval<std::future_error const&>().what()), char const*);
32 // Before C++17, we can't construct std::future_error directly in a standards-conforming way
33 #if TEST_STD_VER >= 17
35 std::future_error const f(std::future_errc::broken_promise);
36 [[maybe_unused]] char const* what = f.what();
37 LIBCPP_ASSERT(what == std::string_view{"The associated promise has been destructed prior "
38 "to the associated state becoming ready."});
41 std::future_error f(std::future_errc::future_already_retrieved);
42 [[maybe_unused]] char const* what = f.what();
43 LIBCPP_ASSERT(what == std::string_view{"The future has already been retrieved from "
44 "the promise or packaged_task."});
47 std::future_error f(std::future_errc::promise_already_satisfied);
48 [[maybe_unused]] char const* what = f.what();
49 LIBCPP_ASSERT(what == std::string_view{"The state of the promise has already been set."});
52 std::future_error f(std::future_errc::no_state);
53 [[maybe_unused]] char const* what = f.what();
54 LIBCPP_ASSERT(what == std::string_view{"Operation not permitted on an object without "
55 "an associated state."});
57 #endif
59 return 0;