Test and fix handling of exactly MAX_PACKED_ARGS arguments

This commit is contained in:
vitaut 2015-05-01 06:55:26 -07:00
parent 969d1cdbdc
commit 87cb2935f8
2 changed files with 5 additions and 1 deletions

View File

@ -2665,7 +2665,7 @@ inline void set_types(Value *, const Args & ...) {
// argument that marks the end of the list.
template <unsigned N>
struct ArgArraySize {
enum { VALUE = N + (N == 0 || N > ArgList::MAX_PACKED_ARGS ? 1 : 0) };
enum { VALUE = N + (N == 0 || N >= ArgList::MAX_PACKED_ARGS ? 1 : 0) };
};
}
}

View File

@ -574,6 +574,10 @@ TEST(FormatterTest, ManyArgs) {
FormatError, "argument index out of range");
EXPECT_THROW_MSG(TestFormat<21>::format("{21}"),
FormatError, "argument index out of range");
enum { MAX_PACKED_ARGS = fmt::ArgList::MAX_PACKED_ARGS };
std::string format_str = fmt::format("{{{}}}", MAX_PACKED_ARGS + 1);
EXPECT_THROW_MSG(TestFormat<MAX_PACKED_ARGS>::format(format_str),
FormatError, "argument index out of range");
}
#endif