title: GoogleMock - Matchers and MFC\ATL CString
body: <p>I asked this question on the Google Group but I think I will get a faster response on here.</p>
  
  <p>I'm trying to use <a href="http://code.google.com/p/googlemock/" rel="nofollow noreferrer">Google's Mocking framework</a> to test my code. I am also utilizing their <a href="http://code.google.com/p/googletest/" rel="nofollow noreferrer">test framework</a> as well. I'm compiling in VC9. 
  I'm having issues matching arguments that are MFC\ATL CStrings. GMock
  says the objects are not equal and it appears it is evaluating on the
  pointer addresses. The method I am attempting to mock is structured
  like so:</p>
  
  <pre><code>void myMethod(const CString &amp; key, const CString &amp; value);
  </code></pre>
  
  <p>thus:</p>
  
  <pre><code>MOCK_METHOD2(myMethod, void(const CString &amp; key , const CString &amp;
  value);
  </code></pre>
  
  <p>When setting up my expectations I am doing to following comparison:</p>
  
  <pre><code>CString szKey = _T("Some key");
  CString szValue = _T("Some value");
  
  EXPECT_CALL(myMock, myMethod(Eq(szKey), Eq(szValue))).WillOnce(Return
  (true));
  </code></pre>
  
  <p>I have tried many different combinations of the matchers such as:</p>
  
  <pre><code>EXPECT_CALL(myMock, myMethod(StrCaseEq(_T("Some Key")), StrCaseEq(_T
  (""Some value)))).WillOnce(Return(true));
  
  EXPECT_CALL(myMock, myMethod(TypedEq&lt;const CString &amp;&gt;(szKey),
  TypedEq&lt;const CString &amp;&gt;(szValue))).WillOnce(Return(true));
  
  
  EXPECT_CALL(myMock, myMethod(TypedEq&lt;const CString &amp;&gt;(szKey),
  TypedEq&lt;const CString &amp;&gt;(szValue))).WillOnce(Return(true));
  </code></pre>
  
  <p>Any of the above calls have produced the same result. Anyone else run
  into this issue?</p>
  
  <p>This is the output:</p>
  
  <p>Google Mock tried the following 2 expectations, but none matched:</p>
  
  <pre><code>:80: tried expectation #0
    Expected arg #1: is equal to 006D430C pointing to "Some value"
             Actual: 4-byte object &lt;A8EF 1102&gt;
           Expected: to be called once
             Actual: never called - unsatisfied and active
  :83: tried expectation #1
    Expected arg #1: is equal to (ignoring case) ""
             Actual: 4-byte object &lt;A8EF 1102&gt;
    Expected arg #2: is equal to (ignoring case) "Some value"
             Actual: 4-byte object &lt;C0EE 1102&gt;
           Expected: to be called once
             Actual: never called - unsatisfied and active
  </code></pre>
  
  <p>Adam</p>