![]() |
![]() |
![]() |
![]() |
![]() |
The keyword denotes a structured type: a collection of fields, each one identified by an identifier. Only one of the specified fields will ever be present in an actual union value.
Related keywords:
type union (identifier | address) { type_reference element_identifier ... }; |
The type union keywords introduce the type definition.
identifier is the name used to refer to the union. Must begin with a letter, may contain letters, numbers and underscore characters.
address is a user defined type to allow addressing specific entities inside the System Under Test.
type_reference refers to an already defined (structured or simple) type.
element_identifier identifies the elements of the union. The identifiers must be unique within the same union
... indicates that type_reference element_identifier pairs may be repeated. They are separated by comma.
Example 1: type definition
type union MyUnionType {
integer Number1,
integer Number2,
charstring String
}
The union called MyUnionType consists of three elements. The first two are both of type integer and have the identifier Number1 and Number2, respectively. The third element is of type character string and has the identifier String.
Example 2: dot notation (For the type definition see example 1)
var MyUnionType v_myUnion;
v_myUnion.Number1 := 12;
The variable v_myUnion of type MyUnionType is defined. The value 12 is assigned to the field Number1 making the given field to be the chosen one
Example 3: assignment notation (For the type and variable definition see example 1 & 2)
v_myUnion := {Number2 := 112};
The value 112 is assigned to the field Number2.
Example 4: the predefined function ischosen
var boolean v_whichone := ischosen(v_myUnion.Number1);
The variable v_whichone will have the value true if the field Number1 is chosen (as in example 2).
BNF definition of union