Ch-06 Coding and Testing
Ch-06 Coding and Testing
3) Program Portability
• Make your program so that it can be used on
different machines with little modification.
• Input (array, key) Expected output (S) Test case (s) used
• {10}, 2 -1 2, 7
• {1, 2, 3}, 3 2 (if 1st index = 0) 6
• {2}, 2 0 1, 6
• {} -1 3
• {11, 3}, 11 0 4
• {11, 12}, 13 -1 5
4,5,6
13,14 7,8
11,12 9
10
1. int abs(x)
2. {
3. if ( x >= 0)
4. return x;
5. }
Here, the statement coverage criterion will be satisfied by test
cases with the set {0, 1, 2, 3, …} but does not reflect the error
(leaves the error undetected) if x < 0.
Def={z}
4
C-use=Φ
Def=c-use=Φ
5
pow
pow
Def={z,pow} 7 Def=c-use=Φ
C-use={x,z,pow} 6 y y
Def={z} 8 Def=Φ
9
C-use={z} C-use={z}
Ch - 06: Coding and Testing 34
…
• dpu:- set of branches where a variable is p-
used.
• dcu:- set of nodes where a variable is c-used.