VAR, ARRAY and STR <expected> Parameter

C Test Script Language

Purpose

In this documentation, the Component Testing <expected value> parameters for C 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 ==

where:

Description

The <expected value> 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:

  1. 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:

  1. 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:

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:

{<value>,,<value>}

Additional Rules

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.

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:

Not a number and infinite float values

Component testing can handle not a number and infinite float values as MIN and MAX parameters. Such values must be assigned through a variable. The test produces a verdict depending on the nature of the values.

The following table describes the verdict to be expected for each combination of MIN and MAX values. For example, if the MIN is a real float value and the MAX is +infinite, then the test will fail if the actual return value is not a number or +infinite and will pass if the value is +infinite or greater that MIN.

 

Expected values

Actual return values

MIN

MAX

Not a number

-infinite

float value

+infinite

Not a number

Not a number

Pass

Fail

Fail

Fail

Not a number

-infinite

Pass

Pass

Fail

Fail

Not a number

float value

Pass

Fail

x==MAX

Fail

Not a number

+infinite

Pass

Fail

Fail

Pass

-infinite

Not a number

Pass

Pass

Fail

Fail

-infinite

-infinite

Fail

Pass

Fail

Fail

-infinite

float value

Fail

Pass

x<=MAX

Fail

-infinite

+infinite

Fail

Pass

Pass

Pass

float value

Not a number

Pass

Fail

x==MIN

Fail

float value

-infinite

Fail

Fail

Fail

Fail

float value

float value

Fail

Fail

MIN<=x<=MAX

Fail

float value

+infinite

Fail

Fail

x>=MIN

Pass

+infinite

Not a number

Pass

Fail

Fail

Pass

+infinite

-infinite

Fail

Fail

Fail

Fail

+infinite

float value

Fail

Fail

Fail

Fail

+infinite

+infinite

Fail

Fail

Fail

Pass

 

 

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

Initialization ExpressionsVAR, ARRAY and STRC Variables