Accessing Hidden Data Members Accessing Hidden Data Members Accessing Hidden Data Members Accessing Hidden Data Members Accessing Hidden Data Members Accessing Hidden Data Members Accessing Hidden Data Members Accessing Hidden Data Members Accessing Hidden Data Members Accessing Hidden Data Members Accessing Hidden Data Members Accessing Hidden Data Members Accessing Hidden Data Members Accessing Hidden Data Members Accessing Hidden Data Members Accessing Hidden Data Members Accessing Hidden Data Members Accessing Hidden Data Members Accessing Hidden Data Members Accessing Hidden Data Members Accessing Hidden Data Members Accessing Hidden Data Members

Accessing Hidden Data Members

Top  Previous  Next

With Isolator++ Professional you can access any data member of your classes, regardless to their access modifier.

Including private and protected members. Isolator++ Professional can access any static variable too

 

Use the following APIs to access variables in tests will make your tests more robust,

since replacing the access modifier of a variable will not affect the test.

 

Set member value:

 

ISOLATOR_SET_VARIABLE(<instance>, <variable_name>, <value>);

 

Example:
 

ISOLATOR_SET_VARIABLE(person, m_id, 10);

 

Get member value:

 

ISOLATOR_SET_VARIABLE(<instance>, <variable_name>, <result>);

 

Note: Give a resulting variable initial value. It shouldn't be empty.

Example:

 

int memberValue = 0;
ISOLATOR_GET_VARIABLE(person, m_id, memberValue);

 

Note: Getting an array value will not make any copy but return a pointer to the array. The best practice is to use pointer:

 

int* arr = NULL;
ISOLATOR_GET_VARIABLE(person, m_array, arr);

 

Static Data Members

 

To access static data members pass _  for the <instance> and the full name for the <variable_name>

 

Example setting std::map member:

 

std::map<int,mytype> myMap;
myMap[0] = mytype{0};
ISOLATOR_SET_VARIABLE(_, Person::m_static, myMap);

 

and

 

std::map<int,mytype> memberValue = NULL;
ISOLATOR_GET_VARIABLE(_, Person::m_static, memberValue);

 

Static Variables

 

Static Data Members

 

To access static variable  pass _  for the <instance> and the name for the <variable_name>

 

Example:

 

ISOLATOR_SET_VARIABLE(_, staticVariable, 10);

 

and

 

int value = 0;
ISOLATOR_GET_VARIABLE(_, staticVariable, value);

 

 


Copyright  Typemock Ltd. 2009-2022.  All Rights Reserved.