Skip to content

Commit

Permalink
Wrap macro arguments with parentheses
Browse files Browse the repository at this point in the history
Usage example:
```
std::shared_ptr<interface> foo;
When(Method(*foo,bar)).Return(1);
```
  • Loading branch information
nordsturm committed Oct 21, 2019
1 parent 317419c commit 6d67a1d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions include/fakeit/api_macros.hpp
Expand Up @@ -5,7 +5,7 @@
#endif

#define MOCK_TYPE(mock) \
std::remove_reference<decltype(mock.get())>::type
std::remove_reference<decltype((mock).get())>::type

#define OVERLOADED_METHOD_PTR(mock, method, prototype) \
fakeit::Prototype<prototype>::MemberType<MOCK_TYPE(mock)>::get(&MOCK_TYPE(mock)::method)
Expand All @@ -14,16 +14,16 @@
fakeit::Prototype<prototype>::MemberType<MOCK_TYPE(mock)>::getconst(&MOCK_TYPE(mock)::method)

#define Dtor(mock) \
mock.dtor().setMethodDetails(#mock,"destructor")
(mock).dtor().setMethodDetails(#mock,"destructor")

#define Method(mock, method) \
mock.template stub<__COUNTER__>(&MOCK_TYPE(mock)::method).setMethodDetails(#mock,#method)
(mock).template stub<__COUNTER__>(&MOCK_TYPE(mock)::method).setMethodDetails(#mock,#method)

#define OverloadedMethod(mock, method, prototype) \
mock.template stub<__COUNTER__>(OVERLOADED_METHOD_PTR( mock , method, prototype )).setMethodDetails(#mock,#method)
(mock).template stub<__COUNTER__>(OVERLOADED_METHOD_PTR( mock , method, prototype )).setMethodDetails(#mock,#method)

#define ConstOverloadedMethod(mock, method, prototype) \
mock.template stub<__COUNTER__>(CONST_OVERLOADED_METHOD_PTR( mock , method, prototype )).setMethodDetails(#mock,#method)
(mock).template stub<__COUNTER__>(CONST_OVERLOADED_METHOD_PTR( mock , method, prototype )).setMethodDetails(#mock,#method)

#define Verify(...) \
Verify( __VA_ARGS__ ).setFileInfo(__FILE__, __LINE__, __func__)
Expand Down

0 comments on commit 6d67a1d

Please sign in to comment.