mirror of
https://github.com/abseil/abseil-cpp.git
synced 2026-06-04 12:07:05 +08:00
Use a proper fix instead of a workaround for a parameter annotated
absl_nonnull since the latest Clang can see through the workaround PiperOrigin-RevId: 764428456 Change-Id: I88398f924333a72abb39ffb87ecbd02f751d89eb
This commit is contained in:
committed by
Copybara-Service
parent
8a5cefc62a
commit
3006ff8b41
@@ -516,14 +516,11 @@ TEST_F(FormatEntryPointTest, SNPrintF) {
|
||||
EXPECT_EQ(result, 17);
|
||||
EXPECT_EQ(std::string(buffer), "NUMBER: 1234567");
|
||||
|
||||
// The `output` parameter is annotated nonnull, but we want to test that
|
||||
// it is never written to if the size is zero.
|
||||
// Use a variable instead of passing nullptr directly to avoid a `-Wnonnull`
|
||||
// warning.
|
||||
char* null_output = nullptr;
|
||||
result =
|
||||
SNPrintF(null_output, 0, "Just checking the %s of the output.", "size");
|
||||
// Test that the buffer is never written to if the size is zero.
|
||||
buffer[0] = '\0';
|
||||
result = SNPrintF(buffer, 0, "Just checking the %s of the output.", "size");
|
||||
EXPECT_EQ(result, 37);
|
||||
EXPECT_EQ(buffer[0], '\0');
|
||||
}
|
||||
|
||||
TEST_F(FormatEntryPointTest, SNPrintFWithV) {
|
||||
@@ -551,14 +548,11 @@ TEST_F(FormatEntryPointTest, SNPrintFWithV) {
|
||||
|
||||
std::string size = "size";
|
||||
|
||||
// The `output` parameter is annotated nonnull, but we want to test that
|
||||
// it is never written to if the size is zero.
|
||||
// Use a variable instead of passing nullptr directly to avoid a `-Wnonnull`
|
||||
// warning.
|
||||
char* null_output = nullptr;
|
||||
result =
|
||||
SNPrintF(null_output, 0, "Just checking the %v of the output.", size);
|
||||
// Test that the buffer is never written to if the size is zero.
|
||||
buffer[0] = '\0';
|
||||
result = SNPrintF(buffer, 0, "Just checking the %v of the output.", size);
|
||||
EXPECT_EQ(result, 37);
|
||||
EXPECT_EQ(buffer[0], '\0');
|
||||
}
|
||||
|
||||
TEST(StrFormat, BehavesAsDocumented) {
|
||||
|
||||
Reference in New Issue
Block a user