Visual studio 8, problem with mocking methods which is having LPCTSTR parameters

21 views
Skip to first unread message

Yogish Acharya

unread,
Mar 3, 2016, 1:52:21 PM3/3/16
to Google C++ Mocking Framework

Hi,

I am new to GMOCK.
Trying to mock the method which is taking LPCTSTR as a parameter and returning LPCTSTR .
example: virtual LPCTSTR GetData(LPCTSTR key) const. 

My mock looks like this   MOCK_CONST_METHOD1(GetData, LPCTSTR(LPCTSTR key));
My expected call looks like this  

CString str("tesing");
LPCTSTR key = str;
LPCTSTR csValue;

EXPECT_CALL(*obj, GetData(key)).WillOnce(Return(csPSValue)); 

/// Function body///
LPCTSTR CSomeInfo::Get(LPCTSTR key)
{

    return GetData(key ); // mocked method 
}

///

Here I always get null string  as a return value. I was successfully mock the methods which are having integer, CString   parameters but not able to do for LPCTSTR

Please help me.

Thanks,
Yogish



Corey Kosak

unread,
Mar 3, 2016, 7:24:06 PM3/3/16
to Yogish Acharya, Google C++ Mocking Framework
It's always better for us if we have real code to work with rather than something put together in a more ad-hoc fashion. That said, I'm focusing on this line

EXPECT_CALL(*obj, GetData(key)).WillOnce(Return(csPSValue)); 

When program execution crosses this point in your program, what is the value of "csPSValue"?

--

---
You received this message because you are subscribed to the Google Groups "Google C++ Mocking Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to googlemock+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/googlemock/4ef29330-3a02-4a90-b91c-f8963c160f3c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages