Test negative precision.

This commit is contained in:
Victor Zverovich 2014-06-23 08:39:32 -07:00
parent 4099a1269b
commit d0587445cb
2 changed files with 1 additions and 2 deletions

View File

@ -723,7 +723,6 @@ void fmt::BasicWriter<Char>::PrintfParser::Format(
spec.precision_ = GetIntValue(arg); spec.precision_ = GetIntValue(arg);
else if (!error) else if (!error)
error = "precision is not integer"; error = "precision is not integer";
// TODO: check for negative precision
} }
} }

View File

@ -266,11 +266,11 @@ TEST(PrintfTest, IgnorePrecisionForNonNumericArg) {
TEST(PrintfTest, DynamicPrecision) { TEST(PrintfTest, DynamicPrecision) {
EXPECT_EQ("00042", str(fmt::sprintf("%.*d", 5, 42))); EXPECT_EQ("00042", str(fmt::sprintf("%.*d", 5, 42)));
EXPECT_EQ("42", str(fmt::sprintf("%.*d", -5, 42)));
EXPECT_THROW_MSG(fmt::sprintf("%.*d", 5.0, 42), FormatError, EXPECT_THROW_MSG(fmt::sprintf("%.*d", 5.0, 42), FormatError,
"precision is not integer"); "precision is not integer");
EXPECT_THROW_MSG(fmt::sprintf("%.*d"), FormatError, EXPECT_THROW_MSG(fmt::sprintf("%.*d"), FormatError,
"argument index is out of range in format"); "argument index is out of range in format");
// TODO: more tests
} }
// TODO: test length and type specifier // TODO: test length and type specifier