From user's email:
In order to set an argument by reference I need to create a copy
constructor even though it is not needed by the actual code. I do not
want to add the redundant copy constructor. Am I doing something
wrong?
Here is the issue: Consider:
class ClassToMock {
public:
virtual void testMethod(SomeClass& a) {
SomeClass b;
a = b;
}
};
class MockedA : public ClassToMock {
public:
MOCK_METHOD1(testMethod, void(SomeClass&));
};
The following piece of code does not compile:
SomeClass x;
EXPECT_CALL(mock, testMethod(_)).WillOnce(SetArgReferee<0>(x));
But instead compiler throws:
third_party\gmock-1.5.0\include\gmock\gmock-more-actions.h(160) :
error C2664:
'testing::SetArgRefereeActionP<k,value_type>::gmock_Impl<F>::gmock_Impl(val
ue_type)' :
cannot convert parameter 1 from 'const SomeClass' to 'SomeClass'
1> with
1> [
1> k=0,
1> value_type=SomeClass,
1> F=void (SomeClass &)
1> ]
1> Cannot copy construct class 'SomeClass' due to ambiguous
copy constructors or no available copy constructor
mytestcase.cpp(100) : see reference to function template instantiation
'testing::SetArgRefereeActionP<k,value_type>::operator
testing::Action<F>(void) const<F>' being compiled
1> with
1> [
1> k=0,
1> value_type=SomeClass,
1> F=void (SomeClass &)
1> ]
Original issue reported on code.google.com by vladlosev on 25 May 2010 at 6:16
Original issue reported on code.google.com by
vladlosev
on 25 May 2010 at 6:16