VAR, ARRAY and STR <initialization> Parameter

C Test Script Language

Purpose

In this documentation, the Component Testing <initialization> parameters for C specify the initial value of the variable.

Syntax

INIT = <exp>

INIT IN { <exp>, <exp>, ... }

INIT ( <variable> ) WITH { <exp>, <exp>, ... }

INIT FROM <exp> TO <exp> [STEP <exp> | NB_TIMES <nb> | NB_RANDOM <nb>[+ BOUNDS]]

INIT FROM <exp> TO <exp> [STEP <exp> | NB_VALUE <nb> | NB_RANDOM <nb>[+ BOUNDS]]

INIT ==

where:

Description

The <initialization> expressions are used to assign an initial value to a variable. The initial value is displayed in the Component Testing report for C.

The INIT value is calculated during the preprocessing phase, not dynamically during test execution.

Initializations can be expressed in the following ways:

The INIT IN and INIT (<variable>) WITH expressions cannot be used with for arrays that were initialized in extended mode or for structures.

The INIT FROM expression can only be used for numeric variables.

The STEP syntax cannot be used when the same variable is tested by another VAR, ARRAY or STR statement.

The NB_TIMES, NB_VALUE, and NB_RANDOM keywords require that the target platform supports floating point numbers.

INIT == allows the variable to be left un-initialized. You can thus control the values of variables that are dynamically created by the service under test. The initial value is displayed in the test report as a question mark (?).

An initialization expression can still be used (INIT == <expression>) to include of expected value expression when using the INIT pseudo-variable is used. See Expected_Value Expressions.

Expressions

The initialization expressions <exp> can be among any of the following values:

Additional Rules

Any integers contained in an expression must be written either in accordance with native lexical rules, or under the form:

Note   Because of the way hexadecimal values are handled, the value range should not exceed half of the maximum range when the initialization is expressed in hexadecimal.

The number of values inside an INIT IN parameter is limited to 100 elements in a single VAR statement.

The number of INIT IN parameters per TEST LOOP block is limited to 7.

The number of INIT IN parameters per TEST block is limited to 8.

In Component Testing for C, if variables are used in the expression, then the test evaluates the the INIT value with variable values from after the execution.

All Euclidian divisions performed by the Test Script Compiler round to the inferior integer. Therefore, writing -a/b returns a different result than -(a/b), as in the following examples:

 

Examples

VAR x, INIT = pi/4-1, ...

VAR y[4], INIT IN { 0, 1, 2, 3 }, ...

VAR y[5], INIT(y[4]) WITH { 10, 11, 12, 13 }, ...

VAR z.field, INIT FROM 0 TO 100 NB_RANDOM 3, ...

VAR p->value, INIT ==, ...

ARRAY y[0..100], INIT = sin(I), ...

ARRAY y, INIT = {50=>10,others=>0}, ...

STR z, INIT = {0, "", NIL}, ...

STR *p, INIT = {value=>4.9, valid=>1}, ...

 

In the following example, the C test Script Compiler generates code that tests x against a then b after the execution of the code under test:

VAR y,        init in (1,2),            ev = init
VAR a,        init(y) with ( 10, 20 ),  ev = 50
VAR b,        init(y) with ( 30, 40 ),  ev = 70
VAR x,        init(y) with (a, b),      ev = init
#a := 50;
#b := 70;

 

Related Topics

<expression> parameterExpected_Value Expressions<variable> parameter (C)VAR, ARRAY and STR