Omitting a Field’s Initial and Test Values

Component Testing for C

You can only initialize and test structured variables with the following forms:

  • INIT =

  • INIT ==

  • EV =

  • EV ==

If a field of a structured variable needs to be initialized or tested in a different way, you can omit its initial and expected values from the global test of the structured variable, and run a separate test on this field.

The following example illustrates this:

TEST 4

FAMILY nominal

ELEMENT

VAR l, init = NIL, ev = NONIL

VAR *l, init == , ev = {,NIL,NIL}

VAR s, init in {"foo","bar"}, ev = init

VAR l->str, init ==, ev(s) in {"foo","bar"}

#l = push(l,s);

END ELEMENT

END TEST

Using field names, write this as follows:

VAR *l, init ==, ev = {next=>NIL,prev=>NIL}

Related Topics

Testing Variables | Testing a Structured Variable | Testing a Structured Variable with C Expressions | Testing a Structured Variable with Another Structured Variable | C Unions