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
9 // UNSUPPORTED: no-localization
10 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
12 // XFAIL: availability-fp_to_chars-missing
16 // template<class... Args>
17 // string format(const locale& loc, format-string<Args...> fmt, const Args&... args);
18 // template<class... Args>
19 // wstring format(const locale& loc, wformat-string<Args...> fmt, const Args&... args);
26 #include "test_macros.h"
27 #include "format_tests.h"
28 #include "string_literal.h"
29 #include "test_format_string.h"
30 #include "assert_macros.h"
31 #include "concat_macros.h"
34 []<class CharT
, class... Args
>(
35 std::basic_string_view
<CharT
> expected
, test_format_string
<CharT
, Args
...> fmt
, Args
&&... args
) constexpr {
36 std::basic_string
<CharT
> out
= std::format(std::locale(), fmt
, std::forward
<Args
>(args
)...);
39 TEST_WRITE_CONCATENATED(
40 "\nFormat string ", fmt
.get(), "\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.
46 // A basic ill-formed test is done in format.locale.verify.cpp
47 // The exceptions are tested by other functions that don't use the basic-format-string as fmt argument.
50 int main(int, char**) {
51 format_tests
<char, execution_modus::full
>(test
, test_exception
);
53 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
54 format_tests_char_to_wchar_t(test
);
55 format_tests
<wchar_t, execution_modus::full
>(test
, test_exception
);