Commit 47d467e4 by Phoebe Liang Committed by Copybara-Service

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
parent 5be22f98
......@@ -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!");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment