Use format specifiers when formatting null pointers & strings

This commit is contained in:
vitaut
2015-11-23 21:01:28 -08:00
parent 289885e8c0
commit 1a2a333a1a
2 changed files with 20 additions and 11 deletions

View File

@@ -425,6 +425,7 @@ TEST(PrintfTest, String) {
EXPECT_PRINTF("abc", "%s", "abc");
const char *null_str = 0;
EXPECT_PRINTF("(null)", "%s", null_str);
EXPECT_PRINTF(" (null)", "%10s", null_str);
// TODO: wide string
}
@@ -434,6 +435,7 @@ TEST(PrintfTest, Pointer) {
EXPECT_PRINTF(fmt::format("{}", p), "%p", p);
p = 0;
EXPECT_PRINTF("(nil)", "%p", p);
EXPECT_PRINTF(" (nil)", "%10p", p);
const char *s = "test";
EXPECT_PRINTF(fmt::format("{:p}", s), "%p", s);
const char *null_str = 0;