background image
<< To work around this problem | Testing Environments >>
<< To work around this problem | Testing Environments >>

Simulating Functions with char Parameters

Automated Testing
END DEFINE
You should modify the .ptu script like this:
DEFINE STUB fct_sim_c
#int fct_sim(double _in c, unsigned char _inout d);
END DEFINE
Or, if testing the parameters is not required:
DEFINE STUB fct_sim_c
#int fct_sim(double _no c, unsigned char _no d);
END DEFINE
Simulating Functions with char* Parameters
You can use Component Testing for C to stub functions that take a parameter of the
char*
type
.
The
char*
type causes problems with the Component Testing feature because of the
ambiguity built into the C programming language. The
char*
type can represent:
·
Pointers
·
Pointers to a single
char
·
Arrays of characters of indeterminate size
·
Arrays of characters of which the last character is the character \0, a C string.
By default, Component Testing treats all variables of this type as C strings. If this is
not the desired behavior, then you must inform Component Testing with the use of
other instructions. To force to another representation use one of the following
methods.
Pointers
Define the stub as in the following example:
#int StubFunction(char* pChar);
DEFINE STUB Stubs
#int StubFunction(void* _in pChar)
END DEFINE
#char MyChar = 'A';
STUB StubFunction(NIL)0, (&MyChar)1
Pointers to a Single char
Define the type as _inout, as in the following example. The * isn't necessary as the
type must be a pointer to be an out parameter:
#int StubFunction(char* pChar);
DEFINE STUB Stubs
#int StubFunction(char _inout pChar)
END DEFINE
STUB StubFunction(('a','A'))0
Arrays of Characters of Indeterminate Size
151