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-has-no-incomplete-format
10
11 // <format>
12
13 // basic_format_args() noexcept;
14 // template<class... Args>
15 // basic_format_args(const format-arg-store<Context, Args...>& store) noexcept;
16
17 #include <format>
18 #include <cassert>
19
20 #include "test_macros.h"
21
22 template <class CharT>
test()23 void test() {
24 using Context = std::basic_format_context<CharT*, CharT>;
25 {
26 ASSERT_NOEXCEPT(std::basic_format_args<Context>{});
27
28 std::basic_format_args<Context> format_args{};
29 assert(!format_args.get(0));
30 }
31 {
32 auto store = std::make_format_args<Context>(1);
33 ASSERT_NOEXCEPT(std::basic_format_args<Context>{store});
34 std::basic_format_args<Context> format_args{store};
35 assert(format_args.get(0));
36 assert(!format_args.get(1));
37 }
38 {
39 auto store = std::make_format_args<Context>(1, 'c');
40 ASSERT_NOEXCEPT(std::basic_format_args<Context>{store});
41 std::basic_format_args<Context> format_args{store};
42 assert(format_args.get(0));
43 assert(format_args.get(1));
44 assert(!format_args.get(2));
45 }
46 {
47 auto store = std::make_format_args<Context>(1, 'c', nullptr);
48 ASSERT_NOEXCEPT(std::basic_format_args<Context>{store});
49 std::basic_format_args<Context> format_args{store};
50 assert(format_args.get(0));
51 assert(format_args.get(1));
52 assert(format_args.get(2));
53 assert(!format_args.get(3));
54 }
55 }
56
test()57 void test() {
58 test<char>();
59 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
60 test<wchar_t>();
61 #endif
62 }
63
main(int,char **)64 int main(int, char**) {
65 test();
66
67 return 0;
68 }
69