22.11.2012 Views

Schaum's Outline Series

Schaum's Outline Series

Schaum's Outline Series

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

202<br />

Since a regular expression can be mapped to a finite state machine, these two<br />

approaches are equivalent. Although the finite state machine used to describe the<br />

behavior of a software system may not be minimal, having additional states will<br />

increase the effectiveness of the test set.<br />

EXAMPLE 13.2<br />

Identifythe function pair testing coverage for the linked list of rectangles program<br />

of Example 13.1. Consider the calling structure of the functions.<br />

class point<br />

point()<br />

getx()<br />

gety()<br />

class rectangle<br />

rectangle()<br />

point()point()point()point()<br />

length()<br />

getx()getx()gety()gety()<br />

area()<br />

length()length()<br />

class linklistnode<br />

linklistnode()<br />

getNext()<br />

getRectangle()<br />

setnext()<br />

class rectanglelist<br />

rectanglelist()<br />

addRectangle()<br />

rectangle()linklistnode()setnext()<br />

totalArea()<br />

(getRectangle()area()getNext())*<br />

CHAPTER 13 Object-Oriented Testing<br />

Most of the regular expressions for the individual functions have a fixed list of<br />

method calls. Onlythe totalArea function is zero-or-more repetition from the<br />

while loop.<br />

Putting all of these together into one regular expression and considering that the<br />

rectanglelist has to be created first and then addRectangle or totalArea<br />

could be done gives the following regular expression:<br />

rectanglelist ((addRectangle rectangle point point point point<br />

linklistnode setnext) | (totalArea (getRectangle area length getx getx<br />

gety gety length getx getx gety gety getNext)*)<br />

The function pair testing can be achieved bythe following test sets:<br />

1. Creating one rectangle, and then calculating the area<br />

2. Creating two or more rectangles, and then calculating the area<br />

3. Not creating anyrectangles, and then calculating the area<br />

4. Creating rectangles after calculating the area

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

Saved successfully!

Ooh no, something went wrong!