Support fmt::runtime with wchar_t in fmt::format_to_n (#4715)

This commit is contained in:
sunmy2019
2026-03-22 08:10:17 +08:00
committed by GitHub
parent 4968433a6a
commit ea85b81ccd
2 changed files with 30 additions and 2 deletions
+20
View File
@@ -146,6 +146,26 @@ TEST(format_test, wide_format_to_n) {
EXPECT_EQ(L"BC x", fmt::wstring_view(buffer, 4));
}
TEST(format_test, wide_format_to_n_runtime) {
wchar_t buffer[4];
buffer[3] = L'x';
auto result = fmt::format_to_n(buffer, 3, fmt::runtime(L"{}"), 12345);
EXPECT_EQ(5u, result.size);
EXPECT_EQ(buffer + 3, result.out);
EXPECT_EQ(L"123x", fmt::wstring_view(buffer, 4));
buffer[0] = L'x';
buffer[1] = L'x';
buffer[2] = L'x';
result = fmt::format_to_n(buffer, 3, fmt::runtime(L"{}"), L'A');
EXPECT_EQ(1u, result.size);
EXPECT_EQ(buffer + 1, result.out);
EXPECT_EQ(L"Axxx", fmt::wstring_view(buffer, 4));
result = fmt::format_to_n(buffer, 3, fmt::runtime(L"{}{} "), L'B', L'C');
EXPECT_EQ(3u, result.size);
EXPECT_EQ(buffer + 3, result.out);
EXPECT_EQ(L"BC x", fmt::wstring_view(buffer, 4));
}
TEST(xchar_test, named_arg_udl) {
using namespace fmt::literals;
auto udl_a =