I am new in google test and started to work to mock object, after mocking object my original method always getting called
up vote
0
down vote
favorite
Original prototype of function
virtual void GetSegment(const std::string& polygonId,
mi::Uint32& numSegment,
std::vector<std::vector<mi::math::Vector_struct<mi::Float32, 3>>>* points,
std::vector<mi::Uint32>* exclusive);
Mocking my function
MOCK_METHOD4(GetSegment,
void(const std::string&, mi::Uint32&, std::vector<std::vector<mi::math::Vector_struct<mi::Float32, 3>>>*,
std::vector<mi::Uint32>*));
And here is my action.
mi::Uint32 numSegment = 1;
std::vector<mi::Uint32> exclusive(0);
std::vector<std::vector<mi::math::Vector_struct<mi::Float32, 3> >> points
50.8981, 213.265, 125,
117.287, 184.577, 125,
215.488, 129.682, 125,
276.487, 92.0992, 125;
ON_CALL(*mock.get(), GetSegment(refrenceId, _, _, _)).
WillByDefault(DoAll(SetArgReferee<1>(numSegment), SetArgPointee<2>(points), SetArgPointee<3>(exclusive)));
After calling the function, always my original is getting called.
c++ mocking googletest gmock
New contributor
add a comment |
up vote
0
down vote
favorite
Original prototype of function
virtual void GetSegment(const std::string& polygonId,
mi::Uint32& numSegment,
std::vector<std::vector<mi::math::Vector_struct<mi::Float32, 3>>>* points,
std::vector<mi::Uint32>* exclusive);
Mocking my function
MOCK_METHOD4(GetSegment,
void(const std::string&, mi::Uint32&, std::vector<std::vector<mi::math::Vector_struct<mi::Float32, 3>>>*,
std::vector<mi::Uint32>*));
And here is my action.
mi::Uint32 numSegment = 1;
std::vector<mi::Uint32> exclusive(0);
std::vector<std::vector<mi::math::Vector_struct<mi::Float32, 3> >> points
50.8981, 213.265, 125,
117.287, 184.577, 125,
215.488, 129.682, 125,
276.487, 92.0992, 125;
ON_CALL(*mock.get(), GetSegment(refrenceId, _, _, _)).
WillByDefault(DoAll(SetArgReferee<1>(numSegment), SetArgPointee<2>(points), SetArgPointee<3>(exclusive)));
After calling the function, always my original is getting called.
c++ mocking googletest gmock
New contributor
How do you call the function (on which instance) ?
– Jarod42
Nov 8 at 13:16
I am calling From my base class instance.
– Abhi
Nov 8 at 13:33
You should call your mock...
– Jarod42
Nov 8 at 13:49
I am getting the same problem, Whether SetArgPointee can point a vector type?
– Abhi
Nov 9 at 9:09
Can you please post the function that is actually using the mock? So far you only have defined the mock, and specified what the mock should do when called, but you haven`t shown us the code that is acutally using the it.
– CharonX
Nov 9 at 11:09
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Original prototype of function
virtual void GetSegment(const std::string& polygonId,
mi::Uint32& numSegment,
std::vector<std::vector<mi::math::Vector_struct<mi::Float32, 3>>>* points,
std::vector<mi::Uint32>* exclusive);
Mocking my function
MOCK_METHOD4(GetSegment,
void(const std::string&, mi::Uint32&, std::vector<std::vector<mi::math::Vector_struct<mi::Float32, 3>>>*,
std::vector<mi::Uint32>*));
And here is my action.
mi::Uint32 numSegment = 1;
std::vector<mi::Uint32> exclusive(0);
std::vector<std::vector<mi::math::Vector_struct<mi::Float32, 3> >> points
50.8981, 213.265, 125,
117.287, 184.577, 125,
215.488, 129.682, 125,
276.487, 92.0992, 125;
ON_CALL(*mock.get(), GetSegment(refrenceId, _, _, _)).
WillByDefault(DoAll(SetArgReferee<1>(numSegment), SetArgPointee<2>(points), SetArgPointee<3>(exclusive)));
After calling the function, always my original is getting called.
c++ mocking googletest gmock
New contributor
Original prototype of function
virtual void GetSegment(const std::string& polygonId,
mi::Uint32& numSegment,
std::vector<std::vector<mi::math::Vector_struct<mi::Float32, 3>>>* points,
std::vector<mi::Uint32>* exclusive);
Mocking my function
MOCK_METHOD4(GetSegment,
void(const std::string&, mi::Uint32&, std::vector<std::vector<mi::math::Vector_struct<mi::Float32, 3>>>*,
std::vector<mi::Uint32>*));
And here is my action.
mi::Uint32 numSegment = 1;
std::vector<mi::Uint32> exclusive(0);
std::vector<std::vector<mi::math::Vector_struct<mi::Float32, 3> >> points
50.8981, 213.265, 125,
117.287, 184.577, 125,
215.488, 129.682, 125,
276.487, 92.0992, 125;
ON_CALL(*mock.get(), GetSegment(refrenceId, _, _, _)).
WillByDefault(DoAll(SetArgReferee<1>(numSegment), SetArgPointee<2>(points), SetArgPointee<3>(exclusive)));
After calling the function, always my original is getting called.
c++ mocking googletest gmock
c++ mocking googletest gmock
New contributor
New contributor
edited Nov 8 at 13:13
Jarod42
111k1299176
111k1299176
New contributor
asked Nov 8 at 13:01
Abhi
11
11
New contributor
New contributor
How do you call the function (on which instance) ?
– Jarod42
Nov 8 at 13:16
I am calling From my base class instance.
– Abhi
Nov 8 at 13:33
You should call your mock...
– Jarod42
Nov 8 at 13:49
I am getting the same problem, Whether SetArgPointee can point a vector type?
– Abhi
Nov 9 at 9:09
Can you please post the function that is actually using the mock? So far you only have defined the mock, and specified what the mock should do when called, but you haven`t shown us the code that is acutally using the it.
– CharonX
Nov 9 at 11:09
add a comment |
How do you call the function (on which instance) ?
– Jarod42
Nov 8 at 13:16
I am calling From my base class instance.
– Abhi
Nov 8 at 13:33
You should call your mock...
– Jarod42
Nov 8 at 13:49
I am getting the same problem, Whether SetArgPointee can point a vector type?
– Abhi
Nov 9 at 9:09
Can you please post the function that is actually using the mock? So far you only have defined the mock, and specified what the mock should do when called, but you haven`t shown us the code that is acutally using the it.
– CharonX
Nov 9 at 11:09
How do you call the function (on which instance) ?
– Jarod42
Nov 8 at 13:16
How do you call the function (on which instance) ?
– Jarod42
Nov 8 at 13:16
I am calling From my base class instance.
– Abhi
Nov 8 at 13:33
I am calling From my base class instance.
– Abhi
Nov 8 at 13:33
You should call your mock...
– Jarod42
Nov 8 at 13:49
You should call your mock...
– Jarod42
Nov 8 at 13:49
I am getting the same problem, Whether SetArgPointee can point a vector type?
– Abhi
Nov 9 at 9:09
I am getting the same problem, Whether SetArgPointee can point a vector type?
– Abhi
Nov 9 at 9:09
Can you please post the function that is actually using the mock? So far you only have defined the mock, and specified what the mock should do when called, but you haven`t shown us the code that is acutally using the it.
– CharonX
Nov 9 at 11:09
Can you please post the function that is actually using the mock? So far you only have defined the mock, and specified what the mock should do when called, but you haven`t shown us the code that is acutally using the it.
– CharonX
Nov 9 at 11:09
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Abhi is a new contributor. Be nice, and check out our Code of Conduct.
draft saved
draft discarded
Abhi is a new contributor. Be nice, and check out our Code of Conduct.
Abhi is a new contributor. Be nice, and check out our Code of Conduct.
Abhi is a new contributor. Be nice, and check out our Code of Conduct.
draft saved
draft discarded
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53208289%2fi-am-new-in-google-test-and-started-to-work-to-mock-object-after-mocking-object%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
How do you call the function (on which instance) ?
– Jarod42
Nov 8 at 13:16
I am calling From my base class instance.
– Abhi
Nov 8 at 13:33
You should call your mock...
– Jarod42
Nov 8 at 13:49
I am getting the same problem, Whether SetArgPointee can point a vector type?
– Abhi
Nov 9 at 9:09
Can you please post the function that is actually using the mock? So far you only have defined the mock, and specified what the mock should do when called, but you haven`t shown us the code that is acutally using the it.
– CharonX
Nov 9 at 11:09