Throw exception in parse_nonnegative_int if the number is too big.

This commit is contained in:
Victor Zverovich
2014-08-28 06:42:59 -07:00
parent 9646e38c3b
commit 526b7fc91d
4 changed files with 32 additions and 21 deletions
+11 -1
View File
@@ -79,7 +79,7 @@ TEST(PrintfTest, AutomaticArgIndexing) {
TEST(PrintfTest, NumberIsTooBigInArgIndex) {
EXPECT_THROW_MSG(fmt::sprintf(format("%{}$", BIG_NUM)),
FormatError, "invalid format string");
FormatError, "number is too big in format");
EXPECT_THROW_MSG(fmt::sprintf(format("%{}$d", BIG_NUM)),
FormatError, "number is too big in format");
}
@@ -429,3 +429,13 @@ TEST(PrintfTest, Pointer) {
TEST(PrintfTest, Location) {
// TODO: test %n
}
#if FMT_USE_FILE_DESCRIPTORS
TEST(PrintfTest, Examples) {
const char *weekday = "Thursday";
const char *month = "August";
int day = 21;
EXPECT_WRITE(stdout, fmt::printf("%1$s, %3$d %2$s", weekday, month, day),
"Thursday, 21 August");
}
#endif