Using Gmock 1.6 with Visual Studio 2013 on Windows:
The method I am trying to mock has signature:
virtual std::string translate_sdc_name_interface(const std::string& name, const std::string & hierDelimiter, drModuleInst * topModule) const = 0;
The corresponding mock declaration is:
MOCK_CONST_METHOD3(translate_sdc_name_interface,
std::string(const std::string& name, const std::string & hierDelimiter, drModuleInst * topModule));
When the mocked method is invoked, I want the default action to be to return a copy of the first argument. None of the following syntaxes work:
class StructVendorOptionsTest : public VendorOptionsTest {
public:
StructVendorOptionsTest() {
//ON_CALL(vendorExterns, translate_sdc_name_interface(_, _, _)).WillByDefault(ReturnArg<0>);
//ON_CALL(vendorExterns, translate_sdc_name_interface(_, _, _)).WillByDefault(WithArg<0>(ReturnNew<std::string>));
//ON_CALL(vendorExterns, translate_sdc_name_interface(_, _, _)).WillByDefault(WithArg<0>(ReturnNew<std::string>()));
//ON_CALL(vendorExterns, translate_sdc_name_interface(_, _, _)).WillByDefault(ReturnNew<std::string>(ReturnArg<0>()));
}
protected:
MockVendorExterns vendorExterns;
};
The first of these complains about being unable to convert a const std::string & to a std::string; the others result in various syntax errors with the template expansions. I haven't found a good example of this in the documentation. What's the right syntax to use here (I assume it is possible to do this)?
Dave W.