c++ - Using Gtest how return different values in ON_CALL? -
is possible return different values using on_call willbydefault? example
class foomock { mock_method0(foo, int()); } void bar() { foomock mock; int f = 0; on_call(mock, foo()).willbydefault(return(f)); expect_true(f==mock.foo()); // correct f++; expect_true(f==mock.foo()); // failed, because on_call returns f=0 }
does exists way return new value of variable?
yes there way, change code to:
on_call(mock, foo()) .willbydefault(returnpointee(&f));
read more returnpointee
in link (in returning live values mock methods
section)
Comments
Post a Comment