Closed
Description
Hi!
I'm using your library in my projects and i really like it.
But on the other hand it's basic_object<> implicit conversions from string is a source of bugs and long debugging sessions. I had two such sessions today.
Take a look. Some time ago a had a settings_provider class and a test mock
class settings_provider{
virtual std::string get_settings(int id) const;
};
class settings_provider_mock : public settings_provider{
MOCK_CONST_METHOD1(get_settings, std::string(_));
};
Then,when using this mock,i setup it to return some json-formatted string
EXPECT_CALL(*sp_mock ,get_settings(_)).WillOnce(Return("{ \"key\"=\"value\" }"));
Some time later i changed settings_provider and corresponding mock interface to
class settings_provider{
virtual basic_json<> get_settings(int id) const;
};
class settings_provider_mock : public settings_provider{
MOCK_CONST_METHOD<N>(get_settings, basic_json<>(_));
};
But the EXPECT_CALL continued to compile,but now get_settings returns json object with value "{ "key"="value" }".
So, my suggestion is to make conversion from string(and maybe other types) explicit, to avoid such errors in future.