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 ParseContext>
19 // constexpr typename ParseContext::iterator
20 // parse(ParseContext& ctx);
22 // Note this tests the basics of this function. It's tested in more detail in
23 // the format functions test.
29 #include "test_format_context.h"
30 #include "test_macros.h"
31 #include "make_string.h"
33 #define SV(S) MAKE_STRING_VIEW(CharT, S)
35 template <class StringViewT
>
36 constexpr void test_parse(StringViewT fmt
, std::size_t offset
) {
37 using CharT
= typename
StringViewT::value_type
;
38 auto parse_ctx
= std::basic_format_parse_context
<CharT
>(fmt
);
39 std::formatter
<std::thread::id
, CharT
> formatter
;
40 static_assert(std::semiregular
<decltype(formatter
)>);
42 std::same_as
<typename
StringViewT::iterator
> auto it
= formatter
.parse(parse_ctx
);
43 assert(it
== fmt
.end() - offset
);
46 template <class CharT
>
47 constexpr void test_fmt() {
48 test_parse(SV(""), 0);
49 test_parse(SV("1"), 0);
51 test_parse(SV("}"), 1);
52 test_parse(SV("1}"), 1);
55 constexpr bool test() {
57 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
64 int main(int, char**) {
66 static_assert(test());