FormatError -> format_error

This commit is contained in:
Victor Zverovich 2016-08-25 08:38:07 -07:00
parent 2ae6bca488
commit 9bb213e920
7 changed files with 205 additions and 205 deletions

View File

@ -82,7 +82,7 @@ static inline fmt::internal::Null<> strerror_s(char *, std::size_t, ...) {
namespace fmt {
FMT_FUNC internal::RuntimeError::~RuntimeError() throw() {}
FMT_FUNC FormatError::~FormatError() throw() {}
FMT_FUNC format_error::~format_error() throw() {}
FMT_FUNC SystemError::~SystemError() throw() {}
namespace {
@ -296,10 +296,10 @@ const uint64_t internal::BasicData<T>::POWERS_OF_10_64[] = {
FMT_FUNC void internal::report_unknown_type(char code, const char *type) {
(void)type;
if (std::isprint(static_cast<unsigned char>(code))) {
FMT_THROW(FormatError(
FMT_THROW(format_error(
format("unknown format code '{}' for {}", code, type)));
}
FMT_THROW(FormatError(
FMT_THROW(format_error(
format("unknown format code '\\x{:02x}' for {}",
static_cast<unsigned>(code), type)));
}

View File

@ -535,11 +535,11 @@ typedef BasicCStringRef<char> CStringRef;
typedef BasicCStringRef<wchar_t> WCStringRef;
/** A formatting error such as invalid format string. */
class FormatError : public std::runtime_error {
class format_error : public std::runtime_error {
public:
explicit FormatError(CStringRef message)
explicit format_error(CStringRef message)
: std::runtime_error(message.c_str()) {}
~FormatError() throw();
~format_error() throw();
};
namespace internal {
@ -1883,7 +1883,7 @@ class ArgFormatterBase : public ArgVisitor<Impl, void> {
return;
}
if (spec_.align_ == ALIGN_NUMERIC || spec_.flags_ != 0)
FMT_THROW(FormatError("invalid format specifier for char"));
FMT_THROW(format_error("invalid format specifier for char"));
typedef typename BasicWriter<Char>::CharPtr CharPtr;
Char fill = internal::CharTraits<Char>::cast(spec_.fill());
CharPtr out = CharPtr();
@ -2647,7 +2647,7 @@ void BasicWriter<Char>::write_str(
std::size_t str_size = s.size;
if (str_size == 0) {
if (!str_value) {
FMT_THROW(FormatError("string pointer is null"));
FMT_THROW(format_error("string pointer is null"));
}
}
std::size_t precision = static_cast<std::size_t>(spec.precision_);
@ -3496,7 +3496,7 @@ unsigned parse_nonnegative_int(const Char *&s) {
// Convert to unsigned to prevent a warning.
unsigned max_int = (std::numeric_limits<int>::max)();
if (value > max_int)
FMT_THROW(FormatError("number is too big"));
FMT_THROW(format_error("number is too big"));
return value;
}
@ -3504,7 +3504,7 @@ inline void require_numeric_argument(const Arg &arg, char spec) {
if (arg.type > Arg::LAST_NUMERIC_TYPE) {
std::string message =
fmt::format("format specifier '{}' requires numeric argument", spec);
FMT_THROW(fmt::FormatError(message));
FMT_THROW(fmt::format_error(message));
}
}
@ -3513,7 +3513,7 @@ void check_sign(const Char *&s, const Arg &arg) {
char sign = static_cast<char>(*s);
require_numeric_argument(arg, sign);
if (arg.type == Arg::UINT || arg.type == Arg::ULONG_LONG) {
FMT_THROW(FormatError(fmt::format(
FMT_THROW(format_error(fmt::format(
"format specifier '{}' requires signed argument", sign)));
}
++s;
@ -3539,7 +3539,7 @@ inline internal::Arg BasicFormatter<Char, AF>::parse_arg_index(const Char *&s) {
internal::Arg arg = *s < '0' || *s > '9' ?
next_arg(error) : get_arg(internal::parse_nonnegative_int(s), error);
if (error) {
FMT_THROW(FormatError(
FMT_THROW(format_error(
*s != '}' && *s != ':' ? "invalid format string" : error));
}
return arg;
@ -3556,7 +3556,7 @@ inline internal::Arg BasicFormatter<Char, AF>::parse_arg_name(const Char *&s) {
const char *error = 0;
internal::Arg arg = get_arg(BasicStringRef<Char>(start, s - start), error);
if (error)
FMT_THROW(FormatError(error));
FMT_THROW(format_error(error));
return arg;
}
@ -3595,7 +3595,7 @@ const Char *BasicFormatter<Char, ArgFormatter>::format(
if (p != s) {
if (c == '}') break;
if (c == '{')
FMT_THROW(FormatError("invalid fill character '{'"));
FMT_THROW(format_error("invalid fill character '{'"));
s += 2;
spec.fill_ = c;
} else ++s;
@ -3644,12 +3644,12 @@ const Char *BasicFormatter<Char, ArgFormatter>::format(
Arg width_arg = internal::is_name_start(*s) ?
parse_arg_name(s) : parse_arg_index(s);
if (*s++ != '}')
FMT_THROW(FormatError("invalid format string"));
FMT_THROW(format_error("invalid format string"));
ULongLong value = 0;
switch (width_arg.type) {
case Arg::INT:
if (width_arg.int_value < 0)
FMT_THROW(FormatError("negative width"));
FMT_THROW(format_error("negative width"));
value = width_arg.int_value;
break;
case Arg::UINT:
@ -3657,17 +3657,17 @@ const Char *BasicFormatter<Char, ArgFormatter>::format(
break;
case Arg::LONG_LONG:
if (width_arg.long_long_value < 0)
FMT_THROW(FormatError("negative width"));
FMT_THROW(format_error("negative width"));
value = width_arg.long_long_value;
break;
case Arg::ULONG_LONG:
value = width_arg.ulong_long_value;
break;
default:
FMT_THROW(FormatError("width is not integer"));
FMT_THROW(format_error("width is not integer"));
}
if (value > (std::numeric_limits<int>::max)())
FMT_THROW(FormatError("number is too big"));
FMT_THROW(format_error("number is too big"));
spec.width_ = static_cast<int>(value);
}
@ -3682,12 +3682,12 @@ const Char *BasicFormatter<Char, ArgFormatter>::format(
Arg precision_arg = internal::is_name_start(*s) ?
parse_arg_name(s) : parse_arg_index(s);
if (*s++ != '}')
FMT_THROW(FormatError("invalid format string"));
FMT_THROW(format_error("invalid format string"));
ULongLong value = 0;
switch (precision_arg.type) {
case Arg::INT:
if (precision_arg.int_value < 0)
FMT_THROW(FormatError("negative precision"));
FMT_THROW(format_error("negative precision"));
value = precision_arg.int_value;
break;
case Arg::UINT:
@ -3695,23 +3695,23 @@ const Char *BasicFormatter<Char, ArgFormatter>::format(
break;
case Arg::LONG_LONG:
if (precision_arg.long_long_value < 0)
FMT_THROW(FormatError("negative precision"));
FMT_THROW(format_error("negative precision"));
value = precision_arg.long_long_value;
break;
case Arg::ULONG_LONG:
value = precision_arg.ulong_long_value;
break;
default:
FMT_THROW(FormatError("precision is not integer"));
FMT_THROW(format_error("precision is not integer"));
}
if (value > (std::numeric_limits<int>::max)())
FMT_THROW(FormatError("number is too big"));
FMT_THROW(format_error("number is too big"));
spec.precision_ = static_cast<int>(value);
} else {
FMT_THROW(FormatError("missing precision specifier"));
FMT_THROW(format_error("missing precision specifier"));
}
if (arg.type <= Arg::LAST_INTEGER_TYPE || arg.type == Arg::POINTER) {
FMT_THROW(FormatError(
FMT_THROW(format_error(
fmt::format("precision not allowed in {} format specifier",
arg.type == Arg::POINTER ? "pointer" : "integer")));
}
@ -3723,7 +3723,7 @@ const Char *BasicFormatter<Char, ArgFormatter>::format(
}
if (*s++ != '}')
FMT_THROW(FormatError("missing '}' in format string"));
FMT_THROW(format_error("missing '}' in format string"));
// Format argument.
ArgFormatter(*this, spec, s - 1).visit(arg);
@ -3743,7 +3743,7 @@ void BasicFormatter<Char, AF>::format(BasicCStringRef<Char> format_str) {
continue;
}
if (c == '}')
FMT_THROW(FormatError("unmatched '}' in format string"));
FMT_THROW(format_error("unmatched '}' in format string"));
write(writer_, start, s - 1);
internal::Arg arg = internal::is_name_start(*s) ?
parse_arg_name(s) : parse_arg_index(s);

View File

@ -43,13 +43,13 @@ struct IntChecker<true> {
class PrecisionHandler : public ArgVisitor<PrecisionHandler, int> {
public:
void report_unhandled_arg() {
FMT_THROW(FormatError("precision is not integer"));
FMT_THROW(format_error("precision is not integer"));
}
template <typename T>
int visit_any_int(T value) {
if (!IntChecker<std::numeric_limits<T>::is_signed>::fits_in_int(value))
FMT_THROW(FormatError("number is too big"));
FMT_THROW(format_error("number is too big"));
return static_cast<int>(value);
}
};
@ -153,7 +153,7 @@ class WidthHandler : public ArgVisitor<WidthHandler, unsigned> {
explicit WidthHandler(FormatSpec &spec) : spec_(spec) {}
void report_unhandled_arg() {
FMT_THROW(FormatError("width is not integer"));
FMT_THROW(format_error("width is not integer"));
}
template <typename T>
@ -166,7 +166,7 @@ class WidthHandler : public ArgVisitor<WidthHandler, unsigned> {
}
unsigned int_max = std::numeric_limits<int>::max();
if (width > int_max)
FMT_THROW(FormatError("number is too big"));
FMT_THROW(format_error("number is too big"));
return static_cast<unsigned>(width);
}
};
@ -345,7 +345,7 @@ internal::Arg PrintfFormatter<Char, AF>::get_arg(const Char *s,
internal::Arg arg = arg_index == std::numeric_limits<unsigned>::max() ?
next_arg(error) : FormatterBase::get_arg(arg_index - 1, error);
if (error)
FMT_THROW(FormatError(!*s ? "invalid format string" : error));
FMT_THROW(format_error(!*s ? "invalid format string" : error));
return arg;
}
@ -460,7 +460,7 @@ void PrintfFormatter<Char, AF>::format(BasicCStringRef<Char> format_str) {
// Parse type.
if (!*s)
FMT_THROW(FormatError("invalid format string"));
FMT_THROW(format_error("invalid format string"));
spec.type_ = static_cast<char>(*s++);
if (arg.type <= Arg::LAST_INTEGER_TYPE) {
// Normalize type.

View File

@ -23,7 +23,7 @@ void format_arg(BasicFormatter<char, ArgFormatter> &f,
while (*end && *end != '}')
++end;
if (*end != '}')
FMT_THROW(FormatError("missing '}' in format string"));
FMT_THROW(format_error("missing '}' in format string"));
internal::MemoryBuffer<char, internal::INLINE_BUFFER_SIZE> format;
format.append(format_str, end + 1);
format[format.size() - 1] = '\0';

View File

@ -72,7 +72,7 @@ using std::size_t;
using fmt::BasicWriter;
using fmt::format;
using fmt::FormatError;
using fmt::format_error;
using fmt::StringRef;
using fmt::CStringRef;
using fmt::MemoryWriter;
@ -535,9 +535,9 @@ TEST(FormatterTest, Escape) {
}
TEST(FormatterTest, UnmatchedBraces) {
EXPECT_THROW_MSG(format("{"), FormatError, "invalid format string");
EXPECT_THROW_MSG(format("}"), FormatError, "unmatched '}' in format string");
EXPECT_THROW_MSG(format("{0{}"), FormatError, "invalid format string");
EXPECT_THROW_MSG(format("{"), format_error, "invalid format string");
EXPECT_THROW_MSG(format("}"), format_error, "unmatched '}' in format string");
EXPECT_THROW_MSG(format("{0{}"), format_error, "invalid format string");
}
TEST(FormatterTest, NoArgs) {
@ -555,22 +555,22 @@ TEST(FormatterTest, ArgsInDifferentPositions) {
}
TEST(FormatterTest, ArgErrors) {
EXPECT_THROW_MSG(format("{"), FormatError, "invalid format string");
EXPECT_THROW_MSG(format("{?}"), FormatError, "invalid format string");
EXPECT_THROW_MSG(format("{0"), FormatError, "invalid format string");
EXPECT_THROW_MSG(format("{0}"), FormatError, "argument index out of range");
EXPECT_THROW_MSG(format("{"), format_error, "invalid format string");
EXPECT_THROW_MSG(format("{?}"), format_error, "invalid format string");
EXPECT_THROW_MSG(format("{0"), format_error, "invalid format string");
EXPECT_THROW_MSG(format("{0}"), format_error, "argument index out of range");
char format_str[BUFFER_SIZE];
safe_sprintf(format_str, "{%u", INT_MAX);
EXPECT_THROW_MSG(format(format_str), FormatError, "invalid format string");
EXPECT_THROW_MSG(format(format_str), format_error, "invalid format string");
safe_sprintf(format_str, "{%u}", INT_MAX);
EXPECT_THROW_MSG(format(format_str), FormatError,
EXPECT_THROW_MSG(format(format_str), format_error,
"argument index out of range");
safe_sprintf(format_str, "{%u", INT_MAX + 1u);
EXPECT_THROW_MSG(format(format_str), FormatError, "number is too big");
EXPECT_THROW_MSG(format(format_str), format_error, "number is too big");
safe_sprintf(format_str, "{%u}", INT_MAX + 1u);
EXPECT_THROW_MSG(format(format_str), FormatError, "number is too big");
EXPECT_THROW_MSG(format(format_str), format_error, "number is too big");
}
#if FMT_USE_VARIADIC_TEMPLATES
@ -593,13 +593,13 @@ struct TestFormat<0> {
TEST(FormatterTest, ManyArgs) {
EXPECT_EQ("19", TestFormat<20>::format("{19}"));
EXPECT_THROW_MSG(TestFormat<20>::format("{20}"),
FormatError, "argument index out of range");
format_error, "argument index out of range");
EXPECT_THROW_MSG(TestFormat<21>::format("{21}"),
FormatError, "argument index out of range");
format_error, "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");
format_error, "argument index out of range");
}
#endif
@ -609,15 +609,15 @@ TEST(FormatterTest, NamedArg) {
char a = 'A', b = 'B', c = 'C';
EXPECT_EQ("BB/AA/CC", format("{1}{b}/{0}{a}/{2}{c}", FMT_CAPTURE(a, b, c)));
EXPECT_EQ(" A", format("{a:>2}", FMT_CAPTURE(a)));
EXPECT_THROW_MSG(format("{a+}", FMT_CAPTURE(a)), FormatError,
EXPECT_THROW_MSG(format("{a+}", FMT_CAPTURE(a)), format_error,
"missing '}' in format string");
EXPECT_THROW_MSG(format("{a}"), FormatError, "argument not found");
EXPECT_THROW_MSG(format("{d}", FMT_CAPTURE(a, b, c)), FormatError,
EXPECT_THROW_MSG(format("{a}"), format_error, "argument not found");
EXPECT_THROW_MSG(format("{d}", FMT_CAPTURE(a, b, c)), format_error,
"argument not found");
EXPECT_THROW_MSG(format("{a}{}", FMT_CAPTURE(a)),
FormatError, "cannot switch from manual to automatic argument indexing");
format_error, "cannot switch from manual to automatic argument indexing");
EXPECT_THROW_MSG(format("{}{a}", FMT_CAPTURE(a)),
FormatError, "cannot switch from automatic to manual argument indexing");
format_error, "cannot switch from automatic to manual argument indexing");
EXPECT_EQ(" -42", format("{0:{width}}", -42, fmt::arg("width", 4)));
EXPECT_EQ("st", format("{0:.{precision}}", "str", fmt::arg("precision", 2)));
int n = 100;
@ -627,15 +627,15 @@ TEST(FormatterTest, NamedArg) {
TEST(FormatterTest, AutoArgIndex) {
EXPECT_EQ("abc", format("{}{}{}", 'a', 'b', 'c'));
EXPECT_THROW_MSG(format("{0}{}", 'a', 'b'),
FormatError, "cannot switch from manual to automatic argument indexing");
format_error, "cannot switch from manual to automatic argument indexing");
EXPECT_THROW_MSG(format("{}{0}", 'a', 'b'),
FormatError, "cannot switch from automatic to manual argument indexing");
format_error, "cannot switch from automatic to manual argument indexing");
EXPECT_EQ("1.2", format("{:.{}}", 1.2345, 2));
EXPECT_THROW_MSG(format("{0}:.{}", 1.2345, 2),
FormatError, "cannot switch from manual to automatic argument indexing");
format_error, "cannot switch from manual to automatic argument indexing");
EXPECT_THROW_MSG(format("{:.{0}}", 1.2345, 2),
FormatError, "cannot switch from automatic to manual argument indexing");
EXPECT_THROW_MSG(format("{}"), FormatError, "argument index out of range");
format_error, "cannot switch from automatic to manual argument indexing");
EXPECT_THROW_MSG(format("{}"), format_error, "argument index out of range");
}
TEST(FormatterTest, EmptySpecs) {
@ -692,13 +692,13 @@ TEST(FormatterTest, NumericAlign) {
EXPECT_EQ("- 42", format("{0:=5}", -42.0));
EXPECT_EQ("- 42", format("{0:=5}", -42.0l));
EXPECT_THROW_MSG(format("{0:=5", 'c'),
FormatError, "missing '}' in format string");
format_error, "missing '}' in format string");
EXPECT_THROW_MSG(format("{0:=5}", 'c'),
FormatError, "invalid format specifier for char");
format_error, "invalid format specifier for char");
EXPECT_THROW_MSG(format("{0:=5}", "abc"),
FormatError, "format specifier '=' requires numeric argument");
format_error, "format specifier '=' requires numeric argument");
EXPECT_THROW_MSG(format("{0:=8}", reinterpret_cast<void*>(0xface)),
FormatError, "format specifier '=' requires numeric argument");
format_error, "format specifier '=' requires numeric argument");
}
TEST(FormatterTest, CenterAlign) {
@ -720,9 +720,9 @@ TEST(FormatterTest, CenterAlign) {
TEST(FormatterTest, Fill) {
EXPECT_THROW_MSG(format("{0:{<5}", 'c'),
FormatError, "invalid fill character '{'");
format_error, "invalid fill character '{'");
EXPECT_THROW_MSG(format("{0:{<5}}", 'c'),
FormatError, "invalid fill character '{'");
format_error, "invalid fill character '{'");
EXPECT_EQ("**42", format("{0:*>4}", 42));
EXPECT_EQ("**-42", format("{0:*>5}", -42));
EXPECT_EQ("***42", format("{0:*>5}", 42u));
@ -742,23 +742,23 @@ TEST(FormatterTest, PlusSign) {
EXPECT_EQ("-42", format("{0:+}", -42));
EXPECT_EQ("+42", format("{0:+}", 42));
EXPECT_THROW_MSG(format("{0:+}", 42u),
FormatError, "format specifier '+' requires signed argument");
format_error, "format specifier '+' requires signed argument");
EXPECT_EQ("+42", format("{0:+}", 42l));
EXPECT_THROW_MSG(format("{0:+}", 42ul),
FormatError, "format specifier '+' requires signed argument");
format_error, "format specifier '+' requires signed argument");
EXPECT_EQ("+42", format("{0:+}", 42ll));
EXPECT_THROW_MSG(format("{0:+}", 42ull),
FormatError, "format specifier '+' requires signed argument");
format_error, "format specifier '+' requires signed argument");
EXPECT_EQ("+42", format("{0:+}", 42.0));
EXPECT_EQ("+42", format("{0:+}", 42.0l));
EXPECT_THROW_MSG(format("{0:+", 'c'),
FormatError, "missing '}' in format string");
format_error, "missing '}' in format string");
EXPECT_THROW_MSG(format("{0:+}", 'c'),
FormatError, "invalid format specifier for char");
format_error, "invalid format specifier for char");
EXPECT_THROW_MSG(format("{0:+}", "abc"),
FormatError, "format specifier '+' requires numeric argument");
format_error, "format specifier '+' requires numeric argument");
EXPECT_THROW_MSG(format("{0:+}", reinterpret_cast<void*>(0x42)),
FormatError, "format specifier '+' requires numeric argument");
format_error, "format specifier '+' requires numeric argument");
}
TEST(FormatterTest, MinusSign) {
@ -766,23 +766,23 @@ TEST(FormatterTest, MinusSign) {
EXPECT_EQ("-42", format("{0:-}", -42));
EXPECT_EQ("42", format("{0:-}", 42));
EXPECT_THROW_MSG(format("{0:-}", 42u),
FormatError, "format specifier '-' requires signed argument");
format_error, "format specifier '-' requires signed argument");
EXPECT_EQ("42", format("{0:-}", 42l));
EXPECT_THROW_MSG(format("{0:-}", 42ul),
FormatError, "format specifier '-' requires signed argument");
format_error, "format specifier '-' requires signed argument");
EXPECT_EQ("42", format("{0:-}", 42ll));
EXPECT_THROW_MSG(format("{0:-}", 42ull),
FormatError, "format specifier '-' requires signed argument");
format_error, "format specifier '-' requires signed argument");
EXPECT_EQ("42", format("{0:-}", 42.0));
EXPECT_EQ("42", format("{0:-}", 42.0l));
EXPECT_THROW_MSG(format("{0:-", 'c'),
FormatError, "missing '}' in format string");
format_error, "missing '}' in format string");
EXPECT_THROW_MSG(format("{0:-}", 'c'),
FormatError, "invalid format specifier for char");
format_error, "invalid format specifier for char");
EXPECT_THROW_MSG(format("{0:-}", "abc"),
FormatError, "format specifier '-' requires numeric argument");
format_error, "format specifier '-' requires numeric argument");
EXPECT_THROW_MSG(format("{0:-}", reinterpret_cast<void*>(0x42)),
FormatError, "format specifier '-' requires numeric argument");
format_error, "format specifier '-' requires numeric argument");
}
TEST(FormatterTest, SpaceSign) {
@ -790,23 +790,23 @@ TEST(FormatterTest, SpaceSign) {
EXPECT_EQ("-42", format("{0: }", -42));
EXPECT_EQ(" 42", format("{0: }", 42));
EXPECT_THROW_MSG(format("{0: }", 42u),
FormatError, "format specifier ' ' requires signed argument");
format_error, "format specifier ' ' requires signed argument");
EXPECT_EQ(" 42", format("{0: }", 42l));
EXPECT_THROW_MSG(format("{0: }", 42ul),
FormatError, "format specifier ' ' requires signed argument");
format_error, "format specifier ' ' requires signed argument");
EXPECT_EQ(" 42", format("{0: }", 42ll));
EXPECT_THROW_MSG(format("{0: }", 42ull),
FormatError, "format specifier ' ' requires signed argument");
format_error, "format specifier ' ' requires signed argument");
EXPECT_EQ(" 42", format("{0: }", 42.0));
EXPECT_EQ(" 42", format("{0: }", 42.0l));
EXPECT_THROW_MSG(format("{0: ", 'c'),
FormatError, "missing '}' in format string");
format_error, "missing '}' in format string");
EXPECT_THROW_MSG(format("{0: }", 'c'),
FormatError, "invalid format specifier for char");
format_error, "invalid format specifier for char");
EXPECT_THROW_MSG(format("{0: }", "abc"),
FormatError, "format specifier ' ' requires numeric argument");
format_error, "format specifier ' ' requires numeric argument");
EXPECT_THROW_MSG(format("{0: }", reinterpret_cast<void*>(0x42)),
FormatError, "format specifier ' ' requires numeric argument");
format_error, "format specifier ' ' requires numeric argument");
}
TEST(FormatterTest, HashFlag) {
@ -845,13 +845,13 @@ TEST(FormatterTest, HashFlag) {
EXPECT_EQ("-42.0000", format("{0:#}", -42.0));
EXPECT_EQ("-42.0000", format("{0:#}", -42.0l));
EXPECT_THROW_MSG(format("{0:#", 'c'),
FormatError, "missing '}' in format string");
format_error, "missing '}' in format string");
EXPECT_THROW_MSG(format("{0:#}", 'c'),
FormatError, "invalid format specifier for char");
format_error, "invalid format specifier for char");
EXPECT_THROW_MSG(format("{0:#}", "abc"),
FormatError, "format specifier '#' requires numeric argument");
format_error, "format specifier '#' requires numeric argument");
EXPECT_THROW_MSG(format("{0:#}", reinterpret_cast<void*>(0x42)),
FormatError, "format specifier '#' requires numeric argument");
format_error, "format specifier '#' requires numeric argument");
}
TEST(FormatterTest, ZeroFlag) {
@ -865,29 +865,29 @@ TEST(FormatterTest, ZeroFlag) {
EXPECT_EQ("-0042", format("{0:05}", -42.0));
EXPECT_EQ("-0042", format("{0:05}", -42.0l));
EXPECT_THROW_MSG(format("{0:0", 'c'),
FormatError, "missing '}' in format string");
format_error, "missing '}' in format string");
EXPECT_THROW_MSG(format("{0:05}", 'c'),
FormatError, "invalid format specifier for char");
format_error, "invalid format specifier for char");
EXPECT_THROW_MSG(format("{0:05}", "abc"),
FormatError, "format specifier '0' requires numeric argument");
format_error, "format specifier '0' requires numeric argument");
EXPECT_THROW_MSG(format("{0:05}", reinterpret_cast<void*>(0x42)),
FormatError, "format specifier '0' requires numeric argument");
format_error, "format specifier '0' requires numeric argument");
}
TEST(FormatterTest, Width) {
char format_str[BUFFER_SIZE];
safe_sprintf(format_str, "{0:%u", UINT_MAX);
increment(format_str + 3);
EXPECT_THROW_MSG(format(format_str, 0), FormatError, "number is too big");
EXPECT_THROW_MSG(format(format_str, 0), format_error, "number is too big");
std::size_t size = std::strlen(format_str);
format_str[size] = '}';
format_str[size + 1] = 0;
EXPECT_THROW_MSG(format(format_str, 0), FormatError, "number is too big");
EXPECT_THROW_MSG(format(format_str, 0), format_error, "number is too big");
safe_sprintf(format_str, "{0:%u", INT_MAX + 1u);
EXPECT_THROW_MSG(format(format_str, 0), FormatError, "number is too big");
EXPECT_THROW_MSG(format(format_str, 0), format_error, "number is too big");
safe_sprintf(format_str, "{0:%u}", INT_MAX + 1u);
EXPECT_THROW_MSG(format(format_str, 0), FormatError, "number is too big");
EXPECT_THROW_MSG(format(format_str, 0), format_error, "number is too big");
EXPECT_EQ(" -42", format("{0:4}", -42));
EXPECT_EQ(" 42", format("{0:5}", 42u));
EXPECT_EQ(" -42", format("{0:6}", -42l));
@ -905,45 +905,45 @@ TEST(FormatterTest, RuntimeWidth) {
char format_str[BUFFER_SIZE];
safe_sprintf(format_str, "{0:{%u", UINT_MAX);
increment(format_str + 4);
EXPECT_THROW_MSG(format(format_str, 0), FormatError, "number is too big");
EXPECT_THROW_MSG(format(format_str, 0), format_error, "number is too big");
std::size_t size = std::strlen(format_str);
format_str[size] = '}';
format_str[size + 1] = 0;
EXPECT_THROW_MSG(format(format_str, 0), FormatError, "number is too big");
EXPECT_THROW_MSG(format(format_str, 0), format_error, "number is too big");
format_str[size + 1] = '}';
format_str[size + 2] = 0;
EXPECT_THROW_MSG(format(format_str, 0), FormatError, "number is too big");
EXPECT_THROW_MSG(format(format_str, 0), format_error, "number is too big");
EXPECT_THROW_MSG(format("{0:{", 0),
FormatError, "invalid format string");
format_error, "invalid format string");
EXPECT_THROW_MSG(format("{0:{}", 0),
FormatError, "cannot switch from manual to automatic argument indexing");
format_error, "cannot switch from manual to automatic argument indexing");
EXPECT_THROW_MSG(format("{0:{?}}", 0),
FormatError, "invalid format string");
format_error, "invalid format string");
EXPECT_THROW_MSG(format("{0:{1}}", 0),
FormatError, "argument index out of range");
format_error, "argument index out of range");
EXPECT_THROW_MSG(format("{0:{0:}}", 0),
FormatError, "invalid format string");
format_error, "invalid format string");
EXPECT_THROW_MSG(format("{0:{1}}", 0, -1),
FormatError, "negative width");
format_error, "negative width");
EXPECT_THROW_MSG(format("{0:{1}}", 0, (INT_MAX + 1u)),
FormatError, "number is too big");
format_error, "number is too big");
EXPECT_THROW_MSG(format("{0:{1}}", 0, -1l),
FormatError, "negative width");
format_error, "negative width");
if (fmt::internal::const_check(sizeof(long) > sizeof(int))) {
long value = INT_MAX;
EXPECT_THROW_MSG(format("{0:{1}}", 0, (value + 1)),
FormatError, "number is too big");
format_error, "number is too big");
}
EXPECT_THROW_MSG(format("{0:{1}}", 0, (INT_MAX + 1ul)),
FormatError, "number is too big");
format_error, "number is too big");
EXPECT_THROW_MSG(format("{0:{1}}", 0, '0'),
FormatError, "width is not integer");
format_error, "width is not integer");
EXPECT_THROW_MSG(format("{0:{1}}", 0, 0.0),
FormatError, "width is not integer");
format_error, "width is not integer");
EXPECT_EQ(" -42", format("{0:{1}}", -42, 4));
EXPECT_EQ(" 42", format("{0:{1}}", 42u, 5));
@ -963,57 +963,57 @@ TEST(FormatterTest, Precision) {
char format_str[BUFFER_SIZE];
safe_sprintf(format_str, "{0:.%u", UINT_MAX);
increment(format_str + 4);
EXPECT_THROW_MSG(format(format_str, 0), FormatError, "number is too big");
EXPECT_THROW_MSG(format(format_str, 0), format_error, "number is too big");
std::size_t size = std::strlen(format_str);
format_str[size] = '}';
format_str[size + 1] = 0;
EXPECT_THROW_MSG(format(format_str, 0), FormatError, "number is too big");
EXPECT_THROW_MSG(format(format_str, 0), format_error, "number is too big");
safe_sprintf(format_str, "{0:.%u", INT_MAX + 1u);
EXPECT_THROW_MSG(format(format_str, 0), FormatError, "number is too big");
EXPECT_THROW_MSG(format(format_str, 0), format_error, "number is too big");
safe_sprintf(format_str, "{0:.%u}", INT_MAX + 1u);
EXPECT_THROW_MSG(format(format_str, 0), FormatError, "number is too big");
EXPECT_THROW_MSG(format(format_str, 0), format_error, "number is too big");
EXPECT_THROW_MSG(format("{0:.", 0),
FormatError, "missing precision specifier");
format_error, "missing precision specifier");
EXPECT_THROW_MSG(format("{0:.}", 0),
FormatError, "missing precision specifier");
format_error, "missing precision specifier");
EXPECT_THROW_MSG(format("{0:.2", 0),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:.2}", 42),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:.2f}", 42),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:.2}", 42u),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:.2f}", 42u),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:.2}", 42l),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:.2f}", 42l),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:.2}", 42ul),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:.2f}", 42ul),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:.2}", 42ll),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:.2f}", 42ll),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:.2}", 42ull),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:.2f}", 42ull),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:3.0}", 'x'),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_EQ("1.2", format("{0:.2}", 1.2345));
EXPECT_EQ("1.2", format("{0:.2}", 1.2345l));
EXPECT_THROW_MSG(format("{0:.2}", reinterpret_cast<void*>(0xcafe)),
FormatError, "precision not allowed in pointer format specifier");
format_error, "precision not allowed in pointer format specifier");
EXPECT_THROW_MSG(format("{0:.2f}", reinterpret_cast<void*>(0xcafe)),
FormatError, "precision not allowed in pointer format specifier");
format_error, "precision not allowed in pointer format specifier");
EXPECT_EQ("st", format("{0:.2}", "str"));
}
@ -1022,81 +1022,81 @@ TEST(FormatterTest, RuntimePrecision) {
char format_str[BUFFER_SIZE];
safe_sprintf(format_str, "{0:.{%u", UINT_MAX);
increment(format_str + 5);
EXPECT_THROW_MSG(format(format_str, 0), FormatError, "number is too big");
EXPECT_THROW_MSG(format(format_str, 0), format_error, "number is too big");
std::size_t size = std::strlen(format_str);
format_str[size] = '}';
format_str[size + 1] = 0;
EXPECT_THROW_MSG(format(format_str, 0), FormatError, "number is too big");
EXPECT_THROW_MSG(format(format_str, 0), format_error, "number is too big");
format_str[size + 1] = '}';
format_str[size + 2] = 0;
EXPECT_THROW_MSG(format(format_str, 0), FormatError, "number is too big");
EXPECT_THROW_MSG(format(format_str, 0), format_error, "number is too big");
EXPECT_THROW_MSG(format("{0:.{", 0),
FormatError, "invalid format string");
format_error, "invalid format string");
EXPECT_THROW_MSG(format("{0:.{}", 0),
FormatError, "cannot switch from manual to automatic argument indexing");
format_error, "cannot switch from manual to automatic argument indexing");
EXPECT_THROW_MSG(format("{0:.{?}}", 0),
FormatError, "invalid format string");
format_error, "invalid format string");
EXPECT_THROW_MSG(format("{0:.{1}", 0, 0),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:.{1}}", 0),
FormatError, "argument index out of range");
format_error, "argument index out of range");
EXPECT_THROW_MSG(format("{0:.{0:}}", 0),
FormatError, "invalid format string");
format_error, "invalid format string");
EXPECT_THROW_MSG(format("{0:.{1}}", 0, -1),
FormatError, "negative precision");
format_error, "negative precision");
EXPECT_THROW_MSG(format("{0:.{1}}", 0, (INT_MAX + 1u)),
FormatError, "number is too big");
format_error, "number is too big");
EXPECT_THROW_MSG(format("{0:.{1}}", 0, -1l),
FormatError, "negative precision");
format_error, "negative precision");
if (fmt::internal::const_check(sizeof(long) > sizeof(int))) {
long value = INT_MAX;
EXPECT_THROW_MSG(format("{0:.{1}}", 0, (value + 1)),
FormatError, "number is too big");
format_error, "number is too big");
}
EXPECT_THROW_MSG(format("{0:.{1}}", 0, (INT_MAX + 1ul)),
FormatError, "number is too big");
format_error, "number is too big");
EXPECT_THROW_MSG(format("{0:.{1}}", 0, '0'),
FormatError, "precision is not integer");
format_error, "precision is not integer");
EXPECT_THROW_MSG(format("{0:.{1}}", 0, 0.0),
FormatError, "precision is not integer");
format_error, "precision is not integer");
EXPECT_THROW_MSG(format("{0:.{1}}", 42, 2),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:.{1}f}", 42, 2),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:.{1}}", 42u, 2),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:.{1}f}", 42u, 2),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:.{1}}", 42l, 2),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:.{1}f}", 42l, 2),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:.{1}}", 42ul, 2),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:.{1}f}", 42ul, 2),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:.{1}}", 42ll, 2),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:.{1}f}", 42ll, 2),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:.{1}}", 42ull, 2),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:.{1}f}", 42ull, 2),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_THROW_MSG(format("{0:3.{1}}", 'x', 0),
FormatError, "precision not allowed in integer format specifier");
format_error, "precision not allowed in integer format specifier");
EXPECT_EQ("1.2", format("{0:.{1}}", 1.2345, 2));
EXPECT_EQ("1.2", format("{1:.{0}}", 2, 1.2345l));
EXPECT_THROW_MSG(format("{0:.{1}}", reinterpret_cast<void*>(0xcafe), 2),
FormatError, "precision not allowed in pointer format specifier");
format_error, "precision not allowed in pointer format specifier");
EXPECT_THROW_MSG(format("{0:.{1}f}", reinterpret_cast<void*>(0xcafe), 2),
FormatError, "precision not allowed in pointer format specifier");
format_error, "precision not allowed in pointer format specifier");
EXPECT_EQ("st", format("{0:.{1}}", "str", 2));
}
@ -1116,7 +1116,7 @@ void check_unknown_types(
safe_sprintf(message, "unknown format code '\\x%02x' for %s", c,
type_name);
}
EXPECT_THROW_MSG(format(format_str, value), FormatError, message)
EXPECT_THROW_MSG(format(format_str, value), format_error, message)
<< format_str << " " << message;
}
}
@ -1138,7 +1138,7 @@ TEST(FormatterTest, FormatShort) {
TEST(FormatterTest, FormatInt) {
EXPECT_THROW_MSG(format("{0:v", 42),
FormatError, "missing '}' in format string");
format_error, "missing '}' in format string");
check_unknown_types(42, "bBdoxXn", "integer");
}
@ -1328,7 +1328,7 @@ TEST(FormatterTest, FormatCString) {
char nonconst[] = "nonconst";
EXPECT_EQ("nonconst", format("{0}", nonconst));
EXPECT_THROW_MSG(format("{0}", reinterpret_cast<const char*>(0)),
FormatError, "string pointer is null");
format_error, "string pointer is null");
}
TEST(FormatterTest, FormatSCharString) {
@ -1374,7 +1374,7 @@ void format_arg(fmt::BasicFormatter<char> &f, const char *, const Date &d) {
TEST(FormatterTest, FormatCustom) {
Date date(2012, 12, 9);
EXPECT_THROW_MSG(fmt::format("{:s}", date), FormatError,
EXPECT_THROW_MSG(fmt::format("{:s}", date), format_error,
"unmatched '}' in format string");
}
@ -1477,7 +1477,7 @@ TEST(FormatterTest, Examples) {
EXPECT_EQ("The answer is 42", format("The answer is {}", 42));
EXPECT_THROW_MSG(
format("The answer is {:d}", "forty-two"), FormatError,
format("The answer is {:d}", "forty-two"), format_error,
"unknown format code 'd' for string");
EXPECT_EQ(L"Cyrillic letter \x42e",

View File

@ -33,7 +33,7 @@
#include "util.h"
using fmt::format;
using fmt::FormatError;
using fmt::format_error;
std::ostream &operator<<(std::ostream &os, const Date &d) {
os << d.year() << '-' << d.month() << '-' << d.day();
@ -87,19 +87,19 @@ TEST(OStreamTest, FormatSpecs) {
EXPECT_EQ("def ", format("{0:<5}", TestString("def")));
EXPECT_EQ(" def", format("{0:>5}", TestString("def")));
EXPECT_THROW_MSG(format("{0:=5}", TestString("def")),
FormatError, "format specifier '=' requires numeric argument");
format_error, "format specifier '=' requires numeric argument");
EXPECT_EQ(" def ", format("{0:^5}", TestString("def")));
EXPECT_EQ("def**", format("{0:*<5}", TestString("def")));
EXPECT_THROW_MSG(format("{0:+}", TestString()),
FormatError, "format specifier '+' requires numeric argument");
format_error, "format specifier '+' requires numeric argument");
EXPECT_THROW_MSG(format("{0:-}", TestString()),
FormatError, "format specifier '-' requires numeric argument");
format_error, "format specifier '-' requires numeric argument");
EXPECT_THROW_MSG(format("{0: }", TestString()),
FormatError, "format specifier ' ' requires numeric argument");
format_error, "format specifier ' ' requires numeric argument");
EXPECT_THROW_MSG(format("{0:#}", TestString()),
FormatError, "format specifier '#' requires numeric argument");
format_error, "format specifier '#' requires numeric argument");
EXPECT_THROW_MSG(format("{0:05}", TestString()),
FormatError, "format specifier '0' requires numeric argument");
format_error, "format specifier '0' requires numeric argument");
EXPECT_EQ("test ", format("{0:13}", TestString("test")));
EXPECT_EQ("test ", format("{0:{1}}", TestString("test"), 13));
EXPECT_EQ("te", format("{0:.2}", TestString("test")));

View File

@ -35,7 +35,7 @@
#include "util.h"
using fmt::format;
using fmt::FormatError;
using fmt::format_error;
const unsigned BIG_NUM = INT_MAX + 1u;
@ -80,45 +80,45 @@ TEST(PrintfTest, AutomaticArgIndexing) {
TEST(PrintfTest, NumberIsTooBigInArgIndex) {
EXPECT_THROW_MSG(fmt::sprintf(format("%{}$", BIG_NUM)),
FormatError, "number is too big");
format_error, "number is too big");
EXPECT_THROW_MSG(fmt::sprintf(format("%{}$d", BIG_NUM)),
FormatError, "number is too big");
format_error, "number is too big");
}
TEST(PrintfTest, SwitchArgIndexing) {
EXPECT_THROW_MSG(fmt::sprintf("%1$d%", 1, 2),
FormatError, "invalid format string");
format_error, "invalid format string");
EXPECT_THROW_MSG(fmt::sprintf(format("%1$d%{}d", BIG_NUM), 1, 2),
FormatError, "number is too big");
format_error, "number is too big");
EXPECT_THROW_MSG(fmt::sprintf("%1$d%d", 1, 2),
FormatError, "cannot switch from manual to automatic argument indexing");
format_error, "cannot switch from manual to automatic argument indexing");
EXPECT_THROW_MSG(fmt::sprintf("%d%1$", 1, 2),
FormatError, "invalid format string");
format_error, "invalid format string");
EXPECT_THROW_MSG(fmt::sprintf(format("%d%{}$d", BIG_NUM), 1, 2),
FormatError, "number is too big");
format_error, "number is too big");
EXPECT_THROW_MSG(fmt::sprintf("%d%1$d", 1, 2),
FormatError, "cannot switch from automatic to manual argument indexing");
format_error, "cannot switch from automatic to manual argument indexing");
// Indexing errors override width errors.
EXPECT_THROW_MSG(fmt::sprintf(format("%d%1${}d", BIG_NUM), 1, 2),
FormatError, "number is too big");
format_error, "number is too big");
EXPECT_THROW_MSG(fmt::sprintf(format("%1$d%{}d", BIG_NUM), 1, 2),
FormatError, "number is too big");
format_error, "number is too big");
}
TEST(PrintfTest, InvalidArgIndex) {
EXPECT_THROW_MSG(fmt::sprintf("%0$d", 42), FormatError,
EXPECT_THROW_MSG(fmt::sprintf("%0$d", 42), format_error,
"argument index out of range");
EXPECT_THROW_MSG(fmt::sprintf("%2$d", 42), FormatError,
EXPECT_THROW_MSG(fmt::sprintf("%2$d", 42), format_error,
"argument index out of range");
EXPECT_THROW_MSG(fmt::sprintf(format("%{}$d", INT_MAX), 42),
FormatError, "argument index out of range");
format_error, "argument index out of range");
EXPECT_THROW_MSG(fmt::sprintf("%2$", 42),
FormatError, "invalid format string");
format_error, "invalid format string");
EXPECT_THROW_MSG(fmt::sprintf(format("%{}$d", BIG_NUM), 42),
FormatError, "number is too big");
format_error, "number is too big");
}
TEST(PrintfTest, DefaultAlignRight) {
@ -204,23 +204,23 @@ TEST(PrintfTest, Width) {
EXPECT_PRINTF(" abc", "%5s", "abc");
// Width cannot be specified twice.
EXPECT_THROW_MSG(fmt::sprintf("%5-5d", 42), FormatError,
EXPECT_THROW_MSG(fmt::sprintf("%5-5d", 42), format_error,
"unknown format code '-' for integer");
EXPECT_THROW_MSG(fmt::sprintf(format("%{}d", BIG_NUM), 42),
FormatError, "number is too big");
format_error, "number is too big");
EXPECT_THROW_MSG(fmt::sprintf(format("%1${}d", BIG_NUM), 42),
FormatError, "number is too big");
format_error, "number is too big");
}
TEST(PrintfTest, DynamicWidth) {
EXPECT_EQ(" 42", fmt::sprintf("%*d", 5, 42));
EXPECT_EQ("42 ", fmt::sprintf("%*d", -5, 42));
EXPECT_THROW_MSG(fmt::sprintf("%*d", 5.0, 42), FormatError,
EXPECT_THROW_MSG(fmt::sprintf("%*d", 5.0, 42), format_error,
"width is not integer");
EXPECT_THROW_MSG(fmt::sprintf("%*d"), FormatError,
EXPECT_THROW_MSG(fmt::sprintf("%*d"), format_error,
"argument index out of range");
EXPECT_THROW_MSG(fmt::sprintf("%*d", BIG_NUM, 42), FormatError,
EXPECT_THROW_MSG(fmt::sprintf("%*d", BIG_NUM, 42), format_error,
"number is too big");
}
@ -263,15 +263,15 @@ TEST(PrintfTest, IgnorePrecisionForNonNumericArg) {
TEST(PrintfTest, DynamicPrecision) {
EXPECT_EQ("00042", fmt::sprintf("%.*d", 5, 42));
EXPECT_EQ("42", fmt::sprintf("%.*d", -5, 42));
EXPECT_THROW_MSG(fmt::sprintf("%.*d", 5.0, 42), FormatError,
EXPECT_THROW_MSG(fmt::sprintf("%.*d", 5.0, 42), format_error,
"precision is not integer");
EXPECT_THROW_MSG(fmt::sprintf("%.*d"), FormatError,
EXPECT_THROW_MSG(fmt::sprintf("%.*d"), format_error,
"argument index out of range");
EXPECT_THROW_MSG(fmt::sprintf("%.*d", BIG_NUM, 42), FormatError,
EXPECT_THROW_MSG(fmt::sprintf("%.*d", BIG_NUM, 42), format_error,
"number is too big");
if (sizeof(fmt::LongLong) != sizeof(int)) {
fmt::LongLong prec = static_cast<fmt::LongLong>(INT_MIN) - 1;
EXPECT_THROW_MSG(fmt::sprintf("%.*d", prec, 42), FormatError,
EXPECT_THROW_MSG(fmt::sprintf("%.*d", prec, 42), format_error,
"number is too big");
}
}