Mocking volatile methods

66 views
Skip to first unread message

Edgar

unread,
Sep 3, 2010, 9:13:41 AM9/3/10
to Google C++ Mocking Framework
Hello,
I have a class where some methods have the volatile qualifier. Is
there a way to mock these in googleMock?

eg:
virtual int foo() volatile = 0;

Thanks,
- Edgar

Edgar

unread,
Sep 8, 2010, 4:18:04 PM9/8/10
to Google C++ Mocking Framework
To answer my own question it's not possible using the usual
MOCK_METHOD macros.

I've been able to create MOCK_VOLATILE_METHODn macros similar to the
MOCK_METHODn ones.

Are these macros useful enough to be included in gmock? I've only
created MOCK_VOLATILE_METHOD and MOCK_CONST_VOLATILE_METHOD macros, if
done completely it would double the number of method mocking macros.
Is it best to create an "issue" for this?

- Edgar

Zhanyong Wan (λx.x x)

unread,
Sep 8, 2010, 5:01:15 PM9/8/10
to Edgar, Google C++ Mocking Framework
Hi Edgar,

On Wed, Sep 8, 2010 at 1:18 PM, Edgar <oat...@gmail.com> wrote:
> To answer my own question it's not possible using the usual
> MOCK_METHOD macros.
>
> I've been able to create MOCK_VOLATILE_METHODn macros similar to the
> MOCK_METHODn ones.
>
> Are these macros useful enough to be included in gmock? I've only
> created MOCK_VOLATILE_METHOD and MOCK_CONST_VOLATILE_METHOD macros, if
> done completely it would double the number of method mocking macros.
> Is it best to create an "issue" for this?

I created http://code.google.com/p/googlemock/issues/detail?id=122 to
track this.

As you said, implementing MOCK_VOLATILE_METHOD0() and friends
completely will end up with a combinatorial explosion, so it isn't
viable. I think we'll instead provide a more generic family of macros
that require the user to provide more arguments but are more flexible.
Please see the issue for details. Thanks.


>
> - Edgar
>
> On Sep 3, 10:13 am, Edgar <oat...@gmail.com> wrote:
>> Hello,
>> I have a class where some methods have the volatile qualifier. Is
>> there a way to mock these in googleMock?
>>
>> eg:
>> virtual int foo() volatile = 0;
>>
>> Thanks,
>> - Edgar
>

--
Zhanyong

Reply all
Reply to author
Forward
0 new messages