Testing Records

Component Testing for Ada

To test all the fields of a structured variable or record, use a single STR instruction to define the initializations and expected values of the structure.

The STR 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 STR statement, followed by the declaration keywords:

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

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

Example

The following example demonstrates typical use of the STR statement:

--procedure push(l: in out list; s:string);

TEST 2

  FAMILY nominal

  ELEMENT

    VAR l, init = NIL, ev = NONIL

    STR l.all, init == , ev = ("myfoo",NIL,NIL)

    VAR s, init = "myfoo", ev = init

    #push(l,s);

  END ELEMENT

END TEST

 

Related Topics

Testing RecordsTesting a Record with Ada ExpressionsTesting a Record with Another RecordTesting Records with DiscriminantsTesting Tagged RecordsNo Test