summaryrefslogtreecommitdiff
path: root/absl/strings/str_format_test.cc
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2022-09-20 13:24:16 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-09-20 13:25:17 -0700
commit55996e2e30cd0dc3a73dbb233e8620fec1ff36bf (patch)
treeb97f2a8b5b3d4f511c18df889b197afc243cb0d4 /absl/strings/str_format_test.cc
parentd859fafe1ab9edc9c04ca262d9993be82c757881 (diff)
Explicitly disallows modifiers for use with %v.
PiperOrigin-RevId: 475636693 Change-Id: Idb7c2b9c36ad8e59f24ff7df179a207d301d9e89
Diffstat (limited to 'absl/strings/str_format_test.cc')
-rw-r--r--absl/strings/str_format_test.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/absl/strings/str_format_test.cc b/absl/strings/str_format_test.cc
index 9ef69837..2774cfed 100644
--- a/absl/strings/str_format_test.cc
+++ b/absl/strings/str_format_test.cc
@@ -1020,6 +1020,17 @@ TEST_F(ParsedFormatTest, RegressionMixPositional) {
absl::FormatConversionCharSet::o>::New("%1$d %o")));
}
+TEST_F(ParsedFormatTest, DisallowModifiersWithV) {
+ auto f = ParsedFormat<'v'>::New("ABC%80vDEF");
+ EXPECT_EQ(f, nullptr);
+
+ f = ParsedFormat<'v'>::New("ABC%0vDEF");
+ EXPECT_EQ(f, nullptr);
+
+ f = ParsedFormat<'v'>::New("ABC%.1vDEF");
+ EXPECT_EQ(f, nullptr);
+}
+
using FormatWrapperTest = ::testing::Test;
// Plain wrapper for StrFormat.