From bbb6b357c7f5f92b883dfd5d97065e76bcce8132 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 10 Apr 2020 07:16:20 -0700 Subject: [PATCH] Add floating-point L specifier (#1624) --- include/fmt/format.h | 1 + test/format-test.cc | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 4e96539f..20d69351 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -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: diff --git a/test/format-test.cc b/test/format-test.cc index e9304cee..6a873185 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -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));