Graphs Data Flow
Graphs Data Flow
Meenakshi D’Souza
Defs:
def (1) = {x},
z=x*2
def (5) = def (6) =
2 5
{z}.
1 4 7 Uses:
3 6
x=42 use(5) = {x},
z=x−5 use(6) = {x}.
Example: Pattern Matching
/**
* Find index of pattern in subject string
* @return index (zero-based) of 1st occurrence of pattern in subject; -1
if not found
* @throws NullPointerException if subject or pattern is null
*/
NOTFOUND=−1;iSub=0;rtnIndex=NOTFOUND;
2 isPat=false;subjectLen=subject.length;
patternLen=pattern.length
3
iSub+patternLen−1<subjectLen && isPat==false
4
subject[iSub]==pattern[0]
5 rtnIndex=iSub;
isPat=true;iPat=1
6
11
iPat<patternLen
return(rtnIndex)
7
subject[iSub+iPat]==
pattern[iPat]
break iPat++
iSub++ 10 8 9
rtnIndex=NOTFOUND;
isPat=false;
Pattern Matching: Defs and uses
1 def(1) = {subject,pattern}
def(2)={NOTFOUND,iSub,rtnIndex,isPat,subjectLen,patternLen}
2
use(2)={subject,pattern}
3
use(3,11)=use(3,4)={iSub,patternLen,subjectLen,isPat}
4
use(4,10)=use(4,5)={subject,iSub,pattern}
5 def(5)={rtnIndex,isPat,iPat}
use(5)={iSub}
6
11
use(6,10)=use(6,7)={iPat,patternLen}
use(11)={rtnIndex}
7
use(7,8)=use(7,9)={subject,pattern,iSub,iPat}
def(10)= 10 8 9
use(10)={iSub} def(9)=use(9)={iPat}
def(8)={rtnIndex,isPat}
use(8)={NOTFOUND}
Pattern Matching: Defs and uses
We will look at coverage criteria for data flow testing in the next
module.
Credits
Part of the material used in these slides are derived from the
presentations of the book Introduction to Software Testing, by
Paul Ammann and Jeff Offutt.