Test negative precision.

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

No files matched your search

-1
View File
@@ -723,7 +723,6 @@ void fmt::BasicWriter<Char>::PrintfParser::Format(
spec.precision_ = GetIntValue(arg);
else if (!error)
error = "precision is not integer";
// TODO: check for negative precision
}
}
+1 -1
View File
@@ -266,11 +266,11 @@ TEST(PrintfTest, IgnorePrecisionForNonNumericArg) {
TEST(PrintfTest, DynamicPrecision) {
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,
"precision is not integer");
EXPECT_THROW_MSG(fmt::sprintf("%.*d"), FormatError,
"argument index is out of range in format");
// TODO: more tests
}
// TODO: test length and type specifier