11.2 List Class | 537
The methodslength,insert, anddeletemust be tested together. That is, we insert
several items and check the length; we delete several items and check the length. How do
we know that theinsertanddeleteoperations work correctly? We must write an auxil-
iary methodprintListthat iterates through the list usinglengthandgetNextItemto print
out the values. We callprintListto check the status of the list after a series of insertions
and deletions. To test theisFulloperation, we must test it when the list is full and when
it is not. We must also callinsertwhen the list is full to confirm that the list remains
unchanged.
Do we need to test any special cases for deleteand isThere? We look first at the end
cases. What are the end cases in a list? The item is in the first position in the list, the item is
in the last position in the list, and the item is the only one in the list. We must verify that delete
can correctly delete items in these positions. We must check that isTherecan find items in
these same positions and correctly determine that values are not in the list.
These observations are summarized in the following test plan. The tests are shown in
the order in which they should be performed.
Operation to Be Tested and
Description of Action Input Values Expected Output Observed Output
Constructor (4)
print length
insert
insertfour items and print
insertitem and print
isThere
isTheresusy and print whether found
isThere maryand print whether found
isThere annand print whether found
isThere bettyand print whether found
isFull
invoke (list is full)
delete annand invoke
delete
print
delete bettyand print
delete maryand print
delete johnand print
isEmpty
mary,john,ann,betty
sarah
0
mary,john,ann,betty
mary,john,ann,betty
item is not found
item is found
item is found
item is found
list is full
list is not full
mary,john,betty
mary,john
john
(empty)
yes