VAR, ARRAY and STR

C Test Script Language

Purpose

The VAR, ARRAY, and STR instructions declare the test of a simple variable, a variable array or a variable structure.

Syntax

VAR <variable>, [<format>], <initialization>, <expected_value>

ARRAY <variable>, [<format>], <initialization>, <expected_value>

STR <variable>, [<format>], <initialization>, <expected_value>

where:

Description

Use the VAR, ARRAY, and STR instructions to declare a variable test. During test execution, if the value of the variable is out of the bounds specified in the <expected_value> expression, the test is Failed.

The usage of VAR, ARRAY or STR does not change the behavior of the test, but each keyword specify how the result is displayed in the test report. Use:

If you use a VAR statement to test an array or structure, the report lists each element of the array or structure.

If you use a STR in an ENVIRONMENT block, then all elements of the structure are shown in the report, regardless of whether the test passes or fails. If the STR is in an ELEMENT block, then only the failed elements of the structure are displayed.

The VAR, ARRAY, and STR instructions must be located in an ELEMENT or an ENVIRONMENT block.

Note   Expressions must not use '--' or '++' operators, as these may be interpreted as comments in some environments.

The optional <format> parameter allows you to modify the type of the tested element. This parameter uses the same syntax as a the FORMAT statement. See FORMAT for more information.

In addition the following formats are available in a VAR, ARRAY, or STR statement only:

Example

#char *ar;

#char *ar1;

#char ar2[50];

#unsigned char t;

VAR t, #h, init=200, ev =init -- display as hexadecimal

VAR ar1,string_ptr, init ="defg", ev =INIT   -- init as a pointer and test as a string

VAR ar2,string, init ="defgh", ev =INIT      -- init and test as a string

VAR ar,pointer#b, init =0x12345678, ev =NONIL -- init and test as a pointer and display in binary

 

Related Topics

Initialization Expressions for C | Expected Value Expression for C | C VariablesFORMAT