[BOLT] Add --pad-funcs-before=func:n (#117924)
[llvm-project.git] / libcxx / test / std / utilities / format / format.tuple / set_separator.pass.cpp
blob246de50783075c36d842740a48ff572bfa0a6029
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
11 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
13 // <format>
15 // class range_formatter
16 // template<class charT, formattable<charT>... Ts>
17 // struct formatter<pair-or-tuple<Ts...>, charT>
19 // constexpr void set_separator(basic_string_view<charT> sep) noexcept;
21 // Note this tests the basics of this function. It's tested in more detail in
22 // the format functions tests.
24 #include <format>
25 #include <tuple>
26 #include <utility>
28 #include "make_string.h"
30 #define SV(S) MAKE_STRING_VIEW(CharT, S)
32 template <class CharT, class Arg>
33 constexpr void test() {
34 std::formatter<Arg, CharT> formatter;
35 formatter.set_separator(SV("sep"));
36 // Note the SV macro may throw, so can't use it.
37 static_assert(noexcept(formatter.set_separator(std::basic_string_view<CharT>{})));
39 // Note there is no direct way to validate this function modified the object.
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, bool>>();
50 constexpr bool test() {
51 test<char>();
52 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
53 test<wchar_t>();
54 #endif
56 return true;
59 int main(int, char**) {
60 test();
61 static_assert(test());
63 return 0;