In mock objects to capture the value of arguments of const functions in a member variable.
class Source
{
public:
virtual ~Source() {}
virtual std::string read(int count) const=0;
};
class SourceMock : public Source
{
public:
mutable std::vector arguments;
std::string read(int count) const {
arguments.push_back(count);
return "...";
}
};
//TEST....
SourceMock mock;
//...
VERIFY(mock.arguments.size()==2);
VERIFY(mock.arguments[0]==3);
//...