Giaco777
unread,Feb 13, 2012, 8:23:21 AM2/13/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google C++ Mocking Framework
Hi,
I wanted to enter the google test and mocking world with a very simple
example mostly copied together from the ForDummies document. I run
google mock on Windows XP with cygwin 1.7.10-1. Compiling and linking
the code below with gcc 4.5.3 runs well, but when running it, I get an
Segmentation Fault. This is the gdb output for that:
Program received signal SIGSEGV, Segmentation fault.
0x00432ae2 in join (ptr=0x611d7cd4, this=0x6fa6a4)
at ./gtest/include/gtest/internal/gtest-linked_ptr.h:113
113 while (p->next_ != ptr) p = p->next_;
What's wrong here?
I've send this request already two weeks ago to "moderators", but did
not receive any response so far.
Kind Regards
#include "gmock/gmock.h"
#include "gtest/gtest.h"
class Turtle {
public:
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());
};
using ::testing::AtLeast; // #1
TEST(PainterTest, CanDrawSomething) {
MockTurtle turtle; // #2
EXPECT_CALL(turtle, PenDown()) // #3
.Times(AtLeast(1));
} // #5
int main(int argc, char *argv[]) {
// The following line must be executed to initialize Google Mock
// (and Google Test) before running the tests.
::testing::InitGoogleMock(&argc, argv);
return RUN_ALL_TESTS();
}