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
6 //===----------------------------------------------------------------------===//
8 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
9 // UNSUPPORTED: no-threads
11 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
13 // TODO FMT This test should not require std::to_chars(floating-point)
14 // XFAIL: availability-fp_to_chars-missing
18 // template<class charT>
19 // struct formatter<thread::id, charT>;
21 // template<class... Args>
22 // string format(format_string<Args...> fmt, Args&&... args);
23 // template<class... Args>
24 // wstring format(wformat_string<Args...> fmt, Args&&... args);
29 #include "assert_macros.h"
30 #include "concat_macros.h"
31 #include "format.functions.tests.h"
32 #include "test_format_string.h"
33 #include "test_macros.h"
35 auto test
= []<class CharT
, class... Args
>(
36 std::basic_string_view
<CharT
> expected
, test_format_string
<CharT
, Args
...> fmt
, Args
&&... args
) {
37 std::basic_string
<CharT
> out
= std::format(fmt
, std::forward
<Args
>(args
)...);
38 TEST_REQUIRE(out
== expected
,
39 TEST_WRITE_CONCATENATED(
40 "\nFormat string ", fmt
, "\nExpected output ", expected
, "\nActual output ", out
, '\n'));
43 auto test_exception
= []<class CharT
, class... Args
>(std::string_view
, std::basic_string_view
<CharT
>, Args
&&...) {
44 // After P2216 most exceptions thrown by std::format become ill-formed.
45 // Therefore this tests does nothing.
48 int main(int, char**) {
49 format_tests
<char>(test
, test_exception
);
51 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
52 format_tests
<wchar_t>(test
, test_exception
);