-
Notifications
You must be signed in to change notification settings - Fork 11.6k
/
begin.pass.cpp
53 lines (43 loc) · 1.17 KB
/
begin.pass.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//===----------------------------------------------------------------------===//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <format>
// constexpr begin() const noexcept;
#include <format>
#include <cassert>
#include "test_macros.h"
template <class CharT>
constexpr void test(const CharT* fmt) {
{
std::basic_format_parse_context<CharT> context(fmt);
assert(context.begin() == &fmt[0]);
ASSERT_NOEXCEPT(context.begin());
}
{
std::basic_string_view view{fmt};
std::basic_format_parse_context context(view);
assert(context.begin() == view.begin());
ASSERT_NOEXCEPT(context.begin());
}
}
constexpr bool test() {
test("abc");
test(L"abc");
#ifndef _LIBCPP_NO_HAS_CHAR8_T
test(u8"abc");
#endif
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
test(u"abc");
test(U"abc");
#endif
return true;
}
int main(int, char**) {
test();
static_assert(test());
return 0;
}