[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 / parse.pass.cpp
blob8523bc89497174e1b0d3c5665d8f137d3e9656ef
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 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.
25 #include <cassert>
26 #include <concepts>
27 #include <thread>
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() {
56 test_fmt<char>();
57 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
58 test_fmt<wchar_t>();
59 #endif
61 return true;
64 int main(int, char**) {
65 test();
66 static_assert(test());
68 return 0;