22.11.2012 Views

Schaum's Outline Series

Schaum's Outline Series

Schaum's Outline Series

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

154<br />

10.3.4.6 C1 Subsumes C0<br />

EXAMPLE 10.8—C1 Subsumes C0<br />

For the triangle problem, in Example 10.3 we selected good test cases until we<br />

achieved the C0 coverage. The test cases were (3,4,5—scalene), (3,5,3—<br />

isosceles), (0,1,0—bad inputs), and (4,4,4—equilateral). These tests also covered<br />

four out the five possible outputs. However, we can achieve C1 coverage with two<br />

test cases: (3,4,5—scalene) and (0,0,0—bad inputs). This test is probablynot as<br />

good as the first test set. However, it achieves C1 coverage and it also achieves<br />

C0 coverage.<br />

10.4 Data Flow Testing<br />

CHAPTER 10 Software Testing<br />

Data flow testing is testing based on the flow of data through a program.<br />

Data flows from where it is defined to where it is used. A definition of data,<br />

or def, is when a value is assigned to a variable. Two different kinds of use<br />

have been identified. The computation use, or c-use, is when the variable<br />

appears on the right-hand side of an assignment statement. Ac-use is said<br />

to occur on the assignment statement. The predicate use, or p-use, is when<br />

the variable is used in the condition of a decision statement. Ap-use is<br />

assigned to both branches out of the decision statement. A definition free<br />

path, or def-free, is a path from a definition of a variable to a use of that<br />

variable that does not include another definition of the variable.<br />

EXAMPLE 10.9—Control Flow Graph of Triangle Problem (Example 10.3)<br />

The control flow graph in Fig. 10-2 is annotated with the definitions and uses of the<br />

variables a,b, and c.<br />

p-use a,b,c<br />

p-use a,b,c<br />

p-use a,b,c<br />

p-use a,b,c<br />

abc<br />

e<br />

g<br />

i<br />

k<br />

def a,b,c type<br />

c-use type<br />

p-use a,b,c<br />

p-use a,b,c<br />

p-use a,b,c<br />

p-use a,b,c<br />

d<br />

f<br />

h<br />

j<br />

def type<br />

def type<br />

def type<br />

def type<br />

Fig 10-2. Control flow graph of triangle problem.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!