wanyisunflower / googlemock

Automatically exported from code.google.com/p/googlemock
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

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

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago

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