gmock-global icon indicating copy to clipboard operation
gmock-global copied to clipboard

Compatibility with GoogleTest v1.10

Open xmass opened this issue 5 years ago • 3 comments

Please update the project to be compatible with new powerful MOCK_METHOD macro introduced in GoogleTest release v1.10.0.

xmass avatar Mar 31 '20 10:03 xmass

Commit https://github.com/google/googletest/commit/fbf67a70d07543f40832d0cd7a58f304bc6ab1d1 removed GMOCK_RESULT_ So if you need to compile with current head you should define

#if !defined(GMOCK_RESULT_)
    #define GMOCK_RESULT_(tn, ...) \
    tn ::testing::internal::Function<__VA_ARGS__>::Result
#endif

pmisik avatar Aug 03 '20 08:08 pmisik

@pmisik Sorry I don't quite understand, if I do these steps, then will it be compatible with gtest v1.10.0?

SpaceTestMonkey avatar Feb 12 '21 06:02 SpaceTestMonkey

For the version of googletest I used, I added this patch to the top of the file:

#if !defined(GMOCK_RESULT_)
#define GMOCK_RESULT_(tn, ...) \
    tn ::testing::internal::Function<__VA_ARGS__>::Result
#endif

#if !defined(GMOCK_ARG_)
#define GMOCK_ARG_(tn, N, ...) \
    tn ::testing::internal::Function<__VA_ARGS__>::Arg<N-1>::type
#endif

#if !defined(GMOCK_MATCHER_)
#define GMOCK_MATCHER_(tn, N, ...) \
      const ::testing::Matcher<GMOCK_ARG_(tn, N, __VA_ARGS__)>&
#endif

#if !defined(GMOCK_MOCKER_)
#define GMOCK_MOCKER_(arity, Method) \
    GTEST_CONCAT_TOKEN_(gmock##arity##_##Method##_, __LINE__)
#endif

robertquitt avatar Apr 15 '21 04:04 robertquitt

For the version of googletest I used, I added this patch to the top of the file:

#if !defined(GMOCK_RESULT_)
#define GMOCK_RESULT_(tn, ...) \
    tn ::testing::internal::Function<__VA_ARGS__>::Result
#endif

#if !defined(GMOCK_ARG_)
#define GMOCK_ARG_(tn, N, ...) \
    tn ::testing::internal::Function<__VA_ARGS__>::Arg<N-1>::type
#endif

#if !defined(GMOCK_MATCHER_)
#define GMOCK_MATCHER_(tn, N, ...) \
      const ::testing::Matcher<GMOCK_ARG_(tn, N, __VA_ARGS__)>&
#endif

#if !defined(GMOCK_MOCKER_)
#define GMOCK_MOCKER_(arity, Method) \
    GTEST_CONCAT_TOKEN_(gmock##arity##_##Method##_, __LINE__)
#endif

What file did you add those to the top of? Was it your file containing mocks, or was it the header file for this project?

AeroSW avatar Jul 30 '24 00:07 AeroSW

@AeroSW Could you elaborate on the issue? What's not working?

SergiusTheBest avatar Aug 01 '24 20:08 SergiusTheBest

@AeroSW Could you elaborate on the issue? What's not working?

@SergiusTheBest Everything is working. It took me a few minutes to realize the changes mentioned above are merged into the code. I thought he was talking about adding that code to his own project.

AeroSW avatar Aug 02 '24 05:08 AeroSW

Ok. Then I assume the issue can be closed. I've updated the CI script to be sure it builds with gtest 1.8.1-1.15.2 on gcc/clang/msvc.

SergiusTheBest avatar Aug 02 '24 11:08 SergiusTheBest