Re: googlemock for dummies - Simple example (Turtle) dosnt compile

1,173 views
Skip to first unread message

avihai marchiano

unread,
Jul 25, 2012, 5:17:31 AM7/25/12
to googl...@googlegroups.com
Dont know why , but different eclipse solve it.

On Tuesday, July 24, 2012 9:59:43 AM UTC-4, avihai marchiano wrote:

New to cpp , so forgive me for my ignorance (come from Java). run on ubunto with gcc 4.6 and eclipse-cdt. I tried to follow google-mock for dummies and i didnt success to compile the basic example (Turtle)

I did as follow: 1. download google-mock and run ./configure && make 2. create new project in eclipse-cdt with main class. add both gtest and gmock includes to the includes directory and add both .lib folders under gmock/lib and under gmock/gtest/lib to the lib directories and add gtest and gmock as libs. 3. From the dummy tutorial i copy both the Tutorial and the TurorialMock exactly as they are in the dummy tutorial except the "..." in the example.

The problem is that it dosnt compile. errors below. In eclipse-cdt under problems I see 123 problems (even if I remove the destructor). eclipse complains - Function 'GTEST_CONCAT_TOKEN_' could not be resolved

g++ -I/root/workspace/gmock/include -I/root/workspace/gmock/gtest/include -O0 -g3 -Wall -c -fmessage-length=0 -std=c++0x -pthread -MMD -MP -MF"src/playground.d" -MT"src/playground.d" -o "src/playground.o" "../src/playground.cpp"
../src/playground.cpp:55:7: error: deleted function ‘virtual MockTurtle::~MockTurtle()’
../src/playground.cpp:44:11: error: overriding non-deleted function ‘virtual Turtle::~Turtle()’
../src/playground.cpp:55:7: error: ‘virtual MockTurtle::~MockTurtle()’ is implicitly deleted because the default definition would be ill-formed:
../src/playground.cpp:44:11: error: ‘virtual Turtle::~Turtle()’ is private

class Turtle {
  virtual ~Turtle() {}
  virtual void PenUp() = 0;
  virtual void PenDown() = 0;
  virtual void Forward(int distance) = 0;
  virtual void Turn(int degrees) = 0;
  virtual void GoTo(int x, int y) = 0;
  virtual int GetX() const = 0;
  virtual int GetY() const = 0;
};


class MockTurtle : public Turtle {
 public:
  MOCK_METHOD0(PenUp, void());
  MOCK_METHOD0(PenDown, void());
  MOCK_METHOD1(Forward, void(int distance));
  MOCK_METHOD1(Turn, void(int degrees));
  MOCK_METHOD2(GoTo, void(int x, int y));
  MOCK_CONST_METHOD0(GetX, int());
  MOCK_CONST_METHOD0(GetY, int());
};
Reply all
Reply to author
Forward
0 new messages