diff options
author | Abseil Team <absl-team@google.com> | 2022-11-29 16:43:37 (GMT) |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-11-29 16:44:15 (GMT) |
commit | a16bfcfda1ea994c1abec23cca8f530953042dfa (patch) | |
tree | ed86559e95c65a40b9508ab6e5393be0f98317bf /googlemock/test | |
parent | e68764c147ea0dac1e8811925c531d937396878e (diff) | |
download | googletest-a16bfcfda1ea994c1abec23cca8f530953042dfa.zip googletest-a16bfcfda1ea994c1abec23cca8f530953042dfa.tar.gz googletest-a16bfcfda1ea994c1abec23cca8f530953042dfa.tar.bz2 |
Disables `-Wunused-member-function` and `-Wused-but-marked-unused` that trigger via `MOCK_METHOD()` and `EXPECT_THAT()` macros.
Fixes: #4052, #4055
PiperOrigin-RevId: 491647393
Change-Id: I8e2ad838156fa8c7e9dccd1740af797e694992b6
Diffstat (limited to 'googlemock/test')
-rw-r--r-- | googlemock/test/gmock-function-mocker_test.cc | 15 | ||||
-rw-r--r-- | googlemock/test/gmock-matchers-misc_test.cc | 14 |
2 files changed, 29 insertions, 0 deletions
diff --git a/googlemock/test/gmock-function-mocker_test.cc b/googlemock/test/gmock-function-mocker_test.cc index 286115f..1d15a29 100644 --- a/googlemock/test/gmock-function-mocker_test.cc +++ b/googlemock/test/gmock-function-mocker_test.cc @@ -958,6 +958,21 @@ TEST(MockMethodMockFunctionTest, MockMethodSizeOverhead) { EXPECT_EQ(sizeof(LegacyMockMethodSizes0), sizeof(MockMethodSizes0)); } +TEST(MockMethodMockFunctionTest, EnsureNoUnusedMemberFunction) { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic error "-Wunused-member-function" +#endif + // https://github.com/google/googletest/issues/4052 + struct Foo { + MOCK_METHOD(void, foo, ()); + }; + EXPECT_CALL(Foo(), foo()).Times(0); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif +} + void hasTwoParams(int, int); void MaybeThrows(); void DoesntThrow() noexcept; diff --git a/googlemock/test/gmock-matchers-misc_test.cc b/googlemock/test/gmock-matchers-misc_test.cc index 53f4962..42a0e44 100644 --- a/googlemock/test/gmock-matchers-misc_test.cc +++ b/googlemock/test/gmock-matchers-misc_test.cc @@ -1615,6 +1615,20 @@ TEST(MatcherPMacroTest, WorksOnMoveOnlyType) { EXPECT_THAT(p, Not(UniquePointee(2))); } +MATCHER(EnsureNoUnusedButMarkedUnusedWarning, "") { return (arg % 2) == 0; } + +TEST(MockMethodMockFunctionTest, EnsureNoUnusedButMarkedUnusedWarning) { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic error "-Wused-but-marked-unused" +#endif + // https://github.com/google/googletest/issues/4055 + EXPECT_THAT(0, EnsureNoUnusedButMarkedUnusedWarning()); +#ifdef __clang__ +#pragma clang diagnostic pop +#endif +} + #if GTEST_HAS_EXCEPTIONS // std::function<void()> is used below for compatibility with older copies of |