@@ -516,14 +516,11 @@ TEST_F(FormatEntryPointTest, SNPrintF) {
516516 EXPECT_EQ (result, 17 );
517517 EXPECT_EQ (std::string (buffer), " NUMBER: 1234567" );
518518
519- // The `output` parameter is annotated nonnull, but we want to test that
520- // it is never written to if the size is zero.
521- // Use a variable instead of passing nullptr directly to avoid a `-Wnonnull`
522- // warning.
523- char * null_output = nullptr ;
524- result =
525- SNPrintF (null_output, 0 , " Just checking the %s of the output." , " size" );
519+ // Test that the buffer is never written to if the size is zero.
520+ buffer[0 ] = ' \0 ' ;
521+ result = SNPrintF (buffer, 0 , " Just checking the %s of the output." , " size" );
526522 EXPECT_EQ (result, 37 );
523+ EXPECT_EQ (buffer[0 ], ' \0 ' );
527524}
528525
529526TEST_F (FormatEntryPointTest, SNPrintFWithV) {
@@ -551,14 +548,11 @@ TEST_F(FormatEntryPointTest, SNPrintFWithV) {
551548
552549 std::string size = " size" ;
553550
554- // The `output` parameter is annotated nonnull, but we want to test that
555- // it is never written to if the size is zero.
556- // Use a variable instead of passing nullptr directly to avoid a `-Wnonnull`
557- // warning.
558- char * null_output = nullptr ;
559- result =
560- SNPrintF (null_output, 0 , " Just checking the %v of the output." , size);
551+ // Test that the buffer is never written to if the size is zero.
552+ buffer[0 ] = ' \0 ' ;
553+ result = SNPrintF (buffer, 0 , " Just checking the %v of the output." , size);
561554 EXPECT_EQ (result, 37 );
555+ EXPECT_EQ (buffer[0 ], ' \0 ' );
562556}
563557
564558TEST (StrFormat, BehavesAsDocumented) {
0 commit comments