xref: /llvm-project/libcxx/test/std/utilities/format/format.tuple/set_brackets.pass.cpp (revision eb6e13cb32805ee12d19aaa5823f3e4216a35653)
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, c++20
9 // UNSUPPORTED: libcpp-has-no-incomplete-format
10 
11 // This test requires the dylib support introduced in D92214.
12 // XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{.+}}
13 // XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx11.{{.+}}
14 
15 // <format>
16 
17 // template<class charT, formattable<charT>... Ts>
18 //   struct formatter<pair-or-tuple<Ts...>, charT>
19 
20 // constexpr void constexpr void set_brackets(basic_string_view<charT> opening,
21 //                                            basic_string_view<charT> closing);
22 
23 // Note this tests the basics of this function. It's tested in more detail in
24 // the format functions tests.
25 
26 #include <format>
27 #include <tuple>
28 #include <utility>
29 
30 #include "make_string.h"
31 
32 #define SV(S) MAKE_STRING_VIEW(CharT, S)
33 
34 template <class CharT, class Arg>
35 constexpr void test() {
36   std::formatter<Arg, CharT> formatter;
37   formatter.set_brackets(SV("open"), SV("close"));
38 
39   // Note there is no direct way to validate this function modified the object.
40 }
41 
42 template <class CharT>
43 constexpr void test() {
44   test<CharT, std::tuple<int>>();
45   test<CharT, std::tuple<int, CharT>>();
46   test<CharT, std::pair<int, CharT>>();
47   test<CharT, std::tuple<int, CharT, double>>();
48 }
49 
50 constexpr bool test() {
51   test<char>();
52 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
53   test<wchar_t>();
54 #endif
55 
56   return true;
57 }
58 
59 int main(int, char**) {
60   test();
61   static_assert(test());
62 
63   return 0;
64 }
65