[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / thread / thread.threads / thread.thread.class / thread.thread.id / format.pass.cpp
blob575e5dda93f53c82ff797ba85d67f09508203ba0
1 //===----------------------------------------------------------------------===//
2 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3 // See https://llvm.org/LICENSE.txt for license information.
4 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 //
6 //===----------------------------------------------------------------------===//
8 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
9 // UNSUPPORTED: no-threads
11 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
13 // <thread>
15 // template<class charT>
16 // struct formatter<thread::id, charT>;
18 // template<class FormatContext>
19 // typename FormatContext::iterator
20 // format(const T& r, FormatContext& ctx) const;
22 // Note this tests the basics of this function. It's tested in more detail in
23 // the format functions test.
25 #include <cassert>
26 #include <concepts>
27 #include <iterator>
28 #include <thread>
30 #include "test_format_context.h"
31 #include "test_macros.h"
32 #include "make_string.h"
34 #define SV(S) MAKE_STRING_VIEW(CharT, S)
36 template <class StringViewT>
37 void test_format(StringViewT expected, std::thread::id arg) {
38 using CharT = typename StringViewT::value_type;
39 using String = std::basic_string<CharT>;
40 using OutIt = std::back_insert_iterator<String>;
41 using FormatCtxT = std::basic_format_context<OutIt, CharT>;
43 const std::formatter<std::thread::id, CharT> formatter;
45 String result;
46 OutIt out = std::back_inserter(result);
47 FormatCtxT format_ctx = test_format_context_create<OutIt, CharT>(out, std::make_format_args<FormatCtxT>(arg));
48 formatter.format(arg, format_ctx);
49 assert(result == expected);
52 template <class CharT>
53 void test_fmt() {
54 #if !defined(__APPLE__) && !defined(__FreeBSD__)
55 test_format(SV("0"), std::thread::id());
56 #else
57 test_format(SV("0x0"), std::thread::id());
58 #endif
61 void test() {
62 test_fmt<char>();
63 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
64 test_fmt<wchar_t>();
65 #endif
68 int main(int, char**) {
69 test();
71 return 0;