wangyu5 / googlemock

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

Need to extend .WithArguments to allow selection of arguments #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Currently ON_CALL() and EXPECT_CALL() accepts a
.WithArguments(tuple_matcher) clause for specifying constraints on multiple
arguments, but it's not very easy to use.  The proposal:

- Allow optional template arguments to select the function arguments that
will participate in the matching, ala the WithArgs(callable) action.
- Allow the clause to be used more than once in an expectation.

For example,

  ON_CALL(foo, Bar(_, _, _))
      .WithArguments(A())
      .WithArguments<0, 2>(B())
      .WithArguments<2, 1>(C());

says that:

  - argument 0, 1, and 2 should match matcher A(),
  - argument 0 and 2 should match matcher B(), and
  - argument 2 and 1 should match matcher C().

One use case is that often a function passes a pointer to a buffer in one
argument and the size of the buffer in another argument, and we may want to
verify that the contents of the buffer are expected.

Original issue reported on code.google.com by shiq...@gmail.com on 2 Oct 2008 at 9:27

GoogleCodeExporter commented 9 years ago

Original comment by zhanyong...@gmail.com on 4 Mar 2009 at 7:10

GoogleCodeExporter commented 9 years ago
We decided to implement the .With(Args<0, 1>(m)) syntax instead.

Original comment by zhanyong...@gmail.com on 5 Jun 2009 at 5:24