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

Hello,

I want to use the FAKE_ALL to fake all my objects of the same class. I modified the example from the documentation of DoInstead:

class Person
{
	public:
	     int GetAverageAge() { return 0; }
};
 
class AltPerson
{
	public:         
        int ISOLATOR_TESTABLE ReturnAnotherAge()
        {
          return 10; 
        }
};

I use FAKE_ALL to fake all future instances of Person in this way:

PersonlivePerson = FAKE_ALL<Person>();
AltPersonaltPerson = new AltPerson();
WHEN_CALLED(livePerson->GetAverageAge()).DoMemberFunctionInstead(altPersonReturnAnotherAge);
 
Person *realPerson = new Person();
ASSERT_EQ(10, realPerson->GetAverageAge());
 
ISOLATOR_CLEANUP();

Unfortuantely the original method of Person is used which returns 0.
Am I using this in the wrong way or is something else not correct?

I use Windows 10 and google test.

Thanks a lot in advance,
Michaela

closed with the note: User found out it's working as expected.
asked by MB (1.6k points)
closed by Alon_TypeMock

1 Answer

0 votes

Hi Michaela,

That's an intersting case.
We will invistigate it and keep you posted on our progress.

Cheers,
Alon Sapozhnikov.
Support Specialist.

answered by Alon_TypeMock (10.6k points)
Hi Alon,

I found the real problem for this case. The debugger isn't working in the right way. When I jump into the method that is called the debugger shows me the code from the class that I faked. But the ASSERT_EQ confirms that I get the result of the method that should be used instead of.

So all is right on your side!

I'm sorry for making you work.

Thanks anyway,

Michaela

Hi Michaela,

Thank you for the update.
I was just about to reply back that I couldn't reproduced the issue because the test is passing on my machine.
Enjoy using Isolator++.

Cheers,
Alon Sapozhnikov.
Support Specialist.

...