CIS 221 Closed Lab 5 Warm-Up Exercise


For this closed lab, you will be debugging two defective implementations of the Swap_Substring operation, called Buggy_1.cpp and Buggy_2.cpp. The source files will not be made available until closed lab. In the meantime, the tester asked if the instructor would pass along test cases revealing defects in Buggy_1.cpp and Buggy_2.cpp.

You should study the test cases and convince yourself that they reveal defects. Think about how you might approach the debugging task. Feel free to get organized with a partner, and there is nothing to turn in for this homework.


A Revealing Test Case for Buggy_1.cpp

  test values
t1 = ""
pos = 0
len = 0
t2 = "So is this one"
 
Swap_Substring (t1,pos,len,t2)  
  expected output
t1 = "So is this one"
pos = 0
len = 0
t2 = ""
observed output
========================

Violated assertion at:

File: ../../RESOLVE_-
Foundation/Text/Text.cpp
Line #: 467
Operation: Add

Violated assertion is:
0 <= pos
--------------------------



A Revealing Test Case for Buggy_2.cpp

  test values
t1 = ""
pos = 0
len = 0
t2 = "So is this one"
 
Swap_Substring (t1,pos,len,t2)  
  expected output
t1 = "So is this one"
pos = 0
len = 0
t2 = ""
observed output
t1 = ""
pos = 0
len = 0
t2 = ""