michaelernst / googlemock

Automatically exported from code.google.com/p/googlemock
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Returning shared_ptr to mock from expectation hangs in Linux #114

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Compile and run code in main.cpp

What is the expected output? What do you see instead?
Expected output is for application to exit.  Application never exits.

Which version of Google Mock are you using? On what operating system?

googlemock/src$ svn info
Path: .
URL: http://googlemock.googlecode.com/svn/trunk/src
Repository Root: http://googlemock.googlecode.com/svn
Repository UUID: 8415998a-534a-0410-bf83-d39667b30386
Revision: 300
Node Kind: directory
Schedule: normal
Last Changed Author: zhanyong.wan
Last Changed Rev: 294
Last Changed Date: 2010-05-10 13:14:29 -0400 (Mon, 10 May 2010)

Original issue reported on code.google.com by tim.dave@gmail.com on 2 Jun 2010 at 7:44

Attachments:

GoogleCodeExporter commented 9 years ago
This is the same as issue 79.  A work around is to switch the definition of 
objectA
and objectB.

Original comment by w...@google.com on 2 Jun 2010 at 7:59

GoogleCodeExporter commented 9 years ago
An extremely helpful comment!

Original comment by zilvinas...@gmail.com on 25 Oct 2010 at 1:18

GoogleCodeExporter commented 9 years ago
Can't make it work this workaround. My real example is a bit complex but in 
general I've got the same problem. When I'm invoking method which should take 
argument boost::shared_ptr of mocked class (body is nothing more than mock of 
base intereface), whole results hang. Do you have any suggestions?

Original comment by darek.be...@gmail.com on 16 Jul 2011 at 11:32

GoogleCodeExporter commented 9 years ago
I found that manually reset()'ing shared_ptr instances to mocks that I use in a 
test case works around the problem:

TEST(SomeTest, someCase) {
  auto mock = make_shared<MockObject>();

  // Pass shared_ptr somewhere ...

  mock.reset();
}

Original comment by denis.a....@gmail.com on 16 Feb 2013 at 2:04