Testing expressions

Component Testing for C

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.


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

 TEST 12

 FAMILY nominal


 VAR a, init in {1,2,3}, ev = init

 VAR b, init(a) with {3,2,1}, ev = init

 VAR add(a,b), ev = 4




In this example, you no longer need the variable c.

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

Related Topics

Testing variablesTesting intervalsTesting tolerancesInitializing without testingDeclaring parametersTesting arraysTesting structured variables