Data flow testing example

De Software testing
Ir para: navegação, pesquisa

Source

/* 01 */ {
/* 01 */    char  achar;
/* 01 */    int   length, valid_id;
/* 01 */    length = 0;
/* 01 */    printf ("Identificador: ");
/* 01 */    achar = fgetc (stdin);
/* 01 */    valid_id = valid_s(achar);
/* 01 */    if (valid_id)
/* 02 */       length = 1;
/* 03 */    achar = fgetc (stdin);
/* 04 */    while (achar != '\n')
/* 05 */    {
/* 05 */       if (!(valid_f(achar)))
/* 06 */          valid_id = 0;
/* 07 */       length++;
/* 07 */       achar = fgetc (stdin);
/* 07 */    }
/* 08 */    if (valid_id && (length >= 1) && (length < 6) )
/* 09 */       printf ("Valido\n");
/* 10 */    else
/* 10 */       printf ("Invalido\n");
/* 11 */ }


Control flow graph

Identifier - C - GFC.svg


Definition graph

Identifier - C - GFC-GD.svg

Definition use graph

Identifier - C - DUG.svg


Test requirements

  • All-uses:
    • (length, 1, 2)
    • (achar , 1, 3)
    • (valid id, 1, (1, 3))
    • ...
  • All-pontential-uses
    • (length, 1, 2)
    • (achar , 1, 3)
    • (valid id, 1, (1, 3))
    • (length, 2, (8, 10))
    • (achar , 3, (8, 10))