chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes

I am using Isolator++ professional version 4.3.1.0

I replicated the same code in the question: Issue with return value of a method that returns CString - Typemock Q&A

Code to be tested:

class CIniFileStub

{

public:

CString GetValueTest1()

{

return "Test1";

}

};

Test Code:

TEST_METHOD(TestCIniFileStub)

{

CIniFileStub* fakeIniFile = FAKE<CIniFileStub>();

CString param1("GeneralInformation");

WHEN_CALLED(fakeIniFile->GetValueTest1()).ReturnPtr(&param1);

CString temp = fakeIniFile->GetValueTest1();

}

The WHEN_CALLED line throws the exception: Unhandled exception at 0x00007FFA1EA2AB3D (UnitTests.dll) in testhost.exe: Stack cookie instrumentation code detected a stack-based buffer overrun.

I tried the approach given here as well: Unable to mock the methods those returns CString in C++ - Typemock Q&A. This one too fails with the same error. 
Note that if the production code returns a reference CString& then I am able to mock the call in the test code using following code:
WHEN_CALLED(fakeIniFile->GetValueTest1()).ReturnPtr(BY_REF(param1));

Please help with this issue.

thanks in Advance !

asked ago by santhoshkulandaiyan (600 points)

1 Answer

0 votes
Hi santhoshkulandaiyan,

I reproduced the problem on my end (I didn't receive the same error message as you did, but I did get the same error as in the Q&A threads you linked). We'll investigate and see how it can be fixed.

Also, I'll open a ticket for this issue, and you'll receive an email from me where we can continue discussing it.

Best,
Tom Milchman
Typemock Support Specialist
answered ago by Tom_Typemock (760 points)
...