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