title: How to mock a reference parameter value of function argument in GMock EXPECT_CALL
body: <p>I am novice to google mock just started and tried to write first mock test as follows. AWSS3io is a rest api class to communicate with AWS s3 server to get files. I want to test the -ve scenario i.e 500 response code. Could you please give valuable comments that is this code good or there are other ways to make t more elegant.</p>
  
  <hr>
  
  <p>================Below is the code.===================</p>
  
  <pre><code>File: AWSS3io.h
  ---------------------------start-----------------------------------
  class AWSS3io  {
          private:
              std::string m_aws_url;
  
          public:
              IO_STATUS_CODE get(const std::string &amp;key, std::string &amp;output_string, int &amp;resp_code);
              AWSS3io(const std::string &amp;  aws_url);
              ~AWSS3io();
      };
  #if GTEST
  class MockAWSS3io
      {
          private:
              std::string m_aws_url;
  
          public:
              MockAWSS3io(const std::string &amp; aws_url) { m_aws_url = aws_url; }
              ~MockAWSS3io() {}
              MOCK_METHOD3(get, IO_STATUS_CODE(const std::string &amp;key, std::string &amp;output_string, int &amp;resp_code));
      };
  #endif
      class AWSio
      {
          public:
               AWSio(AWSS3io* paws);
              ~AWSio();
              IO_STATUS_CODE get(const std::string &amp;key, std::string &amp;output_string);
  #if GTEST
              MockAWSS3io* aws_s3_io = nullptr;
  #else
              AWSS3io* aws_s3_io = nullptr;
  #endif
      };
  ---------------------------end-----------------------------------
  
  file: tests/test_aws_mock_test.cpp
  ---------------------------start-----------------------------------
  TEST(FileGetTest, FailureCase) {
      const std::string t_aws_url = "aa.s3.awss3.com";
      MockAWSS3io aws_s3_io(t_aws_url);
      EXPECT_CALL(*aws_s3_io, get(_,_,_))
      .Times(AtLeast(2)).WillOnce(testing::SetArgReferee&lt;2&gt;(500)).WillRepeatedly(testing::SetArgReferee&lt;2&gt;(200));
  
      AWSio awsio(&amp;aws_s3_io);
      std::string key, value;
      EXPECT_TRUE(awsio.get(key, value));
  }
  
  int main(int argc, char** argv) {
    ::testing::InitGoogleMock(&amp;argc, argv);
    return RUN_ALL_TESTS();
  }
  ---------------------------end-----------------------------------
  </code></pre>