From 9bb213e9200d5742d3868b217a7010d536414d96 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Thu, 25 Aug 2016 08:38:07 -0700 Subject: [PATCH] FormatError -> format_error --- fmt/format.cc | 6 +- fmt/format.h | 50 ++++---- fmt/printf.h | 12 +- fmt/time.h | 2 +- test/format-test.cc | 274 +++++++++++++++++++++---------------------- test/ostream-test.cc | 14 +-- test/printf-test.cc | 52 ++++---- 7 files changed, 205 insertions(+), 205 deletions(-) diff --git a/fmt/format.cc b/fmt/format.cc index 9f9d6ae1..7fd0308e 100644 --- a/fmt/format.cc +++ b/fmt/format.cc @@ -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::POWERS_OF_10_64[] = { FMT_FUNC void internal::report_unknown_type(char code, const char *type) { (void)type; if (std::isprint(static_cast(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(code), type))); } diff --git a/fmt/format.h b/fmt/format.h index 65ad328b..145de3a1 100644 --- a/fmt/format.h +++ b/fmt/format.h @@ -535,11 +535,11 @@ typedef BasicCStringRef CStringRef; typedef BasicCStringRef 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 { 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::CharPtr CharPtr; Char fill = internal::CharTraits::cast(spec_.fill()); CharPtr out = CharPtr(); @@ -2647,7 +2647,7 @@ void BasicWriter::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(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::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(*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::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::parse_arg_name(const Char *&s) { const char *error = 0; internal::Arg arg = get_arg(BasicStringRef(start, s - start), error); if (error) - FMT_THROW(FormatError(error)); + FMT_THROW(format_error(error)); return arg; } @@ -3595,7 +3595,7 @@ const Char *BasicFormatter::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::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::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::max)()) - FMT_THROW(FormatError("number is too big")); + FMT_THROW(format_error("number is too big")); spec.width_ = static_cast(value); } @@ -3682,12 +3682,12 @@ const Char *BasicFormatter::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::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::max)()) - FMT_THROW(FormatError("number is too big")); + FMT_THROW(format_error("number is too big")); spec.precision_ = static_cast(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::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::format(BasicCStringRef 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); diff --git a/fmt/printf.h b/fmt/printf.h index f0c0b9a2..e83a9976 100644 --- a/fmt/printf.h +++ b/fmt/printf.h @@ -43,13 +43,13 @@ struct IntChecker { class PrecisionHandler : public ArgVisitor { public: void report_unhandled_arg() { - FMT_THROW(FormatError("precision is not integer")); + FMT_THROW(format_error("precision is not integer")); } template int visit_any_int(T value) { if (!IntChecker::is_signed>::fits_in_int(value)) - FMT_THROW(FormatError("number is too big")); + FMT_THROW(format_error("number is too big")); return static_cast(value); } }; @@ -153,7 +153,7 @@ class WidthHandler : public ArgVisitor { 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 @@ -166,7 +166,7 @@ class WidthHandler : public ArgVisitor { } unsigned int_max = std::numeric_limits::max(); if (width > int_max) - FMT_THROW(FormatError("number is too big")); + FMT_THROW(format_error("number is too big")); return static_cast(width); } }; @@ -345,7 +345,7 @@ internal::Arg PrintfFormatter::get_arg(const Char *s, internal::Arg arg = arg_index == std::numeric_limits::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::format(BasicCStringRef format_str) { // Parse type. if (!*s) - FMT_THROW(FormatError("invalid format string")); + FMT_THROW(format_error("invalid format string")); spec.type_ = static_cast(*s++); if (arg.type <= Arg::LAST_INTEGER_TYPE) { // Normalize type. diff --git a/fmt/time.h b/fmt/time.h index ccdad77f..83f742c4 100644 --- a/fmt/time.h +++ b/fmt/time.h @@ -23,7 +23,7 @@ void format_arg(BasicFormatter &f, while (*end && *end != '}') ++end; if (*end != '}') - FMT_THROW(FormatError("missing '}' in format string")); + FMT_THROW(format_error("missing '}' in format string")); internal::MemoryBuffer format; format.append(format_str, end + 1); format[format.size() - 1] = '\0'; diff --git a/test/format-test.cc b/test/format-test.cc index 6d246b93..a92d875f 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -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::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(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(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(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(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(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(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(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(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(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(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(0)), - FormatError, "string pointer is null"); + format_error, "string pointer is null"); } TEST(FormatterTest, FormatSCharString) { @@ -1374,7 +1374,7 @@ void format_arg(fmt::BasicFormatter &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", diff --git a/test/ostream-test.cc b/test/ostream-test.cc index 4081b43f..fa2c40d6 100644 --- a/test/ostream-test.cc +++ b/test/ostream-test.cc @@ -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"))); diff --git a/test/printf-test.cc b/test/printf-test.cc index 6bba02e1..e8df2181 100644 --- a/test/printf-test.cc +++ b/test/printf-test.cc @@ -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(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"); } }