Skip to content

Commit

Permalink
Fix handling of numeric alignment with no width (#675)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Mar 12, 2018
1 parent 9facc11 commit 7db0e94
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -2787,7 +2787,8 @@ void basic_writer<Range>::write_double(T value, const format_specs &spec) {
if (sign) {
*reserve(1) = sign;
sign = 0;
--as.width_;
if (as.width_)
--as.width_;
}
as.align_ = ALIGN_RIGHT;
} else {
Expand Down
1 change: 1 addition & 0 deletions test/format-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ TEST(FormatterTest, NumericAlign) {
format_error, "format specifier requires numeric argument");
EXPECT_THROW_MSG(format("{0:=8}", reinterpret_cast<void*>(0xface)),
format_error, "format specifier requires numeric argument");
EXPECT_EQ(" 1", fmt::format("{:= }", 1.0));
}

TEST(FormatterTest, CenterAlign) {
Expand Down

0 comments on commit 7db0e94

Please sign in to comment.