{"action":"closed","issue":{"url":"https://api.github.com/repos/mat007/turtle/issues/3","labels_url":"https://api.github.com/repos/mat007/turtle/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/mat007/turtle/issues/3/comments","events_url":"https://api.github.com/repos/mat007/turtle/issues/3/events","html_url":"https://github.com/mat007/turtle/issues/3","id":64382839,"number":3,"title":"Calls made to a function as part of the framework (ie matcher) increment the call count","user":{"login":"Aperion","id":155682,"avatar_url":"https://avatars.githubusercontent.com/u/155682?v=3","gravatar_id":"","url":"https://api.github.com/users/Aperion","html_url":"https://github.com/Aperion","followers_url":"https://api.github.com/users/Aperion/followers","following_url":"https://api.github.com/users/Aperion/following{/other_user}","gists_url":"https://api.github.com/users/Aperion/gists{/gist_id}","starred_url":"https://api.github.com/users/Aperion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Aperion/subscriptions","organizations_url":"https://api.github.com/users/Aperion/orgs","repos_url":"https://api.github.com/users/Aperion/repos","events_url":"https://api.github.com/users/Aperion/events{/privacy}","received_events_url":"https://api.github.com/users/Aperion/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-25T22:00:43Z","updated_at":"2015-03-31T20:18:26Z","closed_at":"2015-03-31T20:18:26Z","body":"This occurs when using the `with` constraint and mock classes.\r\n\r\nI have not run this code but I hope it demonstrates the issue. It appears that calls made for the catcher are counted against the MOCK_EXPECT count\r\n\r\n```c++\r\nclass Id\r\n{\r\npublic:\r\n\tvirtual ~Id(){}\r\n\tvirtual std::string GetId() const = 0;\r\n\tvirtual void Copy(const Id& id) const = 0;\r\n}\r\n\r\nMOCK_BASE_CLASS(IdMock, Id)\r\n{\r\npublic:\r\n\tMOCK_CONST_METHOD(GetId, 0, std::string());\r\n\tMOCK_CONST_METHOD(Copy, 1, void(const Id& id));\r\n}\r\n\r\nbool operator==(const Id& lhs, const IA& rhs)\r\n{\r\n\treturn lhs.GetId() == rhs.GetId();\r\n}\r\n\r\nclass IdCheckNCopy\r\n{\r\npublic:\r\n\tvoid CheckNCopy(const Id& a)\r\n\t{\r\n\t\t// one call to GetId\r\n\t\tif(a.GetId() == \"Id\")\r\n\t\t\t// one call to Copy\r\n\t\t\ta.Copy(a);\r\n\t}\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE(SampleTest)\r\n{\r\n\tIdMock mocked;\r\n\t\r\n\t// expect only one call for if(a.GetId() == \"Id\")\r\n\tMOCK_EXPECT(mocked.GetID).once().returns(\"Id\"); \r\n\t// only one call expected for a.Copy(a)\r\n\tMOCK_EXPECT(mocked.Copy).once().with(mocked);\r\n\t\r\n\t \r\n\tIdCheckNCopy checkNCopy;\r\n\t // matcher makes two calls to .GetId() via operator==\r\n\tcheckNCopy.CheckNCopy(mocked);\r\n}\r\n\r\nclass IdCopy\r\n{\r\npublic:\r\n\tvoid Copy(const Id& a)\r\n\t{\r\n\t\t// one call to GetId\r\n\t\ta.Copy(a);\r\n\t}\r\n}\r\n\r\nBOOST_AUTO_TEST_CASE(SampleTest)\r\n{\r\n\tIdMock mocked;\r\n\t// only one call expected for a.Copy(a)\r\n\tMOCK_EXPECT(mocked.Copy).once().with(mocked);\r\n\t\r\n\t \r\n\tIdCopy copy;\r\n\t // matcher makes two calls to .GetId() via operator==, none are expected;\r\n\tcopy.Copy(mocked);\r\n}\r\n\r\n```"}}