Testing arrays

Component Testing for Ada

With Component Testing for Ada, you can test arrays in quite the same way as you test variables. In the Ada Test Script Language, this is done with the ARRAY statement.

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

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

Testing an Array with Ada Expressions

To initialize and test an array, specify the same value for all the array elements. The following two examples illustrate this simple form.

ARRAY image, init = 0, ev = init

ARRAY histo[1..SIZE_HISTO-1], init = 0, ev = 0

You can use the same expressions for initial and expected values as those used for simple variables (literal values, constants, variables, functions, and Ada operators).


HEADER histo, 1, 1

#with histo; use histo;



  # x1, x2, y1, y2 : integer;

  # histo : T_HISTO;

  TEST 1

    FAMILY nominal


      VAR x1, init = 0, ev = init

      VAR x2, init = SIZE_IMAGE﷓1, ev = init

      VAR y1, init = 0, ev = init

      VAR y2, init = SIZE_IMAGE﷓1, ev = init

      ARRAY image(1..200,1..200), init = 0, ev = init

      VAR histo(1), init = 0, ev = SIZE_IMAGE*SIZE_IMAGE

      ARRAY histo(1..SIZE_HISTO), init = 0, ev = 0

      #compute_histo(x1, y1, x2, y2, histo);




Related Topics

Testing variablesTesting an array with pseudo-variablesTesting character arraysTesting large arraysTesting arrays with listsTesting arrays with other arrays