Simulating Functions with Varying Parameters
Automated Testing
This behaviour is the default behaviour for the "const" keyword, the '@' is not
necessary for const.
Example
Consider a type modifier __foo
DEFINE STUB tst_cst
#int ModifParam(@__foo float _in param);
END DEFINE
Note In this example, __foo is not a standard ANSI-C feature. To force Test
RealTime to recognize this keyword as a type modifier, you must add the
following line to the .ptu test script:
##pragma attol type_modifier = __foo
Simulating Functions with Varying Parameters
In some cases, functions may be designed to accept a variable number of parameters
on each call.
You can still stub these functions with the Component Testing feature by using the
'...' syntax indicating that there may be additional parameters of unknown type and
name.
In this case, Component Testing can only test the validity of the first parameter.
Example
The standard
printf
function is a good a example of a function that can take a variable
number of parameters:
int printf (const char* param, ...);
Here is an example including a STUB of the
printf
function:
HEADER add, 1, 1
#extern int add(int a, int b);
##include <stdio.h>
BEGIN
DEFINE STUB MulitParam
#int printf (const char param[200], ...);
END DEFINE
SERVICE add
#int a, b, c;
TEST 1
FAMILY nominal
ELEMENT
VAR a, init = 1, ev = init
VAR b, init = 3, ev = init
VAR c, init = 0, ev = 4
STUB printf("hello %s\n")12
#c = add(a,b);
END ELEMENT
END TEST
END SERVICE
Functions Using const Parameters
149