Mark InternalDefaultActionSetAt as nodiscard.

PiperOrigin-RevId: 820207225
Change-Id: I8e053f724c18b466bd287f80a720542a535615d2
This commit is contained in:
Abseil Team 2025-10-16 06:31:04 -07:00 committed by Copybara-Service
parent e17e37a115
commit b2b9072ecb
3 changed files with 10 additions and 10 deletions

View File

@ -1292,10 +1292,10 @@ class MockSpec {
: function_mocker_(function_mocker), matchers_(matchers) {} : function_mocker_(function_mocker), matchers_(matchers) {}
// Adds a new default action spec to the function mocker and returns // Adds a new default action spec to the function mocker and returns
// the newly created spec. // the newly created spec. .WillByDefault() must be called on the returned
internal::OnCallSpec<F>& InternalDefaultActionSetAt(const char* file, // object.
int line, const char* obj, [[nodiscard]] internal::OnCallSpec<F>& InternalDefaultActionSetAt(
const char* call) { const char* file, int line, const char* obj, const char* call) {
LogWithLocation(internal::kInfo, file, line, LogWithLocation(internal::kInfo, file, line,
std::string("ON_CALL(") + obj + ", " + call + ") invoked"); std::string("ON_CALL(") + obj + ", " + call + ") invoked");
return function_mocker_->AddNewOnCallSpec(file, line, matchers_); return function_mocker_->AddNewOnCallSpec(file, line, matchers_);

View File

@ -545,7 +545,7 @@ TEST(ExpectCallTest, DoesNotLogWhenVerbosityIsError) {
void OnCallLogger() { void OnCallLogger() {
DummyMock mock; DummyMock mock;
ON_CALL(mock, TestMethod()); (void)ON_CALL(mock, TestMethod());
} }
// Verifies that ON_CALL logs if the --gmock_verbose flag is set to "info". // Verifies that ON_CALL logs if the --gmock_verbose flag is set to "info".
@ -568,7 +568,7 @@ TEST(OnCallTest, DoesNotLogWhenVerbosityIsError) {
void OnCallAnyArgumentLogger() { void OnCallAnyArgumentLogger() {
DummyMock mock; DummyMock mock;
ON_CALL(mock, TestMethodArg(_)); (void)ON_CALL(mock, TestMethodArg(_));
} }
// Verifies that ON_CALL prints provided _ argument. // Verifies that ON_CALL prints provided _ argument.

View File

@ -160,7 +160,7 @@ class MockCC : public CC {
// Tests that a method with expanded name compiles. // Tests that a method with expanded name compiles.
TEST(OnCallSyntaxTest, CompilesWithMethodNameExpandedFromMacro) { TEST(OnCallSyntaxTest, CompilesWithMethodNameExpandedFromMacro) {
MockCC cc; MockCC cc;
ON_CALL(cc, Method()); (void)ON_CALL(cc, Method());
} }
// Tests that the method with expanded name not only compiles but runs // Tests that the method with expanded name not only compiles but runs
@ -193,7 +193,7 @@ TEST(OnCallSyntaxTest, EvaluatesFirstArgumentOnce) {
MockA a; MockA a;
MockA* pa = &a; MockA* pa = &a;
ON_CALL(*pa++, DoA(_)); (void)ON_CALL(*pa++, DoA(_));
EXPECT_EQ(&a + 1, pa); EXPECT_EQ(&a + 1, pa);
} }
@ -201,7 +201,7 @@ TEST(OnCallSyntaxTest, EvaluatesSecondArgumentOnce) {
MockA a; MockA a;
int n = 0; int n = 0;
ON_CALL(a, DoA(n++)); (void)ON_CALL(a, DoA(n++));
EXPECT_EQ(1, n); EXPECT_EQ(1, n);
} }
@ -232,7 +232,7 @@ TEST(OnCallSyntaxTest, WillByDefaultIsMandatory) {
EXPECT_DEATH_IF_SUPPORTED( EXPECT_DEATH_IF_SUPPORTED(
{ {
ON_CALL(a, DoA(5)); (void)ON_CALL(a, DoA(5));
a.DoA(5); a.DoA(5);
}, },
""); "");