![]() |
![]() |
![]() |
![]() |
![]() |
Matching Received Constraint Values
In this section we shall take a closer look at the RECEIVE statement and how it is used to check the received values against the specified constraint values.
Specific Values
In most cases a constraint value will be a specific value. Note that this is not necessarily always a literal value. In TTCN a specific value is an expression which evaluates to a value compatible with the corresponding element type in the relevant ASP, PDU or CM definition. The TTCN syntax allows the operands of these expressions to be:
- literal values;
- constant identifiers;
- formal parameter identifiers;
- predefined and user defined operations;
- expressions, i.e. the syntax is recursive.
When a specific value is used as a constraint value a successful match means that the received value is exactly equal to the value to which the constraint expression evaluates. Specific values can of course, be used to specify constraint values of all types.
Omitting Values
In many cases it may be necessary to omit ASP parameters or PDU fields. In the tabular format all parameters or fields are considered to be optional and may be omitted. This is denoted by writing a dash (-) instead of value.
Case study 16: Omitting values.
In the ASN.1 only parameters or fields that are defined as being OPTIONAL or DEFAULT may be omitted. This can be indicated either by explicitly using the OMIT keyword, or by not including the parameter or field in the constraint.
Replacing Values
In ASN.1 constraints may be constructed from previously defined constraints by using the REPLACE keyword.
Matching Mechanisms
In many instances it is not possible, or even desirable, to specify that the field of a received PDU shall have a specific value. It may be more appropriate to say that a match occurs if the received value falls within certain boundaries or fulfils certain conditions.
TTCN supports a number of matching mechanisms: matching symbols, matching operations and attributes that allow the test specifier to express these matching conditions instead of specific values.These mechanisms include:
- lists of values
- complemented lists of values
- ranges of INTEGER values
- any value
- any value or omit value
- wildcards
- if present attribute
- length attributes
Matching Value Lists
A constraint value may be a list of one or more specific values (remember that specific values include expressions etc. so the elements in the list may be quite complex). A match occurs only if the received value is equal to any one of the values in the constraint value list, otherwise the match fails.
Complementing Value Lists
If a value list is preceded by the keyword COMPLEMENT then a match occurs only if the received value is not equal to any of the values in the constraint value list, otherwise the match fails. Complement can be used on values of any type.
- COMPLEMENT (`00'B, `11'B) will match if the received value is either `01'B or `10'B. Note that this is the same as the list: (NOT `00'B, NOT `11B').
Matching Ranges
Ranges may only be used to match values of INTEGER compatible types. The keywords INFINITY and -INFINITY may be used to specify ranges that may be unbounded in the positive and/or negative direction.
A range matches if the received value is within the range, including the upper and lower boundary.
Matching Any Value
In many cases the test suite specifier is prepared to accept any single value for a particular field, provided that the actual value is compatible with the corresponding element type.
The matching symbol AnyValue is denoted by "?". A match will occur if the received value is any value that is compatible with the expected type.
- suppose that we have declared a BITSTRING of length exactly 2; then AnyValue would match one of `00'B, `01'B, `10'B and `11'B but nothing else;
- suppose that we have declared a value of SEQUENCE OF INTEGER type; then AnyValue will match any SEQUENCE OF INTEGER, except an empty sequence.
Matching Any Value, or Omitting It Altogether
The AnyOrOmit matching symbol, denoted by "*", is similar to AnyValue, except that the value may be omitted altogether. If there is a value present then a match will occur if the received value is any value that is compatible with the expected type; otherwise the value must be omitted. This is only allowed with optional fields.
- suppose that we have declared a BITSTRING of length exactly 2; then AnyOrOmit would match one of `00'B, `01'B, `10'B and `11'B, or a value could be missing altogether;
- suppose that we have declared a value of SEQUENCE OF INTEGER type; then AnyOrOmit will match any SEQUENCE OF INTEGER, including an empty sequence.
Wildcards Within Values
There are two wildcards that may be used within values:
The AnyOne symbol, denoted by "?", is used to replace single elements within all the string types, and within SEQUENCE, SEQUENCE OF, SET and SET OF types. However, the element may not be omitted.
- `?0'B would match either `00'B or `10'B;
- "ab?z" will match any character string of length 4 that begins with ab and ends with z;
- A value of SEQUENCE OF INTEGER such as: {1, 2, ?, 3} means that the third element matches any INTEGER value.
Note that the denotation is the same as for AnyValue, but the semantics of the symbol are not the same.
The AnyOrNone symbol, denoted by "*", is used to replace single elements or a consecutive number of elements within all the string types, and within SEQUENCE, SEQUENCE OF, SET and SET OF types. Also, the element may be omitted.
- `*0'B would match any BITSTRING value that ended with a zero bit;
- "ab*z" will match any character string that begins with ab and ends with z, including the string "abz";
- A value of SEQUENCE OF INTEGER such as: {1, 2, *, 3} means that any SEQUENCE OF INTEGER that begins with 1, 2 and ends with 3, including {1,2,3}, will match.
The If_Present Attribute
The If_Present attribute is intended for use with OPTIONAL fields. The test suite specifier may not know beforehand whether the IUT will be including an OPTIONAL value or not in a particular PDU - the protocol allows either or. The test then has to specify that if the optional value is present it should be checked.
- 3 IF_PRESENT means that either the INTEGER value of 3 will be accepted for that particular field or no value shall be present.
Note that in the tabular format all fields are considered to be OPTIONAL. The match will occur if the received value is any value that is allowed by the specified expected type, i.e. they need not be explicitly declared as such. In ASN.1 this is not the same case; any fields that are OPTIONAL have to be declared as such.
Length Restrictions
Length restrictions apply to the following types:
Essentially these are the same length restrictions that may be placed on the type definitions. The restriction may state the precise length of the string:
http://www.ibm.com/rational |
![]() |
![]() |
![]() |
![]() |