Add floating-point L specifier (#1624)

This commit is contained in:
Victor Zverovich 2020-04-10 07:16:20 -07:00
parent 36ea32640f
commit bbb6b357c7
2 changed files with 3 additions and 1 deletions

View File

@ -1287,6 +1287,7 @@ FMT_CONSTEXPR float_specs parse_float_type_spec(
result.format = float_format::hex;
break;
case 'n':
case 'L':
result.locale = true;
break;
default:

View File

@ -1413,7 +1413,7 @@ TEST(FormatterTest, FormatFloat) {
}
TEST(FormatterTest, FormatDouble) {
check_unknown_types(1.2, "eEfFgGaAn%", "double");
check_unknown_types(1.2, "eEfFgGaAnL%", "double");
EXPECT_EQ("0.0", format("{:}", 0.0));
EXPECT_EQ("0.000000", format("{:f}", 0.0));
EXPECT_EQ("0", format("{:g}", 0.0));
@ -1422,6 +1422,7 @@ TEST(FormatterTest, FormatDouble) {
EXPECT_EQ("392.65", format("{:G}", 392.65));
EXPECT_EQ("392.650000", format("{:f}", 392.65));
EXPECT_EQ("392.650000", format("{:F}", 392.65));
EXPECT_EQ("42", format("{:L}", 42.0));
char buffer[BUFFER_SIZE];
safe_sprintf(buffer, "%e", 392.65);
EXPECT_EQ(buffer, format("{0:e}", 392.65));