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
10 // UNSUPPORTED: no-localization
11 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
13 // XFAIL: availability-fp_to_chars-missing
17 // template<class... Args>
18 // string format(const locale& loc, format-string<Args...> fmt, const Args&... args);
19 // template<class... Args>
20 // wstring format(const locale& loc, wformat-string<Args...> fmt, const Args&... args);
27 #include "test_macros.h"
28 #include "format_tests.h"
29 #include "string_literal.h"
30 #include "test_format_string.h"
31 #include "assert_macros.h"
32 #include "concat_macros.h"
35 []<class CharT
, class... Args
>(
36 std::basic_string_view
<CharT
> expected
, test_format_string
<CharT
, Args
...> fmt
, Args
&&... args
) constexpr {
37 std::basic_string
<CharT
> out
= std::format(std::locale(), fmt
, std::forward
<Args
>(args
)...);
40 TEST_WRITE_CONCATENATED(
41 "\nFormat string ", fmt
.get(), "\nExpected output ", expected
, "\nActual output ", out
, '\n'));
44 auto test_exception
= []<class CharT
, class... Args
>(std::string_view
, std::basic_string_view
<CharT
>, Args
&&...) {
45 // After P2216 most exceptions thrown by std::format become ill-formed.
46 // Therefore this tests does nothing.
47 // A basic ill-formed test is done in format.locale.verify.cpp
48 // The exceptions are tested by other functions that don't use the basic-format-string as fmt argument.
51 int main(int, char**) {
52 format_tests
<char, execution_modus::full
>(test
, test_exception
);
54 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
55 format_tests_char_to_wchar_t(test
);
56 format_tests
<wchar_t, execution_modus::full
>(test
, test_exception
);