VAR, ARRAY and STR <expected> Parameter

Purpose

In conjunction with the VAR, ARRAY and STR keywords, the <expected value> parameters for Ada specify the expected value of a variable.

Syntax

EV = <exp>

EV = <exp> , DELTA = <delta>

MIN = <exp>, MAX = <exp>

EV IN ( <exp>, <exp>, ... )

EV ( <variable> ) IN ( <exp>, <exp>, ... )

EV = INIT

EV ==

where:

• <exp> can be any of the expressions of the Initialization Parameters, plus the following expressions:

• <delta> is the acceptable tolerance of the expected value and can be expressed:

• <variable> is an Ada variable

Description

The EV expressions are used to specify a test criteria by comparison with the value of a variable. The test is considered Passed when the actual value matches the <expected value> expression.

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

An acceptable tolerance <delta> can be expressed:

• As an absolute value, by a numerical expression in the form described above

• As a percentage of the expected value. Tolerance is then written in the form <exp>%.

Expected values can be expressed in the following ways:

• EV = <exp> specifies the expected value of the variable when it is known in advance. The value of variable is considered correct if it is equal to <exp>.

EV = <exp>, DELTA = <tolerance> allows a tolerance for the expected value. The value of variable is considered correct if it lies between <exp> - <tolerance> and <exp> + <tolerance>.

MIN = <exp> and MAX = <exp> specify an interval delimited by an upper and lower limit. The value of the variable is considered correct if it lies between the two expressions. Characters and character strings are treated in dictionary order.

EV IN ( <exp>, <exp>, ... ) specifies the values expected successively, in accordance with the initial values, for a variable that is declared in INIT IN. It is therefore essential that the two lists have an identical number of values.

EV ( <variable> ) IN is identical to EV IN, but the expected values are a function of another variable that has previously been declared in INIT IN. As for EV IN, the two lists must have an identical number of values.

EV == allows the value of <variable> not to be checked at the end of the test. Instead, this value is read and displayed. The value of <variable> is always considered correct.

Expressions

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

• Numeric (integer or floating-point), character, or character string literal values. Strings can be delimited by single or double quotes

• Native constants, which can be numeric, characters, or character strings

• Variables belonging to the test program or the module to be tested

• The keyword NIL to designate a null pointer

• The keyword NONIL, which tests if a pointer is non-null

• Pseudo-variables I, I1, I2 ..., J, J1, J2 ..., where In is the current index of the nth dimension of the parameter and Jm the current number of the subtest generated by the test scenario's mth INIT IN, INIT FROM or LOOP; the I and I1 variables are therefore equivalent as are J and J1; the subtest numbers begin at 1 and are incremented by 1 at each iteration

• An Ada expression with one or more of the above elements combined using any operators and casting, with all required levels of parentheses, the + operator being allowed to concatenate character string variables

• For arrays and structures, any of the above-mentioned expressions between brackets ('[]') for Ada, including when appropriate:

• For an array element, part of an array or a structure field, its index, interval or name followed by '=>' and by the value of the array element, common to all elements of the array portion or structure field

• For structures you can test some fields only, by using the following syntax:

• [<fieldname> => <value>, <fieldname> => <value>]

• The keyword others (written in lower case) followed by '=>' and the default value of any array elements or structure fields not yet mentioned

• The pseudo-variable INIT, which copies the initialization expression. You cannot use the pseudo-variable INIT inside an array or structure. The keyword INIT applies to the entire expression.

EV with DELTA is only allowed for numeric variables. The STR statement does not support DELTA.

MIN = <exp> and MAX = <exp> are only allowed for alphanumeric variables that use lexicographical order for characters and character strings.

MIN = <exp> and MAX = <exp> are not allowed for pointers.

Only EV = and EV == are allowed for structured variables.

In some cases, in order to avoid generated code compilation warnings, the word CAST must be inserted before the NIL or NONIL keywords.

Example

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

VAR y[4], ..., EV IN (0, 1, 2, 3 )

VAR y[5], ..., EV(y[4]) IN ) (10, 11, 12, 13 )

VAR z.field, ..., MIN = 0, MAX = 100

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

ARRAY y[0..100], ..., EV = cos(I)

ARRAY y, ..., EV = (50=>10,others=>0)

STR z, ..., EV = (0, "", NIL)

STR *p, ..., EV = (value=>4.9, valid=>1)

Related Topics