Jonathan Herbst
unread,Sep 27, 2011, 2:15:15 PM9/27/11Sign 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
I am seeing a segmentation fault when I use a boost::filesystem::path
as a parameter to an expected method call and the call is not
matched. Has anyone else seen this problem? Am I doing something
wrong?
I have isolated the problem in the code below:
TestFoo1 succeeds; TestFoo2, 3, and 4 give me a segmentation fault.
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include <boost/filesystem.hpp>
using namespace boost::filesystem;
class Foo
{
public:
Foo() {}
virtual ~Foo() {}
virtual void M(path& p, int i) {}
};
class Bar
{
public:
Bar(Foo* foo):
m_foo(foo)
{}
void M(path& p, int i)
{
m_foo->M(p, i);
}
Foo* m_foo;
};
class MockFoo: public Foo
{
public:
MOCK_METHOD2(M, void(path& p, int i));
};
TEST(BarTest, TestFoo1)
{
MockFoo foo;
Bar bar(&foo);
path p = "path1";
EXPECT_CALL(foo, M(p, 5)).Times(1);
bar.M(p, 5);
}
TEST(BarTest, TestFoo2)
{
MockFoo foo;
Bar bar(&foo);
path p = "path1";
EXPECT_CALL(foo, M(p, 5)).Times(1);
bar.M(p, 6);
}
TEST(BarTest, TestFoo3)
{
MockFoo foo;
Bar bar(&foo);
path p = "path1";
path p2 = "path2";
EXPECT_CALL(foo, M(p2, 6)).Times(1);
bar.M(p, 6);
}
TEST(BarTest, TestFoo4)
{
MockFoo foo;
Bar bar(&foo);
path p = "path1";
bar.M(p, 6);
}
int main(int argc, char** argv)
{
::testing::InitGoogleMock(&argc, argv);
return RUN_ALL_TESTS();
}