Override const function google mock
Asked Answered
B

1

6

When trying to mock a function with google test i still get a warning that I miss a "override"

    MOCK_METHOD(bool, functionName, (), (const override));

The warning I get states

xxx.h:31:22: error: 'functionName' overrides a member function but is not marked 'override'
xxx.h:25:17: note: overridden virtual function is here

How do you mark a mocked function with override and const at the same time?

Boulevard answered 1/7, 2021 at 10:57 Comment(0)
B
13

Of course I found it seconds after posting it :/. Separating the keywords by comas is the trick

from here

    MOCK_METHOD(bool, functionName, (), (const, override));
Boulevard answered 1/7, 2021 at 11:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.