Testing variables

Component Testing for C

One of the main features of Component Testing for C is its ability to compare initial values, expected values and actual values of variables during test execution. In the C Test Script Language, this is done with the VAR statement.

The VAR statement specifies both the test start-up procedure and the post-execution test for simple variables. This instruction uses three parameters:

Declare variables under test with the VAR statement, followed by the declaration keywords:

It does not matter where the VAR instructions are located with respect to the test procedure call since the C code generator separates VAR instructions into two parts :

Many other forms are available that enable you to create more complex test scenarios.

Using C Expressions

Component Testing for C allows you to define initial and expected values with standard C expressions.

All literal values, variable types, functions and most operators available in the C language are accepted by Component Testing for C.


The following example demonstrates typical use of the VAR statement

HEADER add, 1, 1

#with add;



 # a, b, c : integer;


  FAMILY nominal


   VAR a, init = 1, ev = init

   VAR b, init = 3, ev = init

   VAR c, init = 0, ev = 4

   #c := add(a,b);





Related Topics

Testing intervalsTesting tolerancesInitializing without testingTesting expressionsDeclaring parametersTesting arraysTesting structured variables