Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Control flow testing. Problem Consider the following code 1 int binsearch ( int X , int V [ ] , int n ) 2 {
Control flow testing.
Problem
Consider the following code
int binsearch
int X
int V
int n
int low
high
mid
i ;
low
;
high
n
;
for
i
; i
high ; i
if
V
i
V
i
return
;
while
low
high
mid
low
high
;
if
X
V
mid
high
mid
;
else
if
X
V
mid
low
mid
;
else
return mid ;
return
;
This code takes as input a sorted array V of size n
and an integer X
if X exists in the array it will
return the index of X
else it will return
Draw a CFG for binsearch
From the CFG
identify a set of entry
exit paths to satisfy the complete statement coverage
criterion.
Identify additional paths, if necessary, to satisfy the complete branch coverage criterion.
For each path identified above, derive their path predicate expressions.
Solve the path predicate expressions to generate test input and compute the corresponding
expected outcomes.
Are all the selected paths feasible? If not, select and show that a path is infeasible, if it exists.
a n you introduce two faults in the routine so that these go undetected by your test cases
designed for complete branch coverage?
Suggest a general way to detect the kinds of faults introduced in the previous step. an example of cfg and the different paths statemen sc and branchSCPath FF
SCPath TTTTFT
PATH SELECTION CRITERIA
Figure Dashed arrows represent the branches not covered by statement covering in Table
TABLE Paths for Branch Coverage of CFG of Figure
BCPath FF
BCPath TTTTFT
BCPath
BCPath TTFFF
BCPath bc
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started