mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-31 03:07:36 +02:00
Check for argument indexing switch
This commit is contained in:
@ -3296,6 +3296,7 @@ class dynamic_specs_handler :
|
|||||||
|
|
||||||
template <typename Id>
|
template <typename Id>
|
||||||
arg_ref_type make_arg_ref(Id arg_id) {
|
arg_ref_type make_arg_ref(Id arg_id) {
|
||||||
|
context_.check_arg_id(arg_id);
|
||||||
return arg_ref_type(arg_id);
|
return arg_ref_type(arg_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1562,6 +1562,10 @@ TEST(FormatTest, DynamicFormatter) {
|
|||||||
EXPECT_EQ("42", format("{:d}", num));
|
EXPECT_EQ("42", format("{:d}", num));
|
||||||
EXPECT_EQ("foo", format("{:s}", str));
|
EXPECT_EQ("foo", format("{:s}", str));
|
||||||
EXPECT_EQ(" 42 foo ", format("{:{}} {:{}}", num, 3, str, 4));
|
EXPECT_EQ(" 42 foo ", format("{:{}} {:{}}", num, 3, str, 4));
|
||||||
|
EXPECT_THROW_MSG(format("{0:{}}", num),
|
||||||
|
format_error, "cannot switch from manual to automatic argument indexing");
|
||||||
|
EXPECT_THROW_MSG(format("{:{0}}", num),
|
||||||
|
format_error, "cannot switch from automatic to manual argument indexing");
|
||||||
EXPECT_THROW_MSG(format("{:=}", str),
|
EXPECT_THROW_MSG(format("{:=}", str),
|
||||||
format_error, "format specifier '=' requires numeric argument");
|
format_error, "format specifier '=' requires numeric argument");
|
||||||
EXPECT_THROW_MSG(format("{:+}", str),
|
EXPECT_THROW_MSG(format("{:+}", str),
|
||||||
|
Reference in New Issue
Block a user