
Test Generation
Program P5.3
1 main(){
2 int x,y,z; ←Replaced by
int x, y; float z;
3 z=0;
4 input (x, y);
5 if(x<y)
6 {z-x+y; output(z);}
7 output ((float) (x-y));
8 end
9}
t
Start
1
2
3
f
End
main
3, 4, 5
6
7
8, 9
1, 2
use(1)={ x, y }
use(2)={ x, y, z }
use(3)={ x, y }
Lines
Fig. 5.8 Program and its CFG for Example 5.11.
z is changed from int to float. We refer to the original and the
modified programs as P and P
, respectively. It is easy to see that
gdeclChange =∅and declChange
mai n
= {z}. Suppose the following
test set is used for testing P:
T =
⎧
⎨
⎩
t
1
:< x = 1, y = 3 >
t
2
:< x = 2, y = 1 >
t
3
:< x = 3, y = 4 >
⎫
⎬
⎭
We can easily trace CFG(P) for each test case to find the test vectors ...