Gmock setting out parameter

Posted by user1135541 on Stack Overflow See other posts from Stack Overflow or by user1135541
Published on 2014-06-05T03:23:53Z Indexed on 2014/06/05 3:24 UTC
Read the original article Hit count: 114

Filed under:
|

Have a gmock method, and during test, need to set the out parameter to variable address. So that the out parameter of dequeue, which is data points to variable ch;

MOCK_METHOD1(dequeue, void(void* data));

char ch = 'm';
void* a = (void*)&ch;

EXPECT_CALL(FQO, dequeue(_))
        .WillOnce(/*here I need to set argument to a*/);

I tried to figure out side effects: https://code.google.com/p/googlemock/wiki/V1_7_CheatSheet#Side_Effects but keep getting an error.

© Stack Overflow or respective owner

Related posts about c++

Related posts about gmock

  • Gmock setting out parameter

    as seen on Stack Overflow - Search for 'Stack Overflow'
    Have a gmock method, and during test, need to set the out parameter to variable address. So that the out parameter of dequeue, which is data points to variable ch; MOCK_METHOD1(dequeue, void(void* data)); char ch = 'm'; void* a = (void*)&ch; EXPECT_CALL(FQO, dequeue(_)) .WillOnce(/*here… >>> More

  • Howto install google-mock on Ubuntu 12.10

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    I am having hard time trying to install Google C++ Mocking Framework. I have successfully run sudo apt-get install google-mock. Then I tried to compile this sample file #include "gmock/gmock.h" int main(int argc, char** argv) { ::testing::InitGoogleMock(&argc, argv); return RUN_ALL_TESTS(); } with… >>> More

  • Howto mix TDD and RAII

    as seen on Stack Overflow - Search for 'Stack Overflow'
    I'm trying to make extensive tests for my new project but I have a problem. Basically I want to test MyClass. MyClass makes use of several other class which I don't need/want to do their job for the purpose of the test. So I created mocks (I use gtest and gmock for testing) But MyClass instantiate… >>> More