Don't parse '}' as fill

This commit is contained in:
Victor Zverovich 2022-09-07 17:33:31 -07:00
parent 3176e0fad7
commit ecffca6726
2 changed files with 2 additions and 0 deletions

View File

@ -2395,6 +2395,7 @@ FMT_CONSTEXPR auto parse_align(const Char* begin, const Char* end,
auto c = *begin;
if (c == '{')
return handler.on_error("invalid fill character '{'"), begin;
if (c == '}') return begin;
handler.on_fill(basic_string_view<Char>(begin, to_unsigned(p - begin)));
begin = p + 1;
} else

View File

@ -1205,6 +1205,7 @@ constexpr auto uint128_max = ~static_cast<__uint128_t>(0);
TEST(format_test, format_dec) {
EXPECT_EQ("0", fmt::format("{0}", 0));
EXPECT_EQ("42", fmt::format("{0}", 42));
EXPECT_EQ("42>", fmt::format("{:}>", 42));
EXPECT_EQ("42", fmt::format("{0:d}", 42));
EXPECT_EQ("42", fmt::format("{0}", 42u));
EXPECT_EQ("-42", fmt::format("{0}", -42));