calvert1991/googlemock

Print actual values instead of pointers when FieldMatcher is used

Closed this issue · 2 comments

What steps will reproduce the problem?
struct A {
  A(int a) : a_(a){}
  int a_;
};

struct Mock {
  MOCK_METHOD1(Foo, void(A*));
};

A tmp(10);
EXPECT_CALL(mock, Foo(Field(&A::a_, 5)));
mock.Foo(&tmp);

What is the expected output? 

 Expected arg #0: the given field is equal to 5
          Actual: 10

What do you see instead?

 Expected arg #0: the given field is equal to 5
          Actual: 0037FB48



Original issue reported on code.google.com by sto...@google.com on 20 Nov 2009 at 11:38

We can make the implementation of Field() print the value of the field in
ExplainMatchResultTo().  We should do the same for matchers Property() and 
ResultOf().

Original comment by w...@google.com on 3 Dec 2009 at 4:51

  • Changed state: Accepted
  • Added labels: OpSys-All, Type-Enhancement, Usability
  • Removed labels: Type-Defect
Fixed by Manuel Klimek.

Original comment by w...@google.com on 23 Mar 2010 at 7:29

  • Changed state: Fixed