1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
10 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
12 // XFAIL: availability-fp_to_chars-missing
16 // template<class charT, formattable<charT>... Ts>
17 // struct formatter<pair-or-tuple<Ts...>, charT>
19 // tested in the format functions
21 // string vformat(string_view fmt, format_args args);
22 // wstring vformat(wstring_view fmt, wformat_args args);
27 #include "test_macros.h"
28 #include "format.functions.tests.h"
29 #include "assert_macros.h"
30 #include "concat_macros.h"
32 auto test
= []<class CharT
, class... Args
>(
33 std::basic_string_view
<CharT
> expected
, std::basic_string_view
<CharT
> fmt
, Args
&&... args
) {
34 std::basic_string
<CharT
> out
= std::vformat(fmt
, std::make_format_args
<context_t
<CharT
>>(args
...));
35 TEST_REQUIRE(out
== expected
,
36 TEST_WRITE_CONCATENATED(
37 "\nFormat string ", fmt
, "\nExpected output ", expected
, "\nActual output ", out
, '\n'));
41 []<class CharT
, class... Args
>(
42 [[maybe_unused
]] std::string_view what
,
43 [[maybe_unused
]] std::basic_string_view
<CharT
> fmt
,
44 [[maybe_unused
]] Args
&&... args
) {
45 TEST_VALIDATE_EXCEPTION(
47 [&]([[maybe_unused
]] const std::format_error
& e
) {
50 TEST_WRITE_CONCATENATED(
51 "\nFormat string ", fmt
, "\nExpected exception ", what
, "\nActual exception ", e
.what(), '\n'));
53 TEST_IGNORE_NODISCARD
std::vformat(fmt
, std::make_format_args
<context_t
<CharT
>>(args
...)));
56 int main(int, char**) {
57 run_tests
<char>(test
, test_exception
);
59 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
60 run_tests
<wchar_t>(test
, test_exception
);