Skip to content

Commit 47d467e

Browse files
pl98copybara-github
authored andcommitted
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
1 parent 5be22f9 commit 47d467e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

absl/strings/str_format_test.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,8 @@ TEST(StrFormat, BehavesAsDocumented) {
638638
EXPECT_EQ(StrFormat("%#o", 10), "012");
639639
EXPECT_EQ(StrFormat("%#x", 15), "0xf");
640640
EXPECT_EQ(StrFormat("%04d", 8), "0008");
641+
EXPECT_EQ(StrFormat("%#04x", 0), "0000");
642+
EXPECT_EQ(StrFormat("%#04x", 1), "0x01");
641643
// Posix positional substitution.
642644
EXPECT_EQ(absl::StrFormat("%2$s, %3$s, %1$s!", "vici", "veni", "vidi"),
643645
"veni, vidi, vici!");

0 commit comments

Comments
 (0)