Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Mock functions changing value of parameter

Tags:

c++

googlemock

I am trying to mock out some code that returns information by writing to one of the references passed to the function as a parameter. Is there a good way to mock this behavior such that I can have the test code determine what value is written to that variable?

like image 604
Daniel Avatar asked Oct 02 '15 16:10

Daniel


1 Answers

I did a little research and it turns out that GMock has a couple of nice options. From the Google Mock Cheat Sheet

SetArgReferee<N>(value)
SetArgPointee<N>(value)

"Assign value to the variable referenced by the N-th (0-based) argument" and "Assign value to the variable pointed by the N-th (0-based) argument" respectively.

like image 167
Daniel Avatar answered Sep 19 '22 04:09

Daniel