65 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++14, c++17, c++2010 11// UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME12 13// <format>14 15// template<class charT, formattable<charT>... Ts>16// struct formatter<pair-or-tuple<Ts...>, charT>17 18// constexpr void constexpr void set_brackets(basic_string_view<charT> opening,19// basic_string_view<charT> closing) noexcept;20 21// Note this tests the basics of this function. It's tested in more detail in22// the format functions tests.23 24#include <format>25#include <tuple>26#include <utility>27 28#include "make_string.h"29 30#define SV(S) MAKE_STRING_VIEW(CharT, S)31 32template <class CharT, class Arg>33constexpr void test() {34 std::formatter<Arg, CharT> formatter;35 formatter.set_brackets(SV("open"), SV("close"));36 // Note the SV macro may throw, so can't use it.37 static_assert(noexcept(formatter.set_brackets(std::basic_string_view<CharT>{}, std::basic_string_view<CharT>{})));38 39 // Note there is no direct way to validate this function modified the object.40}41 42template <class CharT>43constexpr 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>>();48}49 50constexpr bool test() {51 test<char>();52#ifndef TEST_HAS_NO_WIDE_CHARACTERS53 test<wchar_t>();54#endif55 56 return true;57}58 59int main(int, char**) {60 test();61 static_assert(test());62 63 return 0;64}65