I have an issue with the google mock EXPECT_CALL macro. The following code gives compilation error on the EXPECT_CALL Statement:
error C2660: 'testing::Eq' : function does not take 1 arguments \gmock-1.6.0\include\gmock\gmock-matchers.h
Basically I have a base container and base data object for that container, both abstract and a cache which has a pointer to base container and an Add method that takes a reference to base data object. I have created a basic program to demonstrate the issue. Thanks a lot if anyone can help.
#include "gtest/gtest.h"
#include "gmock/gmock.h"
namespace
{
class BaseData
{
public:
virtual void SetValue(const int value) = 0;
};
class BaseContainer
{
public:
virtual void Add(const BaseData& data) = 0;
};
class MockContainer : public BaseContainer
{
public:
MOCK_METHOD1(Add, void (const BaseData& data));
};
class MockData : public BaseData
{
public:
MOCK_METHOD1(SetValue, void (int));
};
class Cache
{
private:
BaseContainer* container;
public:
Cache(BaseContainer* c)
{
container = c;
}
~Cache()
{
}
void AddToContainer(const BaseData& data)
{
container->Add(data);
}
};
class CacheTestFixture : public ::testing::Test
{
protected:
CacheTestFixture() {}
virtual ~CacheTestFixture() {}
virtual void SetUp() {}
virtual void TearDown() {}
};
TEST_F(CacheTestFixture, TestAdd)
{
MockData data;
MockContainer container;
EXPECT_CALL(container, Add(data)).WillRepeatedly(::testing::Return());
Cache c(&container);
ASSERT_NO_THROW(c.AddToContainer(data));
}
}
int _tmain(int argc, _TCHAR* argv[])
{
::testing::InitGoogleMock(&argc, argv);
return RUN_ALL_TESTS();
}
MOCK_METHOD
forSetValue
requireconst int
instead of justint
? – Pickaninny