Issue 2003 open since 2018 and no triage, and I just ran into same issue

34 views
Skip to first unread message

Bill Barnhill

unread,
Nov 20, 2019, 2:32:54 PM11/20/19
to Google C++ Testing Framework
The issue: 

For convenience, the description is copied here:

I have the following overloaded mock functions

MOCK_METHOD1_T(function, void(int value));
MOCK_METHOD1_T(function, void(std::shared_ptr pointer));

if expect the call
EXPECT_CALL(*mock_object, function(testing::Pointee(10))).
Times(2);

I can't compile it, because the call of the overloaded function is ambiguous.
How can I solve this problem.


I've now run into the same issue while getting started with GoogleTest's GMock. I am on 1.8.1 and can't immediately upgrade to 1.10.x. I'm using the old style MOCK_METHODN as a result.


A version of the example above that's closer to my code is:

class Point2D {
public:
 
Point2D(int xa, int ya)
   
: x(xa), y(ya) {}
 
const int x;
 
const int y;
};

class Point3D {
public:
 
Point3D(int xa, int ya, int za)
   
: x(xa), y(ya), z(za) {}
 
const int x;
 
const int y;
 
const int z;
};

class Foo {
public:
   
virtual void update(shared_ptr<Point2D> point) = 0;
   virtual void update(shared_ptr<Point3D> point) = 0;
};

class MockFoo : public Foo {
public:
   
MockFoo() {}
   MOCK_METHOD1
(update, void(
shared_ptr<Point2D> point));
   MOCK_METHOD1(update, void(shared_ptr<Point3D> point));
};

TEST
(FooTest,Update2D) {
   
MockFoo mock_foo;
   EXPECT
(mock_foo, update(Pointee(An<Point2D>()));
   std
::shared_ptr<Point2D> pt2d(new Point2D(2,3));
   mock_foo
.update(pt2d);
}



Can anyone please give me a version of this example that won't result in the following error?


error: call of overloaded 'gmock_update(testing::internal::PointeeMatcher<testing::Matcher<Point2D>>)' is ambiguous

hyuk myeong

unread,
Nov 21, 2019, 9:38:07 AM11/21/19
to Bill Barnhill, Google C++ Testing Framework
Hello~

I don't know it is the proper solution
But I updated some workarounds for your issue

Please check them in issue 2003

--

---
You received this message because you are subscribed to the Google Groups "Google C++ Testing Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to googletestframework+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/googletestframework/200c1bc5-992e-4465-886f-1d13c886eb02%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages