make plus flag for printf not be ignored for char argument

This commit is contained in:
rimathia 2020-05-14 16:46:09 +02:00
parent 922ea924bf
commit d8d4f2611f
2 changed files with 5 additions and 1 deletions

View File

@ -257,7 +257,7 @@ class printf_arg_formatter : public detail::arg_formatter_base<Range> {
return (*this)(static_cast<int>(value));
fmt_specs.sign = sign::none;
fmt_specs.alt = false;
fmt_specs.align = align::right;
if (fmt_specs.align == align::numeric) fmt_specs.align = align::right;
return base::operator()(value);
} else {
return base::operator()(value);

View File

@ -156,6 +156,10 @@ TEST(PrintfTest, PlusFlag) {
TEST(PrintfTest, MinusFlag) {
EXPECT_PRINTF("abc ", "%-5s", "abc");
EXPECT_PRINTF("abc ", "%0--5s", "abc");
EXPECT_PRINTF("7 ", "%-5d", 7);
EXPECT_PRINTF("97 ", "%-5hhi", 'a');
EXPECT_PRINTF("a ", "%-5c", 'a');
}
TEST(PrintfTest, SpaceFlag) {