It would be a good idea to find a partner
EARLY and work together on the warm-up exercise. If you do,
then turn in one warm-up solution with both names on it. And remember, read
the Closed Lab 4 Instructions
BEFORE you come to closed lab
(they are complicated).
The testing process will work as follows. We provide a test driver that allows you (the tester) to call the Swap_Substring operation. You tell the test driver what values the parameters should have; that is, the incoming or test values of t1, pos, len, and t2. You also tell the test driver what the expected outgoing values of the parameters should be; that is, the outgoing values of t1, pos, len, and t2. The test driver then performs the Swap_Substring operation and reports the outgoing values of the parameters. Further, if one or more of the actual outgoing values differ from the expected outgoing values, then the test driver will notify you that this occurred. In this case, one of your test cases has exposed a bug in the implementation being tested.
For example, suppose you want to
conduct the following test case:
| t1 = "Swap_It_Out, pos = 5, len = 2, t2 = "Them" | |
| Swap_Substring (t1, pos, len, t2); | |
| t1 = "Swap_Them_Out", pos = 5, len = 2, t2 = "It" |
The following shows the interaction with the test driver (user responses are in bold face):
Run in interactive mode (y/n)? y
Start testing (y/n)? y
test value for t1 = Swap_It_Out
test value for pos = 5
test value for len = 2
test value for t2 = Them
expected output for t1 = Swap_Them_Out
expected output for pos = 5
expected output for len = 2
expected output for t2 = It
-------------------------------------------------
| t1 = "Swap_It_Out"
| pos = 5
| len = 2
| t2 = "Them"
-------------------------------------------------
Swap_Substring (t1, pos, len, t2); |
-------------------------------------------------
| t1 = "Swap_Them_Out"
| pos = 5
| len = 2
| t2 = "It"
-------------------------------------------------
Continue testing (y/n)? n
Process shell finished
As another example, the following shows interaction for a test case that succeeds in
exposing a bug (user responses are in bold face):
Run in interactive mode (y/n)? y
Start testing (y/n)? y
test value for t1 = Swap_It_Out
test value for pos = 5
test value for len = 0
test value for t2 =
expected output for t1 = Swap_It_Out
expected output for pos = 5
expected output for len = 0
expected output for t2 =
-------------------------------------------------
| t1 = "Swap_It_Out"
| pos = 5
| len = 0
| t2 = ""
-------------------------------------------------
Swap_Substring (t1, pos, len, t2); |
-------------------------------------------------
| t1 = "Swap_?It_Out"
| pos = 5
| len = 0
| t2 = ""
-------------------------------------------------
ERROR DETECTED:
expected t1 = Swap_It_Out
observed t1 = Swap_?It_Out
EXECUTION TERMINATING
Process shell finished
An executable test driver that uses a correct implementation of Swap_Substring is provided for you to use for the warm-up exercise. It is located at
/class/sce/now/221/closed-labs/catalogs/closed-lab04/Swap_Substring_Test
IMPORTANT NOTE: For the closed-lab testing contest, you can conduct all testing interactively. However,
if someday you want to join the ranks of the "big time" testers, you should seriously
consider
making a test-script file for use in the contest.
To see how this works, let's suppose the name of the file with all of the test cases is test-in, and let's also suppose that the name of the executable test driver is Test_Driver. Then, in an xterm window, you can run the test driver making use of Unix redirection for input and output by typing
Test_Driver < test-in > test-outThis command causes Test_Driver to run taking input from the file test-in and sending its output to a file named test-out. Then, the user can inspect the file test-out to see what happened by typing the Unix command:
less test-outThis all works because the test driver gets input from stdin and puts output to stdout by opening the input/output streams as
input.Open_External ("");
output.Open_External ("");
Unfortunately, there is a catch. The test-in file must present all test cases just as they would be presented if the testing were being done interactively. This includes answers to questions such as
Run in interactive mode (y/n)? Start testing (y/n)?For the two test cases presented earlier, the contents of test-in should be:
n y Swap_It_Out 5 2 Them Swap_Them_Out 5 2 It y Swap_It_Out 5 0 Swap_It_Out 5 0 n
Finally, as a convenience, you can -- and should -- insert comments into your test script at certain points. For example, you might include the following line in your test script:
// Test case #1: swap from the middle of non-empty t1 with non-empty t2When a comment is located correctly in the test script, the test driver echoes the comment. Such comments can help you identify where you are as you wade through the output of the test driver test-out, and also can help you organize and read your test script file. It's likely that you'll want to add test cases to your script during the contest, so you might as well plan for it.
Here is the same sample test-script file as above, only this time it includes some comments:
n // Test case #1: swap from the middle of non-empty t1 with non-empty t2 y Swap_It_Out 5 2 Them Swap_Them_Out 5 2 It // Test case #2: swap none of non-empty t1 with empty t2 y Swap_It_Out 5 0 Swap_It_Out 5 0 n