Debian Codegraph @

libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/end.pass.cpp

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