SE 13th
SE 13th
Testing
Tailored
from Book Chapter
(Introduction to Software Testing)
BY
Paul Ammann & Jeff Offutt
Graphs – Circles and Arrows
Double-diamond graph
Path Expression = abdfhj + abdgij + acegij + acefhj
a b e g
0 1 2 4 5
c d
f
3
4
Let’s Look at the Math
• Path Products
– Commutative : Path product is not ( AB != BA )
– Associative : Path product is ( A(BC) = (AB)C = ABC )
• Path Summation
– Commutative : Summation is ( A + B = B + A )
– Associative : ( (A+B)+C = A+(B+C) = A + B + C )
b e
a d f h i
0 1 2 3 4 5 6
c
g
9
Step 2 : Parallel Edges
• Combine all parallel edges
• Add the edge labels
• Precisely: For any pair of edges with the same source and target
nodes, combine the edges and add their path expressions
• Example : Combine edges b and c
b e
a d f hi
0 1 2 3 4 6
c
g
e
a b+c d f hi
0 1 2 3 4 6
g
10
Step 3 : Self-Loops
• Combine all self-loops (loops from a node to itself)
• Add a new “dummy” node
• An incoming edge with exponent
• Merge the three resulting sequential nodes with multiplication
• Precisely: For any node n1 with a self-loop X, incoming edge A
and outgoing edge B, remove X, add a new node n1’ and edge
with label X*, then combine into one edge AX*B
e
a b+c d f hi
0 1 2 3 4 6
a b+c d e* f hi
0 1 2 3 de*f 3’ 4 6
2 5 2 5
BD
a b+c hi
0 1 2 de*f 4 6
a b +bde*f
c + cde*f hi
0 1 2 de*f 4 6
g
gde*f
a bde*f + cde*f hi
0 1 4 6
gde*f
abde*f + acde*f hi
0 4 6
gde*f
• Specifically:
– Path expression : A+B becomes weight (A) + weight (B)
– Path product : AB becomes max (weight (A), weight (B))
– Loop : An is either 1 or weight (A)
– Judgment of tester – if all paths in the loop can be taken in one test, use 1,
else use weight(A)
= 1 * 2 * (1 * (2))2 * 1
= 1 * 2 * (1 * 2) * 1
= max (1, 2, 1, 2, 1)
=2
Introduction to Software Testing (Ch 2),
© Ammann & Offutt 21
www.introsoftwaretesting.com
4. Complementary Operations Analysis
• A method for finding potential anomalies
– Def-use anomalies (use before a def)
– FileADT example (closing before writing)
• A pair of operations are complementary if their behaviors negate
each other, or one must be done before the other
– push & pop
– enqueue & dequeue
– getting memory & disposing of memory
– open & close
• Edge weights are replaced with one of three labels
– C – Creator operation
– D – Destructor operation
– 1 – Neither
* C D 1 + C D 1
C C2 1 C C C C+D C+1
D DC D2 D D D+C D D+1
1 C D 1 1 C+1 D+1 1
C C
C C 1 1
0 1 2 3 4 5 6
1 D
(n)
D
C*D = 1, canceling
out
• Ask questions:
– Can we have more destructors than creators?
• CCCC
• CCD (DC)n, forall n
26