Skip to content

Commit

Permalink
Fix handling of thousands separator (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Jul 11, 2016
1 parent 116914a commit 11bc4b1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,7 @@ inline void format_decimal(Char *buffer, UInt value, unsigned num_digits,
}
unsigned index = static_cast<unsigned>(value * 2);
*--buffer = Data::DIGITS[index + 1];
thousands_sep(buffer);
*--buffer = Data::DIGITS[index];
}

Expand Down
3 changes: 2 additions & 1 deletion test/format-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,8 @@ TEST(FormatterTest, FormatIntLocale) {
lconv lc = {};
char sep[] = "--";
lc.thousands_sep = sep;
EXPECT_CALL(mock, localeconv()).WillOnce(testing::Return(&lc));
EXPECT_CALL(mock, localeconv()).Times(2).WillRepeatedly(testing::Return(&lc));
EXPECT_EQ("1--234", format("{:n}", 1234));
EXPECT_EQ("1--234--567", format("{:n}", 1234567));
}

Expand Down

0 comments on commit 11bc4b1

Please sign in to comment.