[TableGen] Split DAGISelMatcherOpt FactorNodes into 2 functions. NFC (#125330)
[llvm-project.git] / libcxx / test / std / thread / thread.threads / thread.thread.class / thread.thread.id / format.functions.vformat.pass.cpp
blob8555ebd7426161279b3e6dcd04ce1a339c9a7523
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
10 // UNSUPPORTED: no-threads
12 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
14 // TODO FMT This test should not require std::to_chars(floating-point)
15 // XFAIL: availability-fp_to_chars-missing
17 // <thread>
19 // template<class charT>
20 // struct formatter<thread::id, charT>;
22 // string vformat(string_view fmt, format_args args);
23 // wstring vformat(wstring_view fmt, wformat_args args);
25 #include <format>
26 #include <cassert>
28 #include "assert_macros.h"
29 #include "concat_macros.h"
30 #include "format.functions.tests.h"
31 #include "test_macros.h"
33 auto test = []<class CharT, class... Args>(
34 std::basic_string_view<CharT> expected, std::basic_string_view<CharT> fmt, Args&&... args) {
35 std::basic_string<CharT> out = std::vformat(fmt, std::make_format_args<context_t<CharT>>(args...));
36 TEST_REQUIRE(out == expected,
37 TEST_WRITE_CONCATENATED(
38 "\nFormat string ", fmt, "\nExpected output ", expected, "\nActual output ", out, '\n'));
41 auto test_exception =
42 []<class CharT, class... Args>(
43 [[maybe_unused]] std::string_view what,
44 [[maybe_unused]] std::basic_string_view<CharT> fmt,
45 [[maybe_unused]] Args&&... args) {
46 TEST_VALIDATE_EXCEPTION(
47 std::format_error,
48 [&]([[maybe_unused]] const std::format_error& e) {
49 TEST_LIBCPP_REQUIRE(
50 e.what() == what,
51 TEST_WRITE_CONCATENATED(
52 "\nFormat string ", fmt, "\nExpected exception ", what, "\nActual exception ", e.what(), '\n'));
54 TEST_IGNORE_NODISCARD std::vformat(fmt, std::make_format_args<context_t<CharT>>(args...)));
57 int main(int, char**) {
58 format_tests<char>(test, test_exception);
60 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
61 format_tests<wchar_t>(test, test_exception);
62 #endif
64 return 0;