Specifying Parameters for Environments
Automated Testing
Example
The following example illustrates the use of environments:
HEADER histo, 1, 1
##include <math.h>
##include "histo.h"
BEGIN
ENVIRONMENT image
ARRAY image, init = 0, ev = init
END ENVIRONMENT
USE image
SERVICE COMPUTE_HISTO
#int x1, x2, y1, y2;
#int status;
#T_HISTO histo;
#T_IMAGE image1;
ENVIRONMENT compute_histo
VAR x1, init = 0, ev = init
VAR x2, init = SIZE_IMAGE?1, ev = init
VAR y1, init = 0, ev = init
VAR y2, init = SIZE_IMAGE?1, ev = init
ARRAY histo, init = 0, ev = 0
VAR status, init == , ev = 0
END ENVIRONMENT
USE compute_histo
Specifying Parameters for Environments
You can specify parameters for environments.
Declare the parameters in the ENVIRONMENT instruction as you would for a
service:
ENVIRONMENT compute_histo1(a,b,c,d)
VAR x1, init = a, ev = init
VAR x2, init = b, ev = init
VAR y1, init = c, ev = init
VAR y2, init = d, ev = init
ARRAY histo[0..SIZE_HISTO?1], init = 0, ev = 0
VAR status, init ==, ev = 0
END ENVIRONMENT
The parameters are identifiers, which you can use in variable status instructions, as
follows:
·
In initial or expected value expressions
·
In expressions delimiting bounds of arrays in extended mode
The parameters are initialized when they are used:
USE compute_histo1(0,0,SIZE_IMAGE?1,SIZE_IMAGE?1)
The number of values must be strictly equal to the number of parameters defined for
the environment. The values can be expressions of any type.
153