From a7275818f91c54b7e1a70550296394fd0ddb082c Mon Sep 17 00:00:00 2001 From: Jamboree Date: Tue, 9 Jun 2015 23:28:28 +0800 Subject: [PATCH] Add back test code due to merge mistake --- test/format-test.cc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/format-test.cc b/test/format-test.cc index b86d78d2..f30498c6 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -932,6 +932,32 @@ TEST(FormatterTest, RuntimeWidth) { format_str[size + 2] = 0; EXPECT_THROW_MSG(format(format_str, 0), FormatError, "number is too big"); + EXPECT_THROW_MSG(format("{0:{", 0), + FormatError, "invalid format string"); + EXPECT_THROW_MSG(format("{0:{}", 0), + FormatError, "cannot switch from manual to automatic argument indexing"); + EXPECT_THROW_MSG(format("{0:{?}}", 0), + FormatError, "invalid format string"); + EXPECT_THROW_MSG(format("{0:{1}}", 0), + FormatError, "argument index out of range"); + + EXPECT_THROW_MSG(format("{0:{0:}}", 0), + FormatError, "invalid format string"); + + EXPECT_THROW_MSG(format("{0:{1}}", 0, -1), + FormatError, "negative width"); + EXPECT_THROW_MSG(format("{0:{1}}", 0, (INT_MAX + 1u)), + FormatError, "number is too big"); + EXPECT_THROW_MSG(format("{0:{1}}", 0, -1l), + FormatError, "negative width"); + if (fmt::internal::check(sizeof(long) > sizeof(int))) { + long value = INT_MAX; + EXPECT_THROW_MSG(format("{0:{1}}", 0, (value + 1)), + FormatError, "number is too big"); + } + EXPECT_THROW_MSG(format("{0:{1}}", 0, (INT_MAX + 1ul)), + FormatError, "number is too big"); + EXPECT_THROW_MSG(format("{0:{1}}", 0, '0'), FormatError, "width is not integer"); EXPECT_THROW_MSG(format("{0:{1}}", 0, 0.0),