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
6 //===----------------------------------------------------------------------===//
8 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
9 // UNSUPPORTED: no-threads
11 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
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.
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
;
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
>
54 #if !defined(__APPLE__) && !defined(__FreeBSD__)
55 test_format(SV("0"), std::thread::id());
57 test_format(SV("0x0"), std::thread::id());
63 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
68 int main(int, char**) {