Fix handling of default alignmment with locale (#1801)
This commit is contained in:
parent
76cfb50b2d
commit
279d698e1b
@ -1613,8 +1613,11 @@ template <typename OutputIt, typename Char, typename UInt> struct int_writer {
|
|||||||
make_checked(p, s.size()));
|
make_checked(p, s.size()));
|
||||||
}
|
}
|
||||||
if (prefix_size != 0) p[-1] = static_cast<Char>('-');
|
if (prefix_size != 0) p[-1] = static_cast<Char>('-');
|
||||||
out = write(out, basic_string_view<Char>(buffer.data(), buffer.size()),
|
using iterator = remove_reference_t<decltype(reserve(out, 0))>;
|
||||||
specs);
|
auto data = buffer.data();
|
||||||
|
out = write_padded<align::right>(out, specs, size, size, [=](iterator it) {
|
||||||
|
return copy_str<Char>(data, data + size, it);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void on_chr() { *out++ = static_cast<Char>(abs_value); }
|
void on_chr() { *out++ = static_cast<Char>(abs_value); }
|
||||||
|
@ -70,6 +70,11 @@ TEST(LocaleTest, Format) {
|
|||||||
fmt::format(small_grouping_loc, "{:L}", max_value<uint32_t>()));
|
fmt::format(small_grouping_loc, "{:L}", max_value<uint32_t>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(LocaleTest, FormatDetaultAlign) {
|
||||||
|
std::locale special_grouping_loc(std::locale(), new special_grouping<char>());
|
||||||
|
EXPECT_EQ(" 12,345", fmt::format(special_grouping_loc, "{:8L}", 12345));
|
||||||
|
}
|
||||||
|
|
||||||
TEST(LocaleTest, WFormat) {
|
TEST(LocaleTest, WFormat) {
|
||||||
std::locale loc(std::locale(), new numpunct<wchar_t>());
|
std::locale loc(std::locale(), new numpunct<wchar_t>());
|
||||||
EXPECT_EQ(L"1234567", fmt::format(std::locale(), L"{:L}", 1234567));
|
EXPECT_EQ(L"1234567", fmt::format(std::locale(), L"{:L}", 1234567));
|
||||||
|
Loading…
Reference in New Issue
Block a user