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 //===----------------------------------------------------------------------===//
7 
8 // UNSUPPORTED: c++03, c++11, c++14, c++17
9 // UNSUPPORTED: libcpp-no-concepts
10 // UNSUPPORTED: libcpp-has-no-incomplete-format
11 
12 // <format>
13 
14 // constexpr begin() const noexcept;
15 
16 #include <format>
17 
18 #include <cassert>
19 #include <string_view>
20 
21 #include "test_macros.h"
22 
23 template <class CharT>
test(const CharT * fmt)24 constexpr void test(const CharT* fmt) {
25   {
26     std::basic_format_parse_context<CharT> context(fmt);
27     assert(context.begin() == &fmt[0]);
28     ASSERT_NOEXCEPT(context.begin());
29   }
30   {
31     std::basic_string_view view{fmt};
32     std::basic_format_parse_context context(view);
33     assert(context.begin() == view.begin());
34     ASSERT_NOEXCEPT(context.begin());
35   }
36 }
37 
test()38 constexpr bool test() {
39   test("abc");
40   test(L"abc");
41 #ifndef _LIBCPP_HAS_NO_CHAR8_T
42   test(u8"abc");
43 #endif
44 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
45   test(u"abc");
46   test(U"abc");
47 #endif
48 
49   return true;
50 }
51 
main(int,char **)52 int main(int, char**) {
53   test();
54   static_assert(test());
55 
56   return 0;
57 }
58