diff options
author | Samuel Benzaquen <sbenza@google.com> | 2022-11-29 08:57:48 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-11-29 08:58:23 -0800 |
commit | 82196f059f213c50738142a799bb166b2971950d (patch) | |
tree | 5dbfdb957de4369303797515ad34d3099aeeece7 /absl/strings/internal/str_format/checker_test.cc | |
parent | 13708db87b1ab69f4f2b3214f3f51e986546f282 (diff) | |
download | abseil-82196f059f213c50738142a799bb166b2971950d.tar.gz abseil-82196f059f213c50738142a799bb166b2971950d.tar.bz2 abseil-82196f059f213c50738142a799bb166b2971950d.zip |
Convert the full parser into constexpr now that Abseil requires C++14, and use
this parser for the static checker.
This fixes some outstanding bugs where the static checker differed from the
dynamic one.
Also, fix `%v` to be accepted with POSIX syntax.
Tested:
Presubmit
TGP OCL:487237262:BASE:490275393:1669141454896:92dd62e3
PiperOrigin-RevId: 491650577
Change-Id: Id138c108187428b3aea46f8887495f1da12c91b2
Diffstat (limited to 'absl/strings/internal/str_format/checker_test.cc')
-rw-r--r-- | absl/strings/internal/str_format/checker_test.cc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/absl/strings/internal/str_format/checker_test.cc b/absl/strings/internal/str_format/checker_test.cc index 680517f7..a86bed38 100644 --- a/absl/strings/internal/str_format/checker_test.cc +++ b/absl/strings/internal/str_format/checker_test.cc @@ -93,6 +93,7 @@ TEST(StrFormatChecker, ValidFormat) { ValidFormat<void (*)(), volatile int*>("%p %p"), // ValidFormat<string_view, const char*, double, void*>( "string_view=%s const char*=%s double=%f void*=%p)"), + ValidFormat<int>("%v"), // ValidFormat<int>("%% %1$d"), // ValidFormat<int>("%1$ld"), // @@ -109,7 +110,9 @@ TEST(StrFormatChecker, ValidFormat) { ValidFormat<int, double>("%2$.*1$f"), // ValidFormat<void*, string_view, const char*, double>( "string_view=%2$s const char*=%3$s double=%4$f void*=%1$p " - "repeat=%3$s)")}; + "repeat=%3$s)"), + ValidFormat<std::string>("%1$v"), + }; for (Case c : trues) { EXPECT_TRUE(c.result) << c.format; @@ -130,6 +133,8 @@ TEST(StrFormatChecker, ValidFormat) { ValidFormat<int>("%*d"), // ValidFormat<std::string>("%p"), // ValidFormat<int (*)(int)>("%d"), // + ValidFormat<int>("%1v"), // + ValidFormat<int>("%.1v"), // ValidFormat<>("%3$d"), // ValidFormat<>("%1$r"), // @@ -138,13 +143,14 @@ TEST(StrFormatChecker, ValidFormat) { ValidFormat<int>("%1$*2$1d"), // ValidFormat<int>("%1$1-d"), // ValidFormat<std::string, int>("%2$*1$s"), // - ValidFormat<std::string>("%1$p"), + ValidFormat<std::string>("%1$p"), // + ValidFormat<int>("%1$*2$v"), // ValidFormat<int, int>("%d %2$d"), // }; for (Case c : falses) { - EXPECT_FALSE(c.result) << c.format; + EXPECT_FALSE(c.result) << "format<" << c.format << ">"; } } |