title: Specifying output string argument with GoogleMock
body: <p>I'm evaluating the Google Test/Mock as a framework for unit tests of my C code.</p>
  
  <p>How can I specify the output string argument for the function I would like to mock?</p>
  
  <p>Here I have <code>int get_int_param(const char *)</code> is the function to test and it uses <code>int _get_text_file_content(const char *fn, char *content)</code> function that I want to mock.</p>
  
  <p>How to specify this <code>char *content</code> that is going to be the result of execution of mocking function?</p>
  
  <p>I'm struggling with this code:</p>
  
  <pre><code>TEST(GetParameterTest,Positiv){
     const static int strLen=29;
     char *text=(char *)calloc(strLen,1);
     strcpy(text, "param1=1\nparam2=42\nparam3=3");
  
     MokedFunctions mokedFunctions;
     EXPECT_CALL(mokedFunctions, _get_text_file_content("process.conf",_)).Times(AtLeast(1)).WillOnce(SetArgReferee&lt;1&gt;(text));
  
     EXPECT_EQ(1, get_int_param("param1"));
  }
  </code></pre>
  
  <p>and got this compile error:</p>
  
  <pre><code>/usr/include/gmock/gmock-more-actions.h: In instantiation of ‘typename 
  testing::internal::Function&lt;F&gt;::Result testing::SetArgRefereeActionP&lt;k, 
  value_type&gt;::gmock_Impl&lt;F&gt;::gmock_PerformImpl(const args_type&amp;, 
  arg0_type, arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, 
  arg6_type, arg7_type, arg8_type, arg9_type) const [with arg0_type = 
  const char*; arg1_type = char*; arg2_type = 
  testing::internal::ExcessiveArg; arg3_type = 
  testing::internal::ExcessiveArg; arg4_type = 
  testing::internal::ExcessiveArg; arg5_type = 
  testing::internal::ExcessiveArg; arg6_type = 
  testing::internal::ExcessiveArg; arg7_type = 
  testing::internal::ExcessiveArg; arg8_type = 
  testing::internal::ExcessiveArg; arg9_type = 
  testing::internal::ExcessiveArg; F = int(const char*, char*); int k = 1; 
  value_type = char*; typename testing::internal::Function&lt;F&gt;::Result = 
  int; testing::SetArgRefereeActionP&lt;k, 
  value_type&gt;::gmock_Impl&lt;F&gt;::args_type = std::tuple&lt;const char*, char*&gt;]’:
  
   /usr/include/gmock/gmock-generated-actions.h:664:23:   required from 
   ‘static Result testing::internal::ActionHelper&lt;Result, 
   Impl&gt;::Perform(Impl*, const std::tuple&lt;_U1, _U2&gt;&amp;) [with A0 = const 
   char*; A1 = char*; Result = int; Impl = 
   testing::SetArgRefereeActionP&lt;1, char*&gt;::gmock_Impl&lt;int(const char*, 
   char*)&gt;]’
  
   /usr/include/gmock/gmock-more-actions.h:168:1:   required from 
   ‘testing::SetArgRefereeActionP&lt;k, 
   value_type&gt;::gmock_Impl&lt;F&gt;::return_type 
   testing::SetArgRefereeActionP&lt;k, 
   value_type&gt;::gmock_Impl&lt;F&gt;::Perform(const args_type&amp;) [with F = 
   int(const char*, char*); int k = 1; value_type = char*; 
   testing::SetArgRefereeActionP&lt;k, 
   value_type&gt;::gmock_Impl&lt;F&gt;::return_type = int; 
   testing::SetArgRefereeActionP&lt;k, value_type&gt;::gmock_Impl&lt;F&gt;::args_type 
   = std::tuple&lt;const char*, char*&gt;]’
  
   test_param.cpp:68:1:   required from here
   /usr/include/gmock/gmock-more-actions.h:175:3: error: size of array is negative
   GTEST_COMPILE_ASSERT_(internal::is_reference&lt;argk_type&gt;::value,
   ^
   In file included from /usr/include/gmock/gmock.h:65:0,
               from test_param.cpp:2:
    /usr/include/gmock/gmock-more-actions.h:177:28: error: assignment of read-only location ‘std::get&lt;1u, {const char*, char*}&gt;((* &amp; args))’
      ::std::tr1::get&lt;k&gt;(args) = value;
                          ^
    make[1]: *** [test_param.o] Error 1
  </code></pre>
  
  <p>What I'm doing wrong?</p>