Testing expressions

Component Testing for Ada

To test the return value of an expression, rather than declaring a local variable to memorize the value under test, you can directly test the return value with the VAR instruction.

In some cases, you must leave out the initialization part of the instruction.

Example

The following example places the call of the add function in a VAR statement:

TEST 12

FAMILY nominal

ELEMENT

VAR a, init = 1, ev = init

VAR b, init = 3, ev = init

VAR add(a,b), ev = 4

END ELEMENT

FIN TEST

In this example, you no longer need the variable c . The resulting test report an Unknown status indicating that it has not been tested.

All syntax examples of expected values are still applicable, even in this particular case.

Related Topics

Testing variables | Testing intervals | Testing tolerances | Initializing without testing