mirror of
https://github.com/shadps4-emu/ext-fmt.git
synced 2024-12-04 00:01:06 +00:00
Fix handling of locale separators in FP formatting
This commit is contained in:
parent
395cf0f03e
commit
192f79aaae
@ -2249,7 +2249,7 @@ FMT_CONSTEXPR20 auto do_write_float(OutputIt out, const DecimalFP& fp,
|
||||
if (num_zeros > 0) size += to_unsigned(num_zeros);
|
||||
}
|
||||
auto grouping = Grouping(loc, fspecs.locale);
|
||||
size += to_unsigned(grouping.count_separators(significand_size));
|
||||
size += to_unsigned(grouping.count_separators(exp));
|
||||
return write_padded<align::right>(out, specs, size, [&](iterator it) {
|
||||
if (sign) *it++ = detail::sign<Char>(sign);
|
||||
it = write_significand<Char>(it, significand, significand_size,
|
||||
|
@ -370,10 +370,11 @@ template <typename Char> struct small_grouping : std::numpunct<Char> {
|
||||
|
||||
TEST(locale_test, localized_double) {
|
||||
auto loc = std::locale(std::locale(), new numpunct<char>());
|
||||
EXPECT_EQ("1?23", fmt::format(loc, "{:L}", 1.23));
|
||||
EXPECT_EQ("1?230000", fmt::format(loc, "{:Lf}", 1.23));
|
||||
EXPECT_EQ("1~234?5", fmt::format(loc, "{:L}", 1234.5));
|
||||
EXPECT_EQ("12~000", fmt::format(loc, "{:L}", 12000.0));
|
||||
EXPECT_EQ(fmt::format(loc, "{:L}", 1.23), "1?23");
|
||||
EXPECT_EQ(fmt::format(loc, "{:Lf}", 1.23), "1?230000");
|
||||
EXPECT_EQ(fmt::format(loc, "{:L}", 1234.5), "1~234?5");
|
||||
EXPECT_EQ(fmt::format(loc, "{:L}", 12000.0), "12~000");
|
||||
EXPECT_EQ(fmt::format(loc, "{:8L}", 1230.0), " 1~230");
|
||||
}
|
||||
|
||||
TEST(locale_test, format) {
|
||||
|
Loading…
Reference in New Issue
Block a user