Testing arrays of union elements

Component Testing for C

When testing an array of unions, detail your tests for each member of the array, using VAR lines in the ELEMENT block.

Example

Considering the following variables:

#typedef struct {

# int test1;

# int test2;

# int test3;

# int test4;

# int test5;

# int test6;

# } Test;

#typedef struct {

# int champ1;

# int champ2;

# int champ3;

# } Champ;

#typedef struct {

# int toto1;

# int toto2;

# } Toto;

#typedef union {

# Test A;

# Champ B;

# Toto C;

# } T_union;

#extern T_union Tableau[4];

The test must be written element per element:

TEST 1

FAMILY nominal

ELEMENT

VAR Tableau[0], init = {A => { test1 => 0, test2 => 0, test3 => 0, test4 => 0,

& test5 => 0, test6 => 0} }, ev = init

VAR Tableau[1], init = {B => { champ1 => 0, champ2 => 0, champ3 => 0} }, ev = init

VAR Tableau[2], init = {B => { champ1 => 0, champ2 => 0, champ3 => 0}} , ev = init

VAR Tableau[3], init = {B => { champ1 => 0, champ2 => 0, champ3 => 0}} , ev = init

#ret_fct;

END ELEMENT

END TEST -- TEST 1

Related Topics

Testing arrays | Testing arrays with pseudo-variables | Testing large arrays | Testing arrays with lists | Testing character arrays | Testing arrays with other arrays