Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / utilities / format / format.tuple / set_brackets.pass.cpp
blobb04800867ba8250c4f58a9ea7978cf1b7eb6074b
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 //===----------------------------------------------------------------------===//
8 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
10 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
12 // <format>
14 // template<class charT, formattable<charT>... Ts>
15 // struct formatter<pair-or-tuple<Ts...>, charT>
17 // constexpr void constexpr void set_brackets(basic_string_view<charT> opening,
18 // basic_string_view<charT> closing) noexcept;
20 // Note this tests the basics of this function. It's tested in more detail in
21 // the format functions tests.
23 #include <format>
24 #include <tuple>
25 #include <utility>
27 #include "make_string.h"
29 #define SV(S) MAKE_STRING_VIEW(CharT, S)
31 template <class CharT, class Arg>
32 constexpr void test() {
33 std::formatter<Arg, CharT> formatter;
34 formatter.set_brackets(SV("open"), SV("close"));
35 // Note the SV macro may throw, so can't use it.
36 static_assert(noexcept(formatter.set_brackets(std::basic_string_view<CharT>{}, std::basic_string_view<CharT>{})));
38 // Note there is no direct way to validate this function modified the object.
41 template <class CharT>
42 constexpr void test() {
43 test<CharT, std::tuple<int>>();
44 test<CharT, std::tuple<int, CharT>>();
45 test<CharT, std::pair<int, CharT>>();
46 test<CharT, std::tuple<int, CharT, bool>>();
49 constexpr bool test() {
50 test<char>();
51 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
52 test<wchar_t>();
53 #endif
55 return true;
58 int main(int, char**) {
59 test();
60 static_assert(test());
62 return 0;