Activity for Turtle

  • gambr gambr created ticket #79

    method called several times abd check once with specific parameters

  • Ming Cheng Ming Cheng posted a comment on ticket #78

    I need MyApplication to be constructed completely although I use Mock_MyApplication as a child class.

  • Ming Cheng Ming Cheng created ticket #78

    MOCK_BASE_CLASS

  • Ming Cheng Ming Cheng posted a comment on ticket #77

    Please kindly let me know if my question/sample is not very clear. I am keen to use the tool in my important and urgent project right now.

  • Ming Cheng Ming Cheng created ticket #77

    How to mock some functions in my class

  • Tyler Wright Tyler Wright posted a comment on ticket #76

    Can't seem to figure out why the mock method is just calling the base class method. Some help would be much appreciated.

  • Tyler Wright Tyler Wright created ticket #76

    MOCK_METHOD calling base class methods instead of mocked method.

  • gambr gambr posted a comment on ticket #75

    Thanks Mathieu for the clarification. It works now as expected with both delete process amd MOCK_VERIFY. Cheers, Gianni

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #75

    Hi Gianni, A mock object can either fail directly when a call is made that’s invalid, or if no call happens it must be «verified» to know all calls are done and to check if any unanswered call is remaining. The verification is either done manually (using MOCK_VERIFY for instance) or automatically when the mock object is destroyed. Here you are doing neither given you’re creating a naked pointer and never delete it. Does that make sense? MAT.

  • gambr gambr created ticket #75

    MOCK_EXPECT succedes when it should fail

  • Turtle Turtle released /turtle/1.3.2/turtle-1.3.2.zip

  • Turtle Turtle released /turtle/1.3.2/turtle-1.3.2.tar.gz

  • John McCabe John McCabe posted a comment on ticket #74

    Mathieu, Thanks. To be honest, I don't know how BOOST_REQUIRE behaves in a thread. BOOST_FAIL does the same thing as abort() though. Thanks again for your help. John

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #74

    I think you probably have analyzed the problem correcty, but short of changing the policy I don’t think there is a way out of it. Out of curiosity how does BOOST_REQUIRE behave when it fails in a thread, as it’s what abort in the default policy is modelled after if I remember correctly?

  • John McCabe John McCabe posted a comment on ticket #74

    Matthieu, Thanks for taking the time to reply, but that's not the issue. The code I posted was like that because the original version, that used std::shared_ptr<mockpanel> panel = std::make_shared<mockpanel>(), did the same thing.</mockpanel></mockpanel> I've come to the conclusion that the problem is that, when abort() is called due to the call sequence error, it's generating an exception in the thread that's created, which isn't being propagated to the main thread in a way that the Boost Test runtime...

  • Mathieu Champlon Mathieu Champlon modified ticket #74

    terminate called after throwing an instance of 'boost::exception_detail::clone_impl<mock::exception>'

  • Mathieu Champlon Mathieu Champlon modified a comment on ticket #74

    You’re destroying MockPanel object twice, you should probably use std::make_shared to instantiate a shared pointer instead of MockPanel mockPanel; std::shared_ptr<mockpanel> panel { &mockPanel };

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #74

    You’re destroying the shared pointer twice, you should probably use std::make_shared to instantiate a shared pointer instead of MockPanel mockPanel; std::shared_ptr<mockpanel> panel { &mockPanel };

  • John McCabe John McCabe created ticket #74

    terminate called after throwing an instance of 'boost::exception_detail::clone_impl<mock::exception>'

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #73

    Hi Gianni, Sorry I don’t have access to a C++ compiler at the moment so cannot verify this. What happens if you only set the first two expectations MOCK_EXPECT(macAddressFinderMock->find).with(mock::any, "192.168.0.223").never(); MOCK_EXPECT(macAddressFinderMock->find).with(mock::any, "192.168.0.222").returns("AA-BB-CC-DD-EE-FF"); and call it with "192.168.0.223"? MAT.

  • gambr gambr created ticket #73

    help with MOCK_EXPECT rules

  • GPS GPS created ticket #72

    Warning std::auto_ptr is deprecated

  • Mathieu Champlon Mathieu Champlon created a blog post

    Turtle 1.3.1 has been released !

  • Turtle Turtle released /turtle/1.3.1/turtle-1.3.1.zip

  • Turtle Turtle released /turtle/1.3.1/turtle-1.3.1.tar.gz

  • Mathieu Champlon Mathieu Champlon modified ticket #71

    test succeed with one() or never() indifferently

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #71

    Hi, Sorry for some reason I didn't get a notification when you created this ticket… The expectations are verified either when calling verify() explicitely on a mock object or automatically when the mock object is destroyed. Here you never delete the pointer… MAT.

  • Mathieu Champlon Mathieu Champlon modified ticket #71

    test succeed with one() or never() indifferently

  • gambr gambr created ticket #71

    test succeed with one() or never() indifferently

  • Mathieu Champlon Mathieu Champlon modified ticket #69

    Expecting a call with parameter + defining other calls with any

  • Mathieu Champlon Mathieu Champlon modified ticket #70

    MOCK_BASE_CLASS inside BOOST_AUTO_TEST_CASE

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #70

    Hi Gianni, This is a C++ limitation, see for instance https://stackoverflow.com/questions/5751977/local-type-as-template-arguments-in-c. Are you building with C++11 (or greater) enabled? Cheers, MAT.

  • gambr gambr created ticket #70

    MOCK_BASE_CLASS inside BOOST_AUTO_TEST_CASE

  • gambr gambr posted a comment on ticket #69

    Thank you very much Mathieu, now it works. Gianni

  • Mathieu Champlon Mathieu Champlon modified ticket #69

    Expecting a call with parameter + defining other calls with any

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #69

    Hi Gianni, Have you tried MOCK_EXPECT(readerMock->beginGroup).once().with("hosts"); MOCK_EXPECT(readerMock->beginGroup); ? The expectations are tested in the order you set them, so if you start with MOCK_EXPECT(readerMock->beginGroup).at_least(1); as it doesn't have any with, it will «absorb» all calls preventing your next expectation to ever be triggered. MAT.

  • Mathieu Champlon Mathieu Champlon modified ticket #69

    Expecting a call with parameter + defining other calls with any

  • gambr gambr created ticket #69

    Expecting a call with parameter + defining other calls with any

  • Mathieu Champlon Mathieu Champlon modified ticket #67

    Mock a method that accepts a unique_ptr

  • Darin Ohashi Darin Ohashi posted a comment on ticket #67

    That looks good. Thanks

  • Mathieu Champlon Mathieu Champlon modified ticket #67

    Mock a method that accepts a unique_ptr

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #67

    OK, implemented it in https://github.com/mat007/turtle/pull/35 Would you like to take a look before I merge the PR?

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #67

    Sorry for not following up on this sooner. Yes you're right, it should be feasible, I'll fix it as soon as I can find a couple of hours.

  • Darin Ohashi Darin Ohashi posted a comment on ticket #67

    I agree that that #2 would not work as some might expect, but I don't think devs familar with unique_ptrs would expect it to. I would expect the calls to get an empty unqiue_ptr. Once I have captured the unique_ptr I would accept responsibility for knowing that the value had been moved out. That's one reason I was thinking maybe a new constraint (capture, move? similar to returns vs moves) might be better, because then it would be more explicit that that value has been moved out. I agree that I can...

  • Mathieu Champlon Mathieu Champlon modified ticket #68

    MOCK_CONSTRUCTOR calls default constructor

  • jabaa jabaa posted a comment on ticket #68

    Thank you. I think this will fix my problem. I will try it this week. You can close this issue.

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #68

    Hi jabaa, MOCK_BASE_CLASS actually declares a class, and if you don't intend to set expectations on the constructor you can simply do MOCK_BASE_CLASS(MConnection, Connection) { MConnection(std::string s1, std::string s2, std::string s3, std::string s4) : Connection(s1, s2, s3, s4) {} If you actually need to mock the constructor, add a manual call MOCK_BASE_CLASS(MConnection, Connection) { MConnection(std::string s1, std::string s2, std::string s3, std::string s4) : Connection(s1, s2, s3, s4) { Constructor(s1,...

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #67

    I don't think there is a way we can make mock::retrieve safe in this case because of http://turtle.sourceforge.net/turtle/getting_started.html#turtle.getting_started.expectation_selection_algorithm Imagine the following code std::unique_ptr< … > p; MOCK_EXPECT( m ).with( mock::retrieve( p ), 3 ); MOCK_EXPECT( m ).with( mock::retrieve( p ), 7 ).calls( []( std::unique_ptr< … > pa ) { … } ); m( std::make_unique< … >( … ), 7 ); Here is what happens when m is being called : evaluate first expectation...

  • jabaa jabaa created ticket #68

    MOCK_CONSTRUCTOR calls default constructor

  • Darin Ohashi Darin Ohashi posted a comment on ticket #67

    I took a quick look at the change. I see tests for calls and equal, does this also add support for retrieve? I can implement retrieve on top of calls myself, but the retrieve functionality is what I really want.

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #67

    I believe https://github.com/mat007/turtle/pull/35 should fix the issue. The part you would more likelly be interested in would be https://github.com/mat007/turtle/pull/35/files#diff-585dc13369fc2ce33f49443a59c4e315R708 Does that look good to you? If it does I'll merge the pull request and you will be able to give it a go.

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #67

    Indeed a unique_ptr still needs to behave correctly in non immutable constraints, including mock::equal. I'm still working on the details but I'm hoping to come up with a pull request in the next couple of days.

  • Darin Ohashi Darin Ohashi posted a comment on ticket #67

    Would it be possible to create a constraint for unique_ptrs that compared against the pointer value stored (ake the value of the .get() method) instead of the actual unqiue_ptr, so you wouldn't have to move the unique_ptr to test the contraint?

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #67

    I have made some progress on this issue and now it falls down to the following design decision. When a call occurs with actual parameters being passed to a mock object, among other checks (sequence, …) it first applies the constraints (e.g. what was passed to 'with') then if they "match" it performs the action (e.g. call a functor with the same signature as the mocked method). In case of a moved parameter this would mean forwarding to a constraint and then again to the action functor. Obviously this...

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #67

    Adding support for retrieving the unique_ptr using mock::retrieve looks simple enough, see for instance https://github.com/mat007/turtle/pull/34 However I would have expected more plumbing to be needed to move the unique_ptr through the internals of turtle, e.g. from where you call container->accept( std::move( v ) ) up to the point where the constraint gets tested. For instance this fails to compile BOOST_AUTO_TEST_CASE( std_unique_ptr_is_supported_in_retrieve_constraint ) { MOCK_FUNCTOR( f, void(...

  • Mathieu Champlon Mathieu Champlon modified a comment on ticket #67

    Hi Darin, Believe or not it seems this is the first time such a use case is being brought forward for turtle ! I'm afraid this is currently not supported in turtle… I will be having a look on how to add it. Thanks for the improvement suggestion!

  • Darin Ohashi Darin Ohashi posted a comment on ticket #67

    I am a bit surprised by that, I thought using smart pointers was pretty common these days. I think I can make do with the managed_compare constraint for now. The container is a mock so I can return a different object then the one that was inserted and it shouldn't matter to the class being tested, but that does require a bit more work. Thank you for writing turtle. It is great. It has made our unit testing way easier and cleaner.

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #67

    Hi Darin, Believe or not it seems this is the first time such a use case is being brought forward for turtle ! I'm afraid this currently not supported in turtle… I will be having a look on how to add it. Thanks for the improvement suggestion!

  • Mathieu Champlon Mathieu Champlon modified ticket #66

    mock expectation on protected method

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #66

    Closing it, re-open if you need further help on this.

  • Mathieu Champlon Mathieu Champlon modified ticket #67

    Mock a method that accepts a unique_ptr

  • Darin Ohashi Darin Ohashi created ticket #67

    Mock a method that accepts a unique_ptr

  • Mathieu Champlon Mathieu Champlon modified ticket #66

    mock expectation on protected method

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #66

    Hi Gianni, You have to use the 'tag' e.g, MOCK_EXPECT(smoothingFrame()->mock_prot).once().returns(false); The reason you are not used to this is because when using MOCK_EXPECT the tag defaults to the method name, for instance MOCK_METHOD_EXT(validate, 0, bool(), validate); MAT.

  • gambr gambr created ticket #66

    mock expectation on protected method

  • Mathieu Champlon Mathieu Champlon modified ticket #65

    Force a mock method to throw an exception

  • gambr gambr posted a comment on ticket #65

    Thanks again Mathieu, I wasn't aware of the state sharing for copied objects. I verified it works. This case can be closed then. Regards, Gianni

  • Mathieu Champlon Mathieu Champlon modified a comment on ticket #65

    Indeed this explains the issue. I believe you could also do PathMock* path = new PathMock(); MOCK_EXPECT(path->smooth).throws(Exception()); MOCK_EXPECT(path->clone).returns(new PathMock(*path)); because as stated in http://turtle.sourceforge.net/turtle/reference.html#turtle.reference.creation mock objects can be copied and all copies then share the same state. MAT.

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #65

    Indeed this explains the issue. I believe you could also do PathMock* path = new PathMock(); MOCK_EXPECT(path->smooth).throws(Exception()); MOCK_EXPECT(path->clone).returns(new PathMock(*path)); because as stated in http://turtle.sourceforge.net/turtle/reference.html#turtle.reference.creation mock can be copied and all copies then share the same state. MAT.

  • gambr gambr posted a comment on ticket #65

    Hi Mathieu, thanks for suggesting to make a self contained test: I realized the point! You can give a look at the attached file but basically I had: PathMock* path = new PathMock(); MOCK_EXPECT(path->smooth).throws(Exception()); MOCK_EXPECT(path->clone).returns(new PathMock()); instead I should have writted something like: PathMock path = new PathMock(); PathMock clonedPath = new PathMock(); MOCK_EXPECT(path->clone).returns(clonedPath); MOCK_EXPECT(clonedPath->smooth).throws(Exception()); In fact...

  • gambr gambr posted a comment on ticket #65

    Hi Mathieu, I can make a try. Regards, Gianni

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #65

    Hi, Do you think you might be able to make a small self contained test case I could investigate? Thanks, MAT.

  • gambr gambr posted a comment on ticket #65

    Hi Mathieu, ExecutionException inherits from Exception which is a base class (it is a root class - no inhheritance). I noticed you have "once()" in addition wrt my example but I also tried with "once()" in vain. Cheers, Gianni

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #65

    Hi Gianni, At first glace it looks like it should work, here is a test I just wrote to confirm it: namespace { MOCK_CLASS( my_mock ) { MOCK_METHOD_EXT( my_method, 1, int( int ), my_tag ) }; } BOOST_AUTO_TEST_CASE( basic_mock_object_usage ) { my_mock m; MOCK_EXPECT( m.my_tag ).once().throws( std::runtime_error( "some exception" ) ); BOOST_CHECK_THROW( m.my_method( 27 ), std::exception ); } How are Exception and ExecutionException defined ? MAT.

  • gambr gambr created ticket #65

    Force a mock method to throw an exception

  • Mathieu Champlon Mathieu Champlon modified ticket #16

    mock::retrieve fails with boost::function

  • Mathieu Champlon Mathieu Champlon modified ticket #64

    mock method returning rvalue reference

  • gambr gambr posted a comment on ticket #64

    Thanks, it works! Gianni

  • Mathieu Champlon Mathieu Champlon modified ticket #64

    mock method returning rvalue reference

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #64

    Hi Gianni, You might want to use 'moves' instead of 'returns' e.g. MOCK_EXPECT(motionCompensator->eye).moves(osg::Vec3d());...

  • gambr gambr created ticket #64

    mock method returning rvalue reference

  • Mathieu Champlon Mathieu Champlon modified ticket #62

    Build library

  • Mathieu Champlon Mathieu Champlon modified ticket #63

    returns action customization

  • Mathieu Champlon Mathieu Champlon modified ticket #63

    returns action customization

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #63

    Hi Gianni, In order to do that you just need to use 'calls' instead of 'returns'....

  • gambr gambr created ticket #63

    returns action customization

  • Mathieu Champlon Mathieu Champlon modified a blog post

    Turtle 1.3.0 has been released !

  • Mathieu Champlon Mathieu Champlon created a blog post

    Turtle 1.3.0 has been released !

  • Turtle Turtle released /turtle/1.3.0/turtle-1.3.0.tar.bz2

  • Turtle Turtle released /boost-mock/1.3.0/boost-mock-1.3.0.zip

  • Turtle Turtle released /turtle/1.3.0/turtle-1.3.0.zip

  • Turtle Turtle released /boost-mock/1.3.0/boost-mock-1.3.0.tar.bz2

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #62

    Hi Loïc, Turtle is only available as a header-ony library, it cannot be built into...

  • Loic BERTHOLLET Loic BERTHOLLET posted a comment on ticket #62

    Hello Mathieu, I'm fully agree: Boost can be used as header only, as turtle and Boost.Mock....

  • Mathieu Champlon Mathieu Champlon modified ticket #62

    Build library

  • Mathieu Champlon Mathieu Champlon posted a comment on ticket #62

    Hi, Sorry, for some reason I didn't get an email from SF notifying me of a new ticket...

  • Loic BERTHOLLET Loic BERTHOLLET created ticket #62

    Build library

  • Mathieu Champlon Mathieu Champlon created a blog post

    Turtle 1.2.8 has been released !

  • Turtle Turtle released /boost-mock/1.2.8/boost-mock-1.2.8.zip

  • Turtle Turtle released /boost-mock/1.2.8/boost-mock-1.2.8.tar.bz2

1 >