summaryrefslogtreecommitdiff
path: root/absl/strings
diff options
context:
space:
mode:
authorGravatar Phoebe Liang <phoebeliang@google.com>2023-07-18 14:14:23 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2023-07-18 14:15:15 -0700
commit47d467e44bea8d799f78490658a6fdd830d1347c (patch)
tree802c93d5baf824013d9fa179ea0565724eb3aa14 /absl/strings
parent5be22f98733c674d532598454ae729253bc53e82 (diff)
Add tests for the "%#04x" pattern
Verifies that values other than 0 are prepended with "0x", while 0 is printed as "0000". PiperOrigin-RevId: 549108651 Change-Id: Ib0f87d42066c46f3a5d4b05ca5c9d7ac17be9b66
Diffstat (limited to 'absl/strings')
-rw-r--r--absl/strings/str_format_test.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/absl/strings/str_format_test.cc b/absl/strings/str_format_test.cc
index 5198fb33..20fd0289 100644
--- a/absl/strings/str_format_test.cc
+++ b/absl/strings/str_format_test.cc
@@ -638,6 +638,8 @@ TEST(StrFormat, BehavesAsDocumented) {
EXPECT_EQ(StrFormat("%#o", 10), "012");
EXPECT_EQ(StrFormat("%#x", 15), "0xf");
EXPECT_EQ(StrFormat("%04d", 8), "0008");
+ EXPECT_EQ(StrFormat("%#04x", 0), "0000");
+ EXPECT_EQ(StrFormat("%#04x", 1), "0x01");
// Posix positional substitution.
EXPECT_EQ(absl::StrFormat("%2$s, %3$s, %1$s!", "vici", "veni", "vidi"),
"veni, vidi, vici!");