Mock_Foo.h:10:24: error: exception specification of overriding function is more lax than base version
MOCK_CONST_METHOD0(value, int());
^
/gmock-svn/include/gmock/gmock-generated-function-mockers.h:687:62: note: expanded from macro 'MOCK_CONST_METHOD0'
#define MOCK_CONST_METHOD0(m, ...) GMOCK_METHOD0_(, const, , m, __VA_ARGS__)
^
/gmock-svn/include/gmock/gmock-generated-function-mockers.h:357:37: note: expanded from macro 'GMOCK_METHOD0_'
GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
^
Foo.h:10:17: note: overridden virtual function is here
virtual int value() const noexcept{ return _value; }
^
Here's the sample code used to generate:
Foo.h:
class Foo{
public:
Foo();
~Foo();
virtual int value() const noexcept{ return _value; }
virtual void setValue(const int value){ _value = value; }
private:
int _value;
};
class Bar{
public:
Bar(Foo* foo) : _foo{foo}{}
void doStuff(){
_foo->value();
}
private:
Foo* _foo;
};
Mock_Foo.h#include "Foo.h"#include "gmock/gmock.h"class Mock_Foo : public Foo{public:MOCK_CONST_METHOD0(value, int());MOCK_METHOD1(setValue, void(const int));};Foo_Test.h
#include "gtest/gtest.h"
#include "Mock_Foo.h"
TEST(FooTest, foo){
Mock_Foo foo;
Bar bar{&foo};
EXPECT_CALL(foo, value());
bar.doStuff();
}
--
---
You received this message because you are subscribed to the Google Groups "Google C++ Mocking Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to googlemock+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/googlemock/5994389b-1e43-4d97-b231-5d1bee609d00%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
If a function has 'noexcept' keyword, I don't know if I can mock it. The initial compiling (gcc or clang) complains:Mock_Foo.h:10:24: error: exception specification of overriding function is more lax than base version
MOCK_CONST_METHOD0(value, int());
^
/gmock-svn/include/gmock/gmock-generated-function-mockers.h:687:62: note: expanded from macro 'MOCK_CONST_METHOD0'
#define MOCK_CONST_METHOD0(m, ...) GMOCK_METHOD0_(, const, , m, __VA_ARGS__)
^
/gmock-svn/include/gmock/gmock-generated-function-mockers.h:357:37: note: expanded from macro 'GMOCK_METHOD0_'
GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \
^
Foo.h:10:17: note: overridden virtual function is here
virtual int value() const noexcept{ return _value; }
^
Here's the sample code used to generate:
Foo.h:
class Foo{
public:
Foo();
~Foo();
virtual int value() const noexcept{ return _value; }
virtual void setValue(const int value){ _value = value; }
private:
int _value;
};