googletest
googletest copied to clipboard
[FR]: MOCK_METHOD should warn on missing comma for function qualifiers
Does the feature exist in the most recent commit?
No
Why do we need this feature?
To prevent bugs.
Describe the proposal.
Currently, MOCK_METHOD
expects something like this:
MOCK_METHOD(int, GetX, (), (const, override));
However we see many people forget the comma for the function qualifiers, and type this instead:
MOCK_METHOD(int, GetX, (), (const override)); ^
This goes totally unnoticed. The result is that GMock discards the override
token altogether, which prevents the compiler from enforcing that indeed the function is overriding a virtual function from the base class.
It would be good if GMock could assert this somehow.
Is the feature specific to an operating system, compiler, or build system version?
No
Thanks. Yes, we would like to do this. In fact, we have this feature implemented, but turned off, hidden by the internal flag GMOCK_INTERNAL_STRICT_SPEC_ASSERT. Turning it on requires fixing some internal tests, which we have not completed yet.