so-un-bot/Ingegneria del Software/0222_33/quest.txt
2022-12-30 14:35:46 +01:00

45 lines
No EOL
1 KiB
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 partition coverage di un insieme di test cases è la percentuale di elementi della partition inclusi nei test cases. La partition è una partizione finita dell'insieme di input della funzione che si sta testando.
Si consideri il seguente programma C:
-----------
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#define N 5 /* number of test cases */
int f1(int x)  { return (2*x); }
int main() {  int i, y; int x[N];
 // define test cases
x[0] = 0; x[1] = 1; x[2] = -1; x[3] = 10; x[4] = -10;
// testing
for (i = 0; i < N; i++) {
y = f1(x[i]); // function under testing
assert(y == 2*x[i]); // oracle
 }
printf("All %d test cases passed\n", N);
return (0); 
}
Si vuole testare la funzione f1(). A tal fine l'insieme degli interi viene partizionato come segue: 
{(-inf, -21], [-20, -1], {0}, [1, 20], [21, +inf)}
Il programma main() sopra realizza il nostro testing per la funzione f1(). I test cases sono i valori in x[i].
Quale delle seguenti è la partition coverage conseguita?