so-un-bot/Ingegneria del Software/0222_35/quest.txt

52 lines
No EOL
969 B
Text
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Il branch coverage di un insieme di test cases è la percentuale di branch del programma che sono attraversati da almeno un test case.
Si consideri il seguente programma C:
-----------
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#define N 1 /* number of test cases */
int f(int x)  { int y = 0;
  LOOP: if (abs(x) - y <= 2)
{return ;}
else {y = y + 1; goto LOOP;}
} /* f() */
int main() {  int i, y; int x[N];
// define test cases
x[0] = 3; 
// testing
for (i = 0; i < N; i++) {
y = f(x[i]); // function under testing
assert(y == (abs(x[i]) <= 2) ? 0 : (abs(x[i]) - 2)); // oracle
}
printf("All %d test cases passed\n", N);
return (0); 
}
-----------
Il programma main() sopra realizza il nostro testing per la funzione f(). I test cases sono i valori in x1[i] ed x2[i].
Quale delle seguenti è la branch coverage conseguita?