calvert1991/googlemock

Truly() should accept multi-argument function pointers when used as a tuple matcher

Opened this issue · 1 comments

This doesn't compile:

bool IsDivisible(int x, int y) {
  return x % y == 0;
}
...
EXPECT_CALL(...)
  .With(Args<0, 1>(Truly(&IsDivisible));

as Truly() expects its argument to be a function that takes exactly one 
argument (in this case, a 2-tuple).

The user needs to write IsDivisible() as

bool IsDivisible(const tr1::tuple<int, int> p) {
  return tr1::get<0>(p) % tr1::get<1>(p) == 0;
}

which is tedious and unobvious.

The original definition of IsDivisible should just work in the example.

Original issue reported on code.google.com by w...@google.com on 9 Sep 2010 at 5:21

Original comment by w...@google.com on 27 Sep 2010 at 9:38