Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throwing an exception as default breaks call count expectation #171

Open
GoogleCodeExporter opened this issue May 13, 2015 · 0 comments
Open

Comments

@GoogleCodeExporter
Copy link

using gmock 1.7.0, gtest 1.7.0 on linux x64 (ubuntu 14.10)

Example:

----
class MyMock {
public:
  MOCK_METHOD0(func, void());
};

TEST(MyTest, testMock) {
  MyMock mock;
  ON_CALL(mock, func()).WillByDefault(Throw(std::logic_error("error")));
  EXPECT_CALL(mock, func()).Times(0);
  try {
    mock.func();
  } catch (std::logic_error &e) {
  }
}
----

The test is green and passes. I expect it to fail, because the mock function is 
called once but I expect it not to be..

I assume in the gmock implementation, the call counter is incremented after the 
function returns and throwing an exception jumps over this piece of code.

Original issue reported on code.google.com by heinzis...@gmail.com on 20 Nov 2014 at 11:33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant