mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-26 00:21:13 +00:00
Test negative precision.
This commit is contained in:
parent
4099a1269b
commit
d0587445cb
@ -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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user