Testing character arrays

Component Testing for C

Character arrays are a special case. Variables of this type are processed as character strings delimited by quotes.

You therefore need to initialize and test character arrays using character strings, as the following list example illustrates.

If you want to test character arrays like other arrays, you must use a format modification declaration (FORMAT instruction) to change them to arrays of integers.

Example

The following list example illustrates this type of modification:

TEST 2

  FAMILY nominal

  FORMAT str[] = int

  ELEMENT

    VAR l, pointer, init = NIL, ev = NONIL

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

    VAR str[0..5], init == , ev = {'m','y','f','o','o',0}

    #l = strcpy(str,s);

  END ELEMENT

END TEST 2

Related Topics

Testing arraysTesting arrays with pseudo-variablesTesting large arraysTesting arrays with listsTesting arrays with other arraysTesting an array of union elements