Implement compile-time checks for dynamic width/precision type

This commit is contained in:
Victor Zverovich
2022-07-22 17:00:40 -07:00
parent bc5c7c50fd
commit 48e0a59222
3 changed files with 23 additions and 3 deletions
+1
View File
@@ -584,6 +584,7 @@ struct test_parse_context {
constexpr int next_arg_id() { return 11; }
template <typename Id> FMT_CONSTEXPR void check_arg_id(Id) {}
FMT_CONSTEXPR void check_dynamic_spec(int) {}
constexpr const char* begin() { return nullptr; }
constexpr const char* end() { return nullptr; }
+1
View File
@@ -2177,6 +2177,7 @@ TEST(format_test, format_string_errors) {
EXPECT_ERROR("{: }", "format specifier requires signed argument", unsigned);
EXPECT_ERROR("{:{}}", "argument not found", int);
EXPECT_ERROR("{:.{}}", "argument not found", double);
EXPECT_ERROR("{:{}}", "width/precision is not integer", int, double);
EXPECT_ERROR("{:.2}", "precision not allowed for this argument type", int);
EXPECT_ERROR("{:s}", "invalid type specifier", int);
EXPECT_ERROR("{:s}", "invalid type specifier", char);