Skip to content

Commit b2b9072

Browse files
Abseil Teamcopybara-github
authored andcommitted
Mark InternalDefaultActionSetAt as nodiscard.
PiperOrigin-RevId: 820207225 Change-Id: I8e053f724c18b466bd287f80a720542a535615d2
1 parent e17e37a commit b2b9072

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

googlemock/include/gmock/gmock-spec-builders.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,10 +1292,10 @@ class MockSpec {
12921292
: function_mocker_(function_mocker), matchers_(matchers) {}
12931293

12941294
// Adds a new default action spec to the function mocker and returns
1295-
// the newly created spec.
1296-
internal::OnCallSpec<F>& InternalDefaultActionSetAt(const char* file,
1297-
int line, const char* obj,
1298-
const char* call) {
1295+
// the newly created spec. .WillByDefault() must be called on the returned
1296+
// object.
1297+
[[nodiscard]] internal::OnCallSpec<F>& InternalDefaultActionSetAt(
1298+
const char* file, int line, const char* obj, const char* call) {
12991299
LogWithLocation(internal::kInfo, file, line,
13001300
std::string("ON_CALL(") + obj + ", " + call + ") invoked");
13011301
return function_mocker_->AddNewOnCallSpec(file, line, matchers_);

googlemock/test/gmock-internal-utils_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ TEST(ExpectCallTest, DoesNotLogWhenVerbosityIsError) {
545545

546546
void OnCallLogger() {
547547
DummyMock mock;
548-
ON_CALL(mock, TestMethod());
548+
(void)ON_CALL(mock, TestMethod());
549549
}
550550

551551
// Verifies that ON_CALL logs if the --gmock_verbose flag is set to "info".
@@ -568,7 +568,7 @@ TEST(OnCallTest, DoesNotLogWhenVerbosityIsError) {
568568

569569
void OnCallAnyArgumentLogger() {
570570
DummyMock mock;
571-
ON_CALL(mock, TestMethodArg(_));
571+
(void)ON_CALL(mock, TestMethodArg(_));
572572
}
573573

574574
// Verifies that ON_CALL prints provided _ argument.

googlemock/test/gmock-spec-builders_test.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class MockCC : public CC {
160160
// Tests that a method with expanded name compiles.
161161
TEST(OnCallSyntaxTest, CompilesWithMethodNameExpandedFromMacro) {
162162
MockCC cc;
163-
ON_CALL(cc, Method());
163+
(void)ON_CALL(cc, Method());
164164
}
165165

166166
// Tests that the method with expanded name not only compiles but runs
@@ -193,15 +193,15 @@ TEST(OnCallSyntaxTest, EvaluatesFirstArgumentOnce) {
193193
MockA a;
194194
MockA* pa = &a;
195195

196-
ON_CALL(*pa++, DoA(_));
196+
(void)ON_CALL(*pa++, DoA(_));
197197
EXPECT_EQ(&a + 1, pa);
198198
}
199199

200200
TEST(OnCallSyntaxTest, EvaluatesSecondArgumentOnce) {
201201
MockA a;
202202
int n = 0;
203203

204-
ON_CALL(a, DoA(n++));
204+
(void)ON_CALL(a, DoA(n++));
205205
EXPECT_EQ(1, n);
206206
}
207207

@@ -232,7 +232,7 @@ TEST(OnCallSyntaxTest, WillByDefaultIsMandatory) {
232232

233233
EXPECT_DEATH_IF_SUPPORTED(
234234
{
235-
ON_CALL(a, DoA(5));
235+
(void)ON_CALL(a, DoA(5));
236236
a.DoA(5);
237237
},
238238
"");

0 commit comments

Comments
 (0)